QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2291|回复: 0
打印 上一主题 下一主题

经典任务调度算法的模拟程序

[复制链接]
字体大小: 正常 放大
杨利霞        

5273

主题

81

听众

17万

积分

  • TA的每日心情
    开心
    2021-8-11 17:59
  • 签到天数: 17 天

    [LV.4]偶尔看看III

    网络挑战赛参赛者

    网络挑战赛参赛者

    自我介绍
    本人女,毕业于内蒙古科技大学,担任文职专业,毕业专业英语。

    群组2018美赛大象算法课程

    群组2018美赛护航培训课程

    群组2019年 数学中国站长建

    群组2019年数据分析师课程

    群组2018年大象老师国赛优

    跳转到指定楼层
    1#
    发表于 2021-4-9 15:15 |只看该作者 |倒序浏览
    |招呼Ta 关注Ta

    # ^; Q' ~( d" c& N! V4 Y经典任务调度算法的模拟程序
    ! e3 L; k" {$ A6 {, s* P本科毕业设计写了一个经典任务调度算法的模拟仿真程序,测试了五种调度算法的运行性能。在程序中虚拟了任务的进程,按照不同调度算法策略从进程池中选取任务执行,在任务执行过程中,保存相关的统计参数,最后对这些参数进行处理,反映各个调度算法的实际运行性能,程序中可以通过修改任务的相关参数改变任务特点,测试不同任务环境情况下,调度算法的性能适应性。程序是通过C语言编写的,为了对运行结果图像化,采用了EasyX的图形库。由于计算机中实的任务调度过程比较复杂,在实验中为了简化程序的实现,在某些方面进行了特殊处理。
    & }+ z9 b7 Z+ A9 E/ }( i& D9 j. D8 S+ \4 b; Z2 |$ b# N
    编程平台:VC6.0+EasyX图形库环境。$ Q; `' m4 y$ l  ]( a8 w/ S

    5 L0 Q% X/ ^/ Y( L" O9 x以下截取部分程序运行图::
    5 {( n+ x- o1 g# _. N8 n" X8 y
    ) J, F# }4 S$ y7 \- L; C源代码:& A8 {0 \% Z* F( W. N- m
    % ~5 Q* I8 d: A6 H
    #include<stdio.h>
    % \9 u$ K% z5 u$ a: E" h#include<stdlib.h>& [2 M4 o$ C' s0 L
    #include<easyx.h>7 r6 t  ]8 M& N6 Y1 P
    #include<time.h>
    & Y+ w& g+ i: A0 p4 {5 `' `! C" |#include<conio.h>
    $ z6 c& l3 P  M; N7 d#include<graphics.h>
    4 O2 z% l+ w1 B  D# P' J2 w#define initProcessNum 10
    + H- Z  Q8 D2 V: N3 t' v#define initProcessID 1000) B% G6 G7 F: h' U* o
    #define MAXProcessRunTime 10000# z% C& z; H- ?8 r$ h. N
    #define MAX_MEMORY  4000
    4 x$ {/ V# {5 n- z# r! h+ z" e8 w" W#define exchange_IO_Compute 106 _0 s- l  w: k7 M5 g& k  k
    #define exchange_process 25+ l$ X3 a% s+ P7 E( s, z
    #define task_completed 1
    : q: V5 Q9 \! e. Y7 l, ~#define task_not_completed 0
    % s6 X+ @& o/ V+ Z0 H#define initclocknum 100% i0 s8 i  W+ F0 {. Q  Q( p/ R; v
    enum condition. m$ f  B! `7 Y8 u
    {
    ! q- v1 K2 }3 V- V7 T  t5 [- ~dead,computing,IO_waiting,ready* ~! k" v% S% B- g* P
    };
    4 ~  u# `( E5 L- D9 |4 |struct process
    ! k: y+ t% U$ u) H. }! q& S5 N5 m{
    ! d! b/ [5 J4 q) x/ x2 t- r) Tint processID;
    ; o8 U+ W/ r. y$ ~' J, `) q  Yint comeingTime;+ K, G# M$ d6 r1 Y! G# S
    int ioNum;
    * ^9 Q  _3 d* Iint computeNum;, Y+ Q/ h3 c. ^4 f7 a: F; X0 R, p1 Y
    int * ioClock;  a/ b) b, e1 j
    int * computeClock;
    - \1 m; D% z1 Z: ~2 y& ^int ioTime;
    ( o3 n- X4 K! {! T6 v1 f2 ]int computeTime;3 ~- S* f! l9 X' C9 w1 X
    int askMemory;8 p" R" @$ K- [' p+ ^
    condition flag;
    % @5 P# k4 ~* O0 Vint produceTime;  //生成时间,以下三个数据成员用以计算相关性能  J! a5 l7 N- Y! T4 r1 b$ @
    int runningTime;  //第一次占用CPU的时间' @8 y9 x2 |0 `6 T6 h+ m1 i6 o# s
    int completedTime; //进程完成时的时间
    # u$ W0 T7 p- G6 l: a' Z1 k: l};' |3 ]2 N% V* K; Y) _( b" p8 S
    typedef struct processCmpletedInfo  //保存完成一个作业的相关信息
    5 f2 L6 ~/ P  O{
    2 |" y% K! D4 S$ o+ O$ H! Dint processID,comeingTime,askMemory;. G: q. I# O( e2 E3 \, ^
    int compute,waitio,exchange,completedTime,runningTime;
    * X: o5 T8 `) n% h) M+ z/ aprocessCmpletedInfo * next;! i$ {, o% g$ p/ v- b
    }PCI;# r. Y# E, b9 q; Z# e3 M
    struct processPool7 \2 H5 z6 v% u# k& o0 z
    {0 T7 ^4 t$ g5 h, K! R1 i
    process * p;  Q& g' U. F) C$ x9 j* ?/ t4 S
    int proNum;
    $ S; B2 I% ?; |) t; f};
    1 v- ^' q! r. B* nint MAX_COMING_TIME=0,ID_FIFO=0,systemClock=0,FLAG_FIFO=0,FLAG_TT=0,FLAG_PF=0,FLAG_SJF=0,FLAG_HR=0,FLAG_show=1;
    0 }# f6 Y' e8 K3 Eint InitPool(processPool * p);9 @) ^9 ]* @  p$ n6 N1 A( X4 E
    int produce_one_task(processPool * p,int i,int id);
    & r9 ?9 T7 `; x" D4 D" Mint FIFO(processPool *storage,processPool* memory,int * spareMemory,PCI ** save,int draw);
    . X5 w. E# A& R4 b1 @int TimeTurning(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    : @0 G: ~7 [& lint TimeTurining_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory,int pos);5 s2 N6 \" I8 @4 L9 P8 w. t5 o9 \  C
    int FIFO_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);: u5 K  Z* d0 f
    int ShortJobFirst(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
      ~- F( l" n# d. r2 v. Hint SJF_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);: [& _' K$ C7 P
    int PriorityDispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    , D: u& w  d6 q/ r. Z- x' Pint Priority_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);
    . f* b1 t0 F7 \  A' L: gint High_response_ratio_s_to_m(processPool *storage,processPool* memory,int *spareMemory,int flag,int disatch);
    & ~% ^2 D" i0 t' N; Z" nint High_response_ratio_dispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);. T# c$ i5 n; f3 m

    . R' e# Q* i. \# U3 A
    4 Q: y1 F1 j2 i6 A" y9 O6 Bint sort_by_comingtime(processPool * p,int pos);
    0 J( H) `+ n$ N5 ~) E; }int showProcessInf(processPool p);" \& y, ~7 h9 X" p2 @
    int drawPerformance_FIFO(int x,int y,int memorry);
    ) Z1 C+ G: A9 ?/ Qint drawPerformance_HR(int x,int y,int memorry);
    & N  j, L6 E7 ]" o3 eint drawPerformance_PF(int x,int y,int memorry);. M3 o/ g0 P* L$ a" @3 _
    int drawPerformance_TT(int x,int y,int memorry);' F. K/ \4 }0 f7 F# f
    int drawPerformance_SJF(int x,int y,int memorry);
    9 l+ u% f7 ?5 l- z: u# z* xint MouseListening();
    8 m7 ?& c( J/ [# v* F2 Sint MouseListening2(int *flagShow,int * showTime);( q% e, I& R2 _# e3 L
    int showRunningResult(PCI* FIFO,PCI * timet,PCI * SJF,PCI* PR,PCI* HR);- @& F/ D0 X0 L6 B7 n: A. K6 P

    3 R; U2 f: H# X
    , e) |* \2 n" F& pvoid main()
    - |" y" E- O! r- \$ M* u) p{
    ' r6 s8 |* e4 i& gPCI* FIFO_save_head=NULL,** FIFO_pri=NULL,* Timet_save_head=NULL,** Timet_pri=NULL,* SJF_save_head=NULL,** SJF_pri=NULL,
    . }' H1 z6 H9 h8 t! a- }*Priority_save_head=NULL,** Priority_pri=NULL,*HR_save_head=NULL,** HR_pri=NULL,* p;. o9 G9 i& G$ j% x
    int i=0,FIFO_memory=MAX_MEMORY,count=0,Timet_memory=MAX_MEMORY,SJF_memory=MAX_MEMORY,Priority_memory=MAX_MEMORY,HR_memory=MAX_MEMORY,+ Y% x  O; b: _
    flagDraw=0,showTime=100000;
    & ^$ X* J/ v+ RprocessPool FIFO_p, FIFO_mmy,Timeturn_p,Timeturn_mmy,SJF_p,SJF_mmy,Priority_p,Priority_mmy,HR_p,HR_mmy;
    2 e& P$ L% d/ Z6 P7 ZFILE *fp=NULL;+ d9 P) x- ^1 \5 Q% [8 E* L, Q
    //processPool HR_p,HR_mmy;8 e3 b# ]" l( R/ m

    2 P; V: E1 R( n+ t0 H7 T5 B% X4 S" h( x; W3 T2 G
    srand((unsigned)time(0));
    ; }  F( L3 t& G+ J; qsystemClock=0;0 ~1 b4 E( n0 O' Q+ ?/ [
    initgraph( 1200,650,SHOWCONSOLE );
    0 i$ f" u' C- z+ l: s% xsettextcolor(GREEN);  u+ }" o$ I: C) o. ~0 C  t( V7 i
    setlinecolor(GREEN);
    9 o& n: _* j6 D7 u2 ?7 D% ~  {setfillcolor(GREEN);
    5 H. ^* u* D, r# ]3 gInitPool(&FIFO_p);
    & d- _+ M. E. J; C$ k: M: usort_by_comingtime(&FIFO_p,-1);7 ?) r; j- `0 \4 D
    InitPool(&Timeturn_p);
    - c) i6 f' f6 E$ U* K7 U- \9 }InitPool(&SJF_p);
    1 r1 v+ C& j: Z) b, n; Z3 iInitPool(&Priority_p);( k' G8 _! D, c( A& Z' M
    InitPool(&HR_p);# N& r* J2 h; v
    //showRunningResult(FIFO_save_head,Timet_save_head,SJF_save_head,Priority_save_head,HR_save_head);8 T8 G% H" m9 L0 [
    //Sleep(10000);
      R& k8 K" A% L8 y) a1 K" l! |2 ^
    " z$ B3 M- n9 l$ w- V: B8 @' W" j$ a" h1 D0 ?* q, b2 o0 Z& f
    Timeturn_mmy.p = (process*)malloc(initProcessNum*sizeof(process));" i" M& P- o: K/ b9 r1 }0 i: O" o
    SJF_mmy.p = (process*)malloc(initProcessNum*sizeof(process));
    % k. X' s+ ^7 r% [2 G  gPriority_mmy.p = (process*)malloc(initProcessNum*sizeof(process));. B  n+ x1 g: b( Y" J- U
    HR_mmy.p = (process*)malloc(initProcessNum*sizeof(process));! Z* H! ^$ p' y/ Y! B, ?5 W
    for(i=0; i<initProcessNum ;i++)) K1 t& K0 H$ U. d4 p* `6 o! r. s
    {+ p- V0 N' _) `' B/ R; y
    Timeturn_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));. C% Y% C* d+ P# U3 Q1 b
    Timeturn_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));8 i  a  I7 B& }0 G
    SJF_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));% n2 B( J' ~! @& _6 L) t- Y/ q
    SJF_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));
      k0 R: Y' B( g( U5 yPriority_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));
    ) v2 k3 O' z. {; u% QPriority_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));4 b& g& l* ]; z4 P: z& k* m  ?
    HR_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));( M' l$ Z" \4 v$ \
    HR_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));+ ^5 P3 y; q8 C, h/ N* P- }
    }
    3 W/ `/ u5 m( e8 u2 O, UTimeturn_mmy.proNum = 0;
    ( D. k7 q) q" s$ h) F2 z, p. S5 MTimeTurining_storage_to_memory(&Timeturn_p,&Timeturn_mmy,&Timet_memory,-1);
    , E1 [% i( w% ]9 uSJF_storage_to_memory(&SJF_p,&SJF_mmy,&SJF_memory);" I/ k) t% D) k3 `, L8 t8 ~7 Y) ]: F
    Priority_storage_to_memory(&Priority_p,&Priority_mmy,&Priority_memory);
    $ {4 ^" v1 w5 ~+ pHigh_response_ratio_s_to_m(&HR_p,&HR_mmy,&HR_memory,0,1);
    , Y9 F. _# K) T//showProcessInf(Timeturn_mmy);: |5 M3 G% {9 m; o; u5 h
    FIFO_pri = &FIFO_save_head;
    % _5 B: o) V# [, w7 yTimet_pri = &Timet_save_head;
    % I6 M* K# Z( o' mSJF_pri = &SJF_save_head;
    8 K" E" R. D; q6 K5 I" X( s1 m+ hPriority_pri = &Priority_save_head;5 a2 D9 V  `; `9 F$ W
        HR_pri = &HR_save_head;( @2 f) ~2 _0 @8 a
    setbkcolor(WHITE);! L) R2 U$ e6 l5 Y0 c# c% j
    while(1)
    , p& o* ]$ r: w( J6 g{
      _9 t( h& J1 fif(MouseListening()==1)  C' C- V" K  `8 W+ c! z) u4 n8 \
    flagDraw=1;( s8 q) W/ z/ _; ]5 ^: C* e( L$ \
    if(count==100)
    & T4 T) i0 B" X( g0 g8 c{
    1 E$ c! T% Q5 H- e3 s  xif(FIFO(&FIFO_p,&FIFO_mmy,&FIFO_memory,FIFO_pri,1)==task_completed)
    , g1 O1 g  d+ e5 p& \1 s7 S{
    : K' U+ m4 G) H1 g; |" JFIFO_pri = &((*FIFO_pri)->next);
      w; U- ]) V9 I3 w
    6 E5 j- P! d, @7 t//printf("hello");
    . t1 x8 E- }$ P9 l}
    7 l* W6 B/ J4 rif(TimeTurning(&Timeturn_p,&Timeturn_mmy,&Timet_memory,Timet_pri,1)==task_completed)9 o& }( R$ f, g6 d
    {, y+ f! P/ n! D  ?9 g  w
        Timet_pri = &((*Timet_pri)->next);. W9 H+ n8 e% L. M4 s
    //printf("hello");
    4 K& T- h+ e0 F4 x! ?; e}. L! u5 C. w$ Y7 i% i
    if(ShortJobFirst(&SJF_p,&SJF_mmy,&SJF_memory,SJF_pri,1)==task_completed)
    ( S. t- P; F$ }9 ?& E" J{# T" s9 N" ]3 r" z3 C& q8 t4 E) S
    SJF_pri = &((*SJF_pri)->next);
    ; _$ m/ i3 y$ F0 |  g//printf("hello\n");
    3 y3 m4 q; _/ S% q+ O9 j3 Y) G6 R0 A6 e}: d. x$ I* ?( L
    if(PriorityDispatch(&Priority_p,&Priority_mmy,&Priority_memory,Priority_pri,1)==task_completed)
    ! D( n  o# U: B{
    $ e0 {- \# p8 ~' I$ @. xPriority_pri = &((*Priority_pri)->next);" Z$ Y, D  _: i' ^( x' Z$ v& Z5 [' ?
    //printf("hello\n");
    1 O/ M/ @' ?2 o1 `% @}1 s# G  I# y* S- L
    if(High_response_ratio_dispatch(&HR_p,&HR_mmy,&HR_memory,HR_pri,1)==task_completed)
    8 H' |9 {" J8 T1 ~1 o( ?  h+ v$ Z{
    4 m( A9 W6 c  AHR_pri = &((*HR_pri)->next);
      Z( k1 q$ G- K/ r# J//printf("hello");# x9 _% b) s. ?
    }5 s7 o* c& B; S8 j' v( |1 m  X
    count=0;
    " T+ b3 `. f: B0 M}
    5 L- b7 V( m. L- ^8 l2 c4 H: delse
      A; e/ N6 ?9 u{! C- t+ @% `" N7 @
    if(FIFO(&FIFO_p,&FIFO_mmy,&FIFO_memory,FIFO_pri,0)==task_completed)+ p8 c9 {: n8 r! k9 c7 U& |
    {
    0 }1 N* Y& n& I; f/ MFIFO_pri = &((*FIFO_pri)->next);! j+ r& ]4 G' p3 D0 g/ w
    // printf("hello");+ f" H8 \3 h& B
    }  i# }6 o! h- b9 H" V6 d
    if(TimeTurning(&Timeturn_p,&Timeturn_mmy,&Timet_memory,Timet_pri,0)==task_completed)
    % U2 e4 f; W- P6 ~6 X* e. T% t{
    3 z4 h0 _3 N. u, F3 hTimet_pri = &((*Timet_pri)->next);& O5 n( o: b. o& S6 d3 U) D* f( v4 z
    // printf("hello");& G7 ]: F+ d  q- h+ h# y
    }! ~% R/ g3 f% x+ t. D. B
    if(ShortJobFirst(&SJF_p,&SJF_mmy,&SJF_memory,SJF_pri,0)==task_completed)6 e& I: E- X8 T0 k% |
    {
    ) Y2 _+ z+ B2 l1 M( R" _( ^4 T' I   SJF_pri = &((*SJF_pri)->next);
    ! H5 ?9 Y% P0 n1 `7 F5 A// printf("hello\n");
    ( e' G0 v  x! W. a; e* `, `}
    / v, Y; E* L- c" }! Vif(PriorityDispatch(&Priority_p,&Priority_mmy,&Priority_memory,Priority_pri,0)==task_completed)
    2 s0 e" U+ ~2 \, O% ^# ^5 s- D{
    ) Z" m* x3 p4 h- a1 S8 A8 SPriority_pri = &((*Priority_pri)->next);
    7 v5 D. r# E+ m; D//printf("hello\n");, e5 w; X2 u+ c$ d
    }6 T6 a) w% ?( Z
    if(High_response_ratio_dispatch(&HR_p,&HR_mmy,&HR_memory,HR_pri,0)==task_completed)) Z: u/ z3 q+ S2 T. l* y
    {7 }  F0 f& \- e) C: s
    HR_pri = &((*HR_pri)->next);# ?, K# C: ?: a' [( S1 h
    //printf("hello");3 X! T5 G, Q5 A$ l0 {7 r6 d
    //Sleep(1000);% _' i1 Z: `- h" x
    }7 y" y2 }+ Y$ U3 P3 N
    count++;
    / h- ]7 ]' ], w6 x4 L}$ ?7 S: h0 D3 }, _/ D
    if(systemClock==showTime)
    3 l( P4 w4 k8 ?. |5 a" {{
    2 p) ^, D. G2 y$ B( J6 J! F/*PCI * p=FIFO_save_head;' e3 L5 a/ W+ I: f1 e
    int i=0;) S1 D  K+ N5 c. w( g# K: Z
    for( ;p!=NULL;p=p->next)7 I- E' N' r$ X/ }% b
    {! O$ h( |  R  g+ V- r
    printf("Id %d\n",p->processID);
    . b2 e: K7 W: {- f- H- Aprintf("comeingtime %d\n",p->comeingTime);
    2 w4 V: C7 z8 y$ k, G( N9 u$ C+ I7 tprintf("runningtime %d\n",p->runningTime);, c9 `7 \9 Y: P& L: n
    printf("asdmemory %d\n",p->askMemory);/ q) M, A; e" p. e: G* s
    printf("completedtime %d\n",p->completedTime);/ h4 ]6 w# }, M9 Q
    printf("compute %d\n",p->compute);/ A2 j( Z4 n# x8 u7 u" ~
    printf("exchange %d\n",p->exchange);! s7 i0 ]& _# }" Z8 j
    printf("waitio %d\n",p->waitio);8 T0 Z0 R! U- m+ W  z" a
    i++;6 p. I6 n4 j8 }6 A  B% o8 M
    , e0 n$ ~4 r5 d8 V2 l1 y  H" W0 X

    . o. M2 O, M6 A% ]4 S}
    0 h* j1 w& o6 W- q2 Oprintf("%d\n",i);*/% W9 x0 U0 d3 j6 d* n' h( S
    if( (fp  = fopen( "data.txt", "a" )) == NULL )
    3 {" d7 ~! J( c1 Q! F! c( d3 \{+ P+ x: T0 `6 H4 r/ C; N5 P
    printf( "The file 'data.txt' was not opened\n" );
    ) q1 k9 r' S" p3 ~. P# |- U9 p//return 1;, l2 h. z+ i/ X
    }1 ~) G  \5 o  I3 \# U( \3 P/ W
    else4 ]" i; B+ c' r/ P  K# H4 M3 k
    {% t+ Q0 U  v. B. h3 k( g
    fprintf(fp,"FCFS \n");/ H+ u% c7 i" l( @
    for(p=FIFO_save_head;p!=NULL;p=p->next)5 U4 @- W( y$ Z& w
    fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    9 }( i+ ~& j9 d+ i% Hp->exchange,p->waitio,p->runningTime);: P/ ?/ G- V( S: j/ ?' y/ `
    fprintf(fp,"\nTime turn \n");- j: G+ }3 m$ W
    for(p=Timet_save_head;p!=NULL;p=p->next)7 Q$ e9 y, F" |. j, J
    fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    ; ?  j# M+ _6 {p->exchange,p->waitio,p->runningTime);
    1 t% X. S% K& d5 K8 O7 D! t1 Efprintf(fp,"\nShort Job First \n");; z5 @8 o/ Q' b" G0 l
    for(p=SJF_save_head;p!=NULL;p=p->next)7 d! t9 D; r' ?$ l
    fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,0 E% M7 |7 Z$ H/ w! }6 d" W
    p->exchange,p->waitio,p->runningTime);+ ^% o( U/ G- L* [& Q
    fprintf(fp,"\nPriority  \n");
    ' U. x9 F. O$ |" z' p* pfor(p=Priority_save_head;p!=NULL;p=p->next)
    , d- R4 J$ ?6 X4 V" bfprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    6 s+ s9 s( X* z) B( p  fp->exchange,p->waitio,p->runningTime);0 T- g2 _! {% B
    fprintf(fp,"\nHigh response \n");
    # O+ v' }% T' ?for(p=HR_save_head;p!=NULL;p=p->next)
    ; O/ V' T- U( L  jfprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    3 `6 r7 l3 g  C. a" e% Y; vp->exchange,p->waitio,p->runningTime);: X1 _9 [3 P$ C3 C, V0 }
    fclose(fp);6 H8 b7 t3 n& b
    }
    0 B& _4 r1 s8 W% f2 XshowRunningResult(FIFO_save_head,Timet_save_head,SJF_save_head,Priority_save_head,HR_save_head);& I& K! _0 W: N# Z) ?4 ~2 X
    MouseListening2(&flagDraw,&showTime);; u' h) B. a/ t; X3 U
    }2 Q& R& G$ P& P
    systemClock++;4 ^" ^5 R: C) j0 M
    if(flagDraw==0)
    " j% `5 T/ n* x9 ?' f* i5 {  Sleep(10);! D8 Z$ z: f+ U5 c% e. }6 u: n
    }8 y$ `9 h) Z+ n, B' S2 U

    ; h* C# z$ k# L0 Y! s- n' m1 V9 m% G
    }
    5 W. m, u; B" Q. Bint showRunningResult(PCI* FIFO,PCI * timet,PCI * SJF,PCI* PR,PCI* HR)* n4 f5 f; L$ Y9 m
    {
    & ^5 I1 `, T3 P6 N3 d, E. |PCI * p=NULL,* name[5];2 z% y: n0 O4 w/ O% y6 }
    int count=0,i=0;
    & |! w  V% O+ f& @, bchar ch[5][10]={"FCFS","timet","SJF","PR","HR"};
    ' ]; j& K/ [6 E5 S5 Ydouble turnover=0,wait=0,c=0,w=0,change=0,pos[4]={0,0,0,0};
    2 G- K3 y0 l8 Bstruct info
    - P; H/ ]5 {/ J& b; h' k  x{" S' t. h$ h  y) S7 ]
    char name[10];7 J9 O* }! w2 |) M' E! m- z( }. e
    double throughput,turnover,wait,CPU_rate;. p3 V: Q# o( o/ K) _& g6 s
    }inf[5];' f! P  W. U0 Z! f& V) g
    name[0]=FIFO,name[1]=timet,name[2]=SJF,name[3]=PR,name[4]=HR;
    2 ^8 o" W8 F+ @$ q# E3 O  k) [printf("调度算法..........A\n");
    + U2 ^5 x! H/ z) u2 _: d+ uprintf("吞吐量............B\n");
    & E7 P/ Y, Y! g& j/ s8 {0 rprintf("平均周转时间......C\n");" I8 G1 B0 Y9 u% v) C0 o
    printf("等待时间..........D\n");1 _+ e0 W/ Y4 q& N
    printf("CPU利用率.........E\n");
    * I* P/ n  \9 f& Fprintf("A\tB\tC\t\tD\t\tE\n");
    . N. V, B; g! S* m. Rfor(i=0;i<5;i++)
    / ]! R  p  L& t8 F% q{
    # ]' c/ D8 K3 p3 N" Scount=0,turnover=0,wait=0,c=0,w=0,change=0;
    1 x: T( A5 ^5 C2 g9 L' Xfor(p=name; p!=NULL; p=p->next)% S6 j, d; x8 t  \/ b3 J  l4 [
    {
    $ i& i" v0 W0 p* [- a3 Vcount++;
    " }& ^+ h' x5 X& bturnover += p->completedTime - p->comeingTime;& i3 h) B# R5 O/ U  C7 p( J
    wait += p->runningTime - p->comeingTime;
    7 F& k# V# m8 |& t! I$ bc += p->compute;
    9 L0 J* q, }& V' L3 |w += p->waitio;
    8 w6 C3 S; i( R6 @2 ochange += p->exchange;4 F; ]+ W) d1 v' E4 G' T: ]
    }$ ~% Y, E* ~# e9 E2 R$ r5 K: b
    turnover = turnover/count;, M$ ~7 V; i2 f, d3 Q
    printf("%s\t%d\t%.2f\t\t%.2f\t\t%.2f\n",ch,count,turnover,wait,c/(c+w+change));) y1 ]' x2 @6 @5 a$ l0 H
    strcpy(inf.name,ch);
    9 P5 n" ]6 B! z2 }$ }. iinf.throughput=count;$ T+ t4 t" z: e6 Q  v7 |
    inf.turnover=turnover;
    ) ^# I- ~3 \" vinf.wait=wait;4 z# c  S5 r/ P* w! R
    inf.CPU_rate=c/(c+w+change);# j6 L7 E; t+ J; d* I( n
    }9 O$ r0 l+ d9 U; [. J$ L
    //画图
    5 k9 s1 p; N4 ~9 H$ c, H//cleardevice();6 w; Y# P7 g% k5 m4 J1 ?! Q
    line(0,600,1200,600);& G' n5 S; x5 I9 Q) b/ j# U
    line(10,600,10,200);1 z, X% r- I# G! W4 |$ ^
    line(10,200,5,205);
    * I0 e- |3 t# E! Y; rline(10,200,15,205);! ?, }+ J# }, @
    line(310,600,310,200);
    ; J, Y) J: u  V0 X- gline(310,200,305,205);& x5 X7 L& s6 b6 ?
    line(310,200,315,205);! @  p* j5 \, D- P: G) H
    line(610,600,610,200);; ~- _; F0 U+ T& u( ]
    line(610,200,605,205);; a' D3 u/ n0 T( ?4 p1 n1 J
    line(610,200,615,205);
    0 c0 ?& f9 B* e. @, hline(910,600,910,200);
    7 V  h: H: S: B& D# h0 R# M/ {line(910,200,905,205);
    0 @) H& |7 q7 K" C/ Iline(910,200,915,205);//最高的长度400,宽度均为40
    ( x9 H0 ]* l5 z; a# Gfor(i=0;i<5;i++). Y* ?4 T' J% o
    {" t. Q0 x( a. a& [2 A% W8 S
    if(inf.throughput>pos[0])& j' P1 y- n, L3 o) ^3 w
    pos[0]=inf.throughput;" }) c1 R! c7 @- S5 G
    if(inf.turnover>pos[1])
    , Y; q& P/ h0 g/ ^$ C5 z( ?pos[1]=inf.turnover;; ^7 p5 N0 o. d. v
    if(inf.wait>pos[2])) @2 u! q1 O# }, j8 O" X: ?0 M& }+ i
    pos[2]=inf.wait;, G9 p# K4 |/ Y
    if(inf.CPU_rate>pos[3])
    . ?! x- y% [" d" a! z! q8 w( H% y2 I4 w! ^pos[3]=inf.CPU_rate;
    9 Y, D6 v) [0 Y( \1 i9 d( w, u}2 [" u, z' s' H! p
    settextstyle(30, 15, _T("楷体"));
    0 |2 h9 s1 {/ l8 R5 G9 `- ?8 qfor(i=0;i<5;i++)
    0 }; U7 L& W1 U$ Q- Y6 W{
    2 c5 q: R% A) z3 @2 V+ F. V2 n" Xswitch (i)
    1 _5 z. `4 H" n1 u{4 ~! ], ~- E, H6 P
    case 0:
    ! a5 @* G/ ~- E! `0 z6 U1 Q$ Usetfillcolor(BLUE);" c/ w$ y# b+ |) }5 m) S
    fillrectangle(100,50,150,100);
    3 \' y6 g: u5 qouttextxy(160,50,"FCFS");
    % W/ ^  `* M* U5 fbreak;, G+ ^2 P' z! C: ]" S# Q
    case 1:
    8 n3 M7 Y) K9 S2 Zsetfillcolor(RED);6 L& V7 R* n9 m; I: ^! [( \
    fillrectangle(250,50,300,100);
    ' W) M& ~* B# Y; V# I# W4 e7 Kouttextxy(310,50,"timeTurn");
    ) \7 h4 R- j8 z; c, cbreak;; m9 c/ e! l7 b( }( t
    case 2:6 M# F4 f, M" H9 ]1 [. o
    setfillcolor(YELLOW);5 G9 ~+ E2 w* {, o& E
    fillrectangle(450,50,500,100);
    + [. O& I$ l2 S: G) n  U7 E0 T& d' S7 G, Oouttextxy(510,50,"SJf");: \# }. j! v$ M; x, H1 }5 n
    break;
    / y9 g4 r' o" C7 J- R5 tcase 3:
    ; j( l  b& W' g" [/ K7 Jsetfillcolor(BROWN);
    . h8 E$ t& T  |- wfillrectangle(580,50,630,100);8 B- s4 O8 z% M- G3 c
    outtextxy(640,50,"PR");
    ! x6 Y5 i8 c0 |break;
    $ W. n  l: C2 w4 u/ Fcase 4:  _) {* R" ?% F6 P% d5 U& r
    setfillcolor(GREEN);
    + U$ \5 S7 X7 qfillrectangle(690,50,740,100);3 u$ v, {# w% c2 `3 X
    outtextxy(750,50,"HR");; l; T+ s0 |7 ~! E
    break;) B+ U- g; E1 D5 T* z' l0 K& o
    }/ C2 l, \, k  _. A
    fillrectangle(50+i*40,600-(int)(inf.throughput*400/pos[0]),90+i*40,600);$ }! u6 H$ [" D
    fillrectangle(350+i*40,600-(int)(inf.turnover*400/pos[1]),390+i*40,600);, E! ?0 s6 a6 Z; h8 F
    fillrectangle(650+i*40,600-(int)(inf.wait*400/pos[2]),690+i*40,600);5 s  W0 `! z/ E" W2 L8 H
    fillrectangle(950+i*40,600-(int)(inf.CPU_rate*400/pos[3]),990+i*40,600);1 W7 K) Y6 O8 c0 x
    # Q& P' I2 k; H' {8 a* }/ K9 T
    ! ]% D! C+ ]3 O+ W1 Z
    }
    ' k0 Q/ v' x3 I# l+ h$ o    outtextxy(100,150,"吞吐量");
    % G+ x, h7 H, ~9 c5 d) Louttextxy(350,150,"平均周转时间");* B0 O) D' D5 p  _! k% {
    outtextxy(650,150,"平均等待时间");' t+ G  m. Y- }# J4 Z% o2 ~" n
    outtextxy(950,150,"CPU利用率");& H4 j$ z% c$ q$ ?; S$ [
    return 0;7 Z$ \* ^5 x" j: Q
    }' `1 E7 `4 y# n1 k, g! ~9 c0 M5 d
    int MouseListening()8 w% i6 {% }: w1 {
    {
    ( }& h5 z" p. `* P, c5 y9 ~8 `MOUSEMSG p;
    , ~/ a( O& j( X' j& A2 oif(MouseHit())$ {% r5 e: N3 t  n% i& u3 h
    {
    1 b% c! \9 E+ z  a/ g3 Dp=GetMouseMsg();$ r& k8 `. w- t5 W
    if(p.mkLButton==true)
    / z  N2 b1 C! \: c: y{8 \. @" D/ [% M3 I# e
    if(p.x>0 && p.y>0 && p.x<400 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)
    # q7 t9 h& F- cFLAG_FIFO = 1;
    - E: w+ n5 A. g3 K2 ?( G; Gelse if(p.x>400 && p.y>0 && p.x<800 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)
    . G1 Z0 n/ `4 XFLAG_TT = 1;
    $ t0 E; p- Y( M& K9 }else if(p.x>800 && p.y>0 && p.x<1200 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)
    3 w7 E5 g3 j& d! Y2 _+ J& KFLAG_PF = 1;. s* f. D0 d+ m+ }4 i
    else if(p.x>0 && p.y>325 && p.x<400 && p.y<650 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)
    5 C  g" v3 Y3 hFLAG_SJF = 1;
    1 d' O8 F2 M/ C; ^8 d7 l2 xelse if(p.x>400 && p.y>325 && p.x<800 && p.y<650 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)
    ) O9 t$ n3 R' G+ m" r1 \6 T3 {FLAG_HR=1;& V! h- i0 w+ u  |7 u/ k
    else if(FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO >0)
    & ]- A1 m' U) h: r& t{
    : A+ k( p7 N8 O" u' DFLAG_HR=FLAG_SJF=FLAG_PF=FLAG_TT=FLAG_FIFO=0;
    0 v$ n' v! @* K; t' |! h! W3 |, tclearrectangle(800,325,1200,650);$ {' V1 c/ B; k) {) c
    }
    9 p% F; e' \8 v: X! Helse if((FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0 && p.x>890 && p.y>455 && p.x<1110 && p.y<510 ), x" P: f2 T* u1 a
    {
    0 i* i  R( W8 \% Q1 m5 N! iFLAG_show=0;6 q5 F/ l! v* L# T
    cleardevice();
    ( }9 K- n6 `- \, D' [return 1;
    * R  w# I2 {! R4 [; n' G4 Z: A6 L}
    ) f% }1 }! N9 w2 p}
    ; |$ _$ X. y& c' x0 v}
    $ f7 z- t9 v8 [2 d4 c! Hreturn 0;
    0 c0 d# m+ A1 o# `3 l. W}" G5 J. `6 Y/ M+ d2 Z* K
    int MouseListening2(int *flagShow,int * showTime)
    - K+ L. K# b4 X+ f3 C{/ S7 J# ]5 q- h
    MOUSEMSG p;: l2 M! B0 L4 o9 [' ~% l, V. n
    rectangle(1150,0,1200,50);  I) F- q4 t" P8 K( O
    outtextxy(1160,10,"X");
    ) A- }* J8 s* x, p5 P0 K* Z- twhile(1)
    . l! v0 z/ t$ C5 L3 E{
    ; q, O6 _+ K' b& f: `- oif(MouseHit())
    ! ~6 }' ~0 a2 a3 J{
    ) P1 ~& ?- \$ y, pp=GetMouseMsg();1 S+ }1 Q$ z. K1 [" i9 k8 Q0 ~. y
    if(p.mkLButton==true)
    3 A, E/ g9 [: @9 j) V2 X4 e( F4 q{
    . h* J1 e+ H5 y  t& @5 iif(p.x>1150 && p.y>0 && p.x<1200 && p.y<50 )7 v4 a- }/ ~2 r- e3 f& r5 t, I
    {
    9 Q" D& H2 P$ V7 c9 I% m& P0 ](*flagShow) = 0;# b2 E/ w  y; u0 |# S/ j& V
    (*showTime) += (*showTime);! d0 X& J; p% d* G
    FLAG_show=1;
    # R* O+ w- F! \) u! xbreak;
    % [, S; F9 K: C" o6 Q8 f; o0 L}
    % P2 T4 O) ]6 h  Z8 m4 `2 |$ ?0 n; E* d! U5 n
    }
    ) J9 e8 I% U5 ~. g" s0 k}/ [+ F5 a- A2 C" d% h+ O; K
    Sleep(20);0 g: ]& U7 p( T1 z2 O9 h2 S7 g# I8 `4 y
    }5 I; }$ S, U, P6 e5 X3 ^# A
    cleardevice();9 L! y5 J" f' g( m3 c9 ^# ~
    return 0;
    * `6 w% G4 G; G# X9 t: ~! x3 u}, `) D! _" V5 T4 a& v5 t
    int drawPerformance_FIFO(int x,int y,int memorry,int com,int wai,int cha)
    ) s4 _( q" w2 t7 Q- T{
      i1 [7 f7 m: ^" mstatic int info[11][3],num=0;
    - Z% ?9 u( G  |! Q2 ?int i=0,j=0,pos[10][3][2];- m# ?0 l* ?6 @$ J& T
    float temp,t;
    9 `* u- n2 p3 t. X5 o- u* K//画按钮,不属于FIFO图的范围+ ?+ r, m, I7 O. f
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0 && FLAG_show==1)
    & ?0 b: Y9 ^5 {5 R{
    / F. f9 o* M; @7 Jsettextstyle(30, 15, _T("楷体"));' q& q  ^1 m4 F+ w* p
    rectangle(890,455,1110,510);+ D  b2 b( |" E  n7 u1 V9 n) p' D" F, {
    rectangle(900,465,1100,500);' G; o  _/ h% Y% z
    outtextxy(910,468,"查看运行结果");
    ( j8 \1 O$ N  m) A& P}, ~7 n8 T& [6 [6 _, ?0 G5 d
    //结束画按钮
    0 g$ ^! e! n+ r) C5 [info[num][0] = com;$ m/ K+ ^9 d$ U
    info[num][1] = wai;  v+ Z) ]3 h1 ?' k# l, {* ]2 `2 ?% H/ g
    info[num++][2] = cha;1 T5 m  f  c% t$ G' r0 p+ s" \
    if(num>10)  //存储10个点
    ) l1 q: N: c6 J2 I8 A{
    4 ^$ y5 [5 d3 |/ r( G/ afor(i=0 ;i<10;i++)% o/ T  E! I0 b! O
    {8 x5 C2 i1 k  p" d
    info[0] = info[i+1][0];* d+ h! D9 d! k) Q$ s0 W. J
    info[1] = info[i+1][1];8 \8 o, }: \: g. J, v# S5 `) I0 g; @
    info[2] = info[i+1][2];- D' I8 _5 _3 ~' h) u# S
    }
    2 T. Y: v- ^# ]/ U/ h% N4 j- Ynum--;2 Y& E1 I' j) w; X6 c1 H# V
    }
    & s4 X- Q# b# n5 d4 @" @3 eif(FLAG_show==0)
    ' s5 F# x$ K0 @0 B) `# ]; treturn 0;8 d# S  M) @% v* H- U  ~$ _
    for(i=0; i<num; i++)
    9 f& ?: ^. N$ D& Z8 }{
    & R) h0 c1 _. r. q' k6 t2 y0 P5 {8 kt = (float)info[0];
    . s8 A5 S* k$ M* ^+ O9 v# p% S. Q' ltemp = (t/101)*90;
    0 @6 \- _0 ~/ upos[0][0] = (10-num+i)*25+x+100;  ?5 ?1 a- D0 L
    pos[0][1] = y+110-(int)temp;
    # f& j+ K8 p( d2 R1 ft = (float)info[1];/ t7 F3 t' t1 q3 T
    temp = (t/101)*90;3 G  J1 h! c/ ?% \
    pos[1][0] = (10-num+i)*25+x+100;) w# N$ g' o  p/ p& i" y
    pos[1][1] = y+210-(int)temp;
    " R$ u2 x0 g- at = (float)info[2];
      p: ]+ w9 L, J! [1 |2 ktemp = (t/101)*90;/ p0 @  E6 r4 C: @; A+ I" ~: c
    pos[2][0] = (10-num+i)*25+x+100;
    ! c. Q* r) {, a9 o5 s$ Apos[2][1] = y+310-(int)temp;; S! J6 f  u/ H- ?; q
    }
    % p+ J# X: o7 O9 gif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)( B; C9 [/ M- s3 }  _
    {
    . Q* `; A: S% n5 v/ Eclearrectangle(x,y,x+400,y+315);0 n) ~+ w9 _$ {; k2 ~+ @* |% b) R
    settextstyle(20, 10, _T("楷体"));
    ( [1 \9 q' @7 J# y* R5 {; ?rectangle(x,y,x+400,y+325);4 O7 J. L' \9 `4 N
    outtextxy(x+40,y+10,"CPU");       //画柱状图
    " U( K4 C* ~$ [  ~9 r" a7 eouttextxy(x+45,y+10+100,"IO");
    0 ?/ p0 r1 r( D& X2 \outtextxy(x+40-15,y+10+200,"change");
    0 p6 ^. b9 Z( I$ {  g6 g6 \; grectangle(x+35,y+30,x+75,y+110);
    - y, x+ A7 N6 u% O% B4 ~! g' frectangle(x+35,y+130,x+75,y+210);
    1 i% u) q2 S" ^3 y/ r  f$ g/ Z1 ~& U9 lrectangle(x+35,y+230,x+75,y+310);: g0 Q) L. r1 W9 Y# v
    outtextxy(x+180,y+310,"FCFS");, s: Y* T: @& H' u8 ?
    t = (float)com;
    ( z+ S4 `5 l% q7 s+ w) Vtemp=(t/101)*80;
    ; q9 Q( w# l& d  N! Hfillrectangle(x+35,y+110-(int)temp,x+75,y+110);
    - Q! ]& }: _" T9 |t = (float)wai;9 s1 w0 I$ {+ `4 E5 x3 b- |; z
    temp=(t/101)*80;# z$ R' ~  I" f; B
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    # h1 A) {; J5 ~! B$ `! \: ct = (float)cha;
    % |. a& {1 I+ U% Q; y3 n2 \2 rtemp=(t/101)*80;
      s2 i6 Y$ ?! m/ H7 Rfillrectangle(x+35,y+310-(int)temp,x+75,y+310);, b' V  c5 W& v& d" E
    for(i=0; i<3; i++)   //画坐标   high=90,length=250% b. ~/ u$ x$ k5 p$ ^  W
    {
    ! x; V% d* Q; c/ a, O2 P0 qline(x+100,y+110+100*i,x+350,y+110+100*i);  p* A; M6 Z' Y: ?, U2 _
    line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);( j4 G" |  F1 r! _9 A, Q$ h, }
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);
    2 N$ B) w# D: z# I9 v  r
    4 l9 f$ R% U# I* d, T/ A8 O' }line(x+100,y+110+100*i,x+100,y+20+100*i);/ K: L) E4 P+ X# B
    line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);
    - k( i$ I( g8 O3 z/ ^" T. F$ Bline(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
      f4 b: H( J) ^7 @for(j=0;j<num-1;j++)
    . n1 |9 b6 l+ \- N& C- X! G{  w. j/ t! T  \7 w
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
      U/ D" W. U- G; {6 {line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    * U3 g4 y2 u# h- N, {6 T; [line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); 6 Y+ D6 {1 k2 E% o( [) f6 W8 [% s4 J
    }
    5 J# |( b  {7 k0 F}9 o* B; b6 Y  O' H# V5 U& L1 i
    }# t5 Q$ N; A+ T7 ~8 q  Q
    else if(FLAG_FIFO==1)* v+ e; J+ {6 P) X. F* q
    {
    8 {. O3 U) ]( }x=0,y=0;
    ; b# c( B8 p- v. cfor(i=0; i<num; i++)
    ( ?, m4 I: ?) |  j* z9 U: P' y{
    ) F: m7 v# r7 [4 T" vt = (float)info[0];; k/ x$ a: B$ N5 V/ i, a
    temp = (t/101)*180;5 j( a4 [5 {! N. E) z
    pos[0][0] = (10-num+i)*50+x+650;
    7 a3 X/ D# Y; X4 d1 f. g$ p- w1 {pos[0][1] = y+210-(int)temp;
    % q( n: V# F' y8 S. }6 q  c/ Ht = (float)info[1];4 G. J8 H4 N) j& g6 J. h/ q2 c
    temp = (t/101)*180;
    ( U' _3 X7 N7 [. H6 J- s6 G( s+ rpos[1][0] = (10-num+i)*50+x+650;
    6 A6 D! g; N0 s. s7 s; gpos[1][1] = y+420-(int)temp;1 C1 k- c* i9 a8 \. W- b: f
    t = (float)info[2];1 t9 Z6 M, Y7 k, B+ U# `; r% ?1 m
    temp = (float)(t/101)*180;
      f) e, |" A' P, ^2 t% Wpos[2][0] = (10-num+i)*50+x+650;
    0 U0 Z+ i7 A  ^" \! a7 b) Hpos[2][1] = y+630-(int)temp;' W: v0 \6 y& \8 z8 b. r# L
    }
    / w( I: ?; }% Y9 `+ D1 o( _clearrectangle(x,y,x+1200,y+650);
    : a. ]. h1 D8 W0 \3 D3 c" Nsettextstyle(40, 20, _T("楷体"));6 i' o) f" Q) {
    outtextxy(x+50,y+50,"FCFS");
      V) W2 m- x0 n' X: g. Uouttextxy(x+280,y+20,"CPU");       //画柱状图
    ( r5 f2 L8 ?5 Q6 i5 aouttextxy(x+285,y+20+200,"IO");1 V% _5 t8 w. P
    outtextxy(x+250,y+20+400,"change");) M' f& X4 a) x( X4 y% D5 e
    rectangle(x+270,y+65,x+330,y+215);0 x$ Z+ ]+ z, B5 B9 u; M/ Z* ^
    rectangle(x+270,y+265,x+330,y+415);
    ) D% S. n: \2 N/ u  i4 k* Irectangle(x+270,y+465,x+330,y+615);
    ) u' p- ^1 x' ?outtextxy(x+290,y+620,"TT");6 a9 b/ y! {7 e" D7 u" F
    t = (float)com;
    " a; w, H  P' Z+ _temp=(t/101)*150;
    , d# P: K% C! f1 R" N; Gfillrectangle(x+270,y+215-(int)temp,x+330,y+215);" K7 E& l  T- f5 B6 o
    t = (float)wai;
    ; O$ P+ W/ C. U, {1 \. Y0 e4 B5 mtemp=(t/101)*150;
    5 d# Q% ~5 B1 Y* J' Cfillrectangle(x+270,y+415-(int)temp,x+330,y+415);; I8 {$ C4 r, h9 A% t7 ~2 V
    t = (float)cha;
    - z8 k/ Y" k& v- M- N, d  K  |/ j" itemp=(t/101)*150;
    % z8 M) l/ K5 q" Q. Pfillrectangle(x+270,y+615-(int)temp,x+330,y+615);7 @( L# K5 j, T( \2 H
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    / h; Z. v# l8 X$ \+ C5 N{; }1 W# T6 g& U( U* x& @+ Q
    line(x+650,y+210+210*i,x+1150,y+210+210*i);! U4 s, A! R) g' F7 p2 l5 P
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);) W) I4 z  |/ h' ?0 ^6 o
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);6 f0 O$ w8 p' l' ~
    & V& p/ D' Y; c$ k2 L$ I
    line(x+650,y+210+210*i,x+650,y+20+210*i);
    % O+ ~! H" c2 q9 Xline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
    . _3 R9 N3 T2 B$ l3 Zline(x+650,y+20+210*i,x+650+10,y+20+10+210*i);( M  o, |4 c6 P9 O3 f
    for(j=0;j<num-1;j++)
    ; C. f$ \9 N8 C& B. g{
    ' m/ _0 t3 a/ L1 B2 Bline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);( l# j* r# }% _; ]; w7 V
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    ) q5 J- W+ p$ l* Y" Cline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    5 M2 d' x- p' t# e, L% w; x}
    6 L% Y( J* i: o0 K5 C3 D}0 h/ K% s0 ?* V
    }$ z/ {: W3 h4 |! d1 z( e

    9 |2 |6 r( w3 t4 n6 Q) D5 S, e  _9 `" m3 O9 R
    return 0;
    5 \* |% {! @  S+ @, W/ Q" t}
    ! ]; A. a! h  F9 Pint drawPerformance_HR(int x,int y,int memorry,int com,int wai,int cha)4 ^! j" ~% B% l8 N. E3 X; n- F( n) x4 z
    {3 S! Z* r1 d; p3 C* x, p0 U
    static int info[11][3],num=0;
    + }% t/ u( d7 F" `int i=0,j=0,pos[10][3][2];
    6 K% G+ u6 ^8 j* H3 ]float temp,t;/ \5 n0 {* |4 F
    info[num][0] = com;9 d! r* x, h7 L' F2 B4 M
    info[num][1] = wai;' @1 b& V9 K4 t$ s
    info[num++][2] = cha;* D! G+ q$ C, u  ?& a9 N0 {1 u
    if(num>10)  //存储10个点
      f! L( X0 ]  n{* K( C0 R- u% S! r. l; @# w5 R
    for(i=0 ;i<10;i++)
    4 c/ A4 }* r! k" X) s) `5 g{; D- M" I5 [& F/ ]" @. W
    info[0] = info[i+1][0];
    / Y1 ?' y; L5 \, q2 T1 cinfo[1] = info[i+1][1];7 x1 N7 W9 T  M6 K! m, j
    info[2] = info[i+1][2];
      i7 T1 C8 \1 C}
    - `1 V. I5 ^/ l+ |( n# Anum--;5 S6 j1 h" b3 Y  _7 h' x
    }
    9 e5 r$ X8 v( \( E6 yif(FLAG_show==0)
    3 V- }% s# \6 K; ~( ~8 n8 areturn 0;
    ( x; V, B' G0 x4 Cfor(i=0; i<num; i++)5 u% F- w% f7 M" f! t
    {
    . [1 P( A& C& ]3 F6 g9 rt = (float)info[0];
    ( O3 i" V* U- Q# R- M& Htemp = (t/101)*90;2 o, \* Y& w9 T2 }0 Q. R
    pos[0][0] = (10-num+i)*25+x+100;
    0 r- b- }2 }1 C, opos[0][1] = y+110-(int)temp;
    7 V% X# H' S: P. `1 Bt = (float)info[1];
    " {: D( [9 v  ~* l7 |temp = (t/101)*90;& P- G4 r9 u% I' R6 n9 W
    pos[1][0] = (10-num+i)*25+x+100;5 v* U& Z9 Y) Q- W+ Z% x) r
    pos[1][1] = y+210-(int)temp;
    0 e3 t9 c8 ~. `( O. o4 lt = (float)info[2];' z# d9 w% r  c4 O5 B, u: Y2 Y
    temp = (float)(t/101)*90;
    3 \& D2 g4 `3 Npos[2][0] = (10-num+i)*25+x+100;; W& Y# m5 A1 H' I( U
    pos[2][1] = y+310-(int)temp;
    0 T1 g1 b+ |7 i! E- d% v( h}# L! P+ ?- U& `% e. E# \! n
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)7 |/ h* d8 a2 k! c( _; J& X3 w2 u
    {7 p7 ]' ]$ V, z, a5 Y/ t
    clearrectangle(x,y,x+400,y+315);
    8 Q* G2 B9 C5 X8 I! s" E1 Fsettextstyle(20, 10, _T("楷体"));2 V. v/ S* T5 W: T& p$ R
    rectangle(x,y,x+400,y+325);
    3 S% d. R2 z% K( j9 }outtextxy(x+40,y+10,"CPU");       //画柱状图
    # T8 y* G' d7 @! Z& Routtextxy(x+45,y+10+100,"IO");
    / j$ ~' A" N7 n. iouttextxy(x+40-15,y+10+200,"change");& e8 A" u7 @6 e! B/ [9 ~0 _
    rectangle(x+35,y+30,x+75,y+110);
    ! }) v# M! v$ y# j! E# Q) J- P- Crectangle(x+35,y+130,x+75,y+210);- v0 [" ?. ^( F+ Q/ D
    rectangle(x+35,y+230,x+75,y+310);
    4 {- @2 b, }' I1 l/ b% `+ ~$ @outtextxy(x+180,y+310,"HR");
    - V% U* ^$ N/ E9 ^! Kt = (float)com;
    0 p& I; F8 j- M8 N7 g( D' ?temp=(t/101)*80;- r: ]& ^( j6 |: q, H: S
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);% Y. e- I0 w$ m
    t = (float)wai;5 {: J) I- p  t5 l1 _
    temp=(t/101)*80;$ h# I; ?7 c# ^9 C9 g+ R
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    6 A1 e8 w& j0 V$ K- Vt = (float)cha;
    & ~6 C7 f% Z: D2 xtemp=(t/101)*80;
    5 Y2 D2 a! U' f! x# Q: Tfillrectangle(x+35,y+310-(int)temp,x+75,y+310);# s3 A- q& T- a6 s" C
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    6 \1 }& F+ F' U9 {; q, V) k6 b{
    9 Q. Q7 e! k! _2 Z6 Hline(x+100,y+110+100*i,x+350,y+110+100*i);
    , ^9 W3 E, s5 a0 v) ?line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);' O! ~  U6 `4 S3 I' r! M# F5 E; }
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);5 h2 i* S& ~7 t$ |) C( ?
    # j6 Y6 _! ~9 D+ a$ |
    line(x+100,y+110+100*i,x+100,y+20+100*i);5 y& F3 c$ Q$ ^& S
    line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);/ G9 @* C9 I& F4 A2 x6 O! ]
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
    6 g# z& J" L& x: d1 n# I" Qfor(j=0;j<num-1;j++)
    , r5 s9 G$ v2 }5 O( ^{
    1 w9 [$ \; b. H8 c5 _line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    $ B, Y$ T" d5 ?# a; Z, _line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);8 j/ O) o* s0 M0 ~& K& m9 b% e0 c
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    4 M: f: B+ H0 `1 u$ s; T}
    $ a/ N9 r/ m( y" k6 P0 o& s}
    + J' G$ g7 M/ v}
    ) ?' a' I* [0 I. Belse if(FLAG_HR==1)
    $ S* Q! [( |. W# x2 V) m& ?& `5 E{! W7 k4 y/ d: f# m/ A
    x=0,y=0;
    $ S8 m* ^6 W) j3 \* U' t5 cfor(i=0; i<num; i++)
    % o6 _- {% [/ C( G{5 a) J4 O+ Y& S4 K+ X5 r# J( O
    t = (float)info[0];
    0 J& H5 D1 F% J; a8 b* Ktemp = (t/101)*180;) m4 J% [. s; A4 n0 b, v
    pos[0][0] = (10-num+i)*50+x+650;
    ( R. u8 B" P" @3 V# \( npos[0][1] = y+210-(int)temp;
    ( l" p( m0 l% \+ a3 f: X/ ft = (float)info[1];$ w. Q8 x/ h# L) T% e
    temp = (t/101)*180;. `. T8 d9 W; R
    pos[1][0] = (10-num+i)*50+x+650;
    6 w) w, w- b& Ypos[1][1] = y+420-(int)temp;1 G) x$ f* B" Y9 h% W- m4 ]5 K$ {
    t = (float)info[2];
    1 ^9 \* n2 z# i; P! p( Ftemp = (float)(t/101)*180;
    2 O# j9 l& W/ C/ r/ Z( ?2 epos[2][0] = (10-num+i)*50+x+650;6 H" {/ g" p* t3 P8 T# X% F0 E
    pos[2][1] = y+630-(int)temp;0 [# f/ M/ [: |5 b% |- m
    }
    ) O0 d" a5 S: O' D7 H8 W, v, nclearrectangle(x,y,x+1200,y+650);% u' m5 g( `1 a# `3 M- h: ?
    settextstyle(40, 20, _T("楷体"));
    3 T, Y# O2 q1 B8 D! [! g7 B: b+ eouttextxy(x+50,y+50,"HR");
      Z/ {3 D3 i8 E* {3 }0 }& O  ]outtextxy(x+280,y+20,"CPU");       //画柱状图& I4 W! x  J" H$ L
    outtextxy(x+285,y+20+200,"IO");; o% _; p# p& G
    outtextxy(x+250,y+20+400,"change");& o& m; w% b1 U3 Z% M: P2 @3 Q4 @
    rectangle(x+270,y+65,x+330,y+215);5 Z3 ^! b8 R" e& I0 @+ {2 J
    rectangle(x+270,y+265,x+330,y+415);& x+ U- s9 V0 b$ O: Z4 A, s  ~
    rectangle(x+270,y+465,x+330,y+615);
    9 R6 u, o( A5 b1 G. l% Uouttextxy(x+290,y+620,"TT");
    ) y! a' V' D8 Yt = (float)com;$ w9 h5 T+ H, q# \, I' z
    temp=(t/101)*150;+ I; f- |2 w' _6 e& M& @
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);' T8 h2 {: O3 r, d. ~6 q, n1 }
    t = (float)wai;
    % Y: k5 o: D3 s5 d1 ktemp=(t/101)*150;
    0 y& [* C% K! Kfillrectangle(x+270,y+415-(int)temp,x+330,y+415);: g( @- k3 N+ Q2 q9 @  X+ A; O
    t = (float)cha;! z3 E% }! P) v7 q6 R1 [
    temp=(t/101)*150;; U2 C1 C" M& x" H3 S. a
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);# }( L$ S" W; u2 c! D/ w% P7 k
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    9 f9 a- K+ J; @6 _6 m{
    ) _! I  O. S$ d; \& \line(x+650,y+210+210*i,x+1150,y+210+210*i);
    ) C0 K7 h9 p  Z5 v$ ~. d6 @line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    8 u% }5 I  v; o6 Q" Xline(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);
    ' O9 S) o0 K6 C$ P5 U6 m$ c4 {) w' q) a: i. O4 V* u
    line(x+650,y+210+210*i,x+650,y+20+210*i);( z' F9 y6 Y4 d, D
    line(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
      o/ i0 d6 C; [  eline(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    / d" r3 Z+ x/ {' C, E9 f- I( G# Rfor(j=0;j<num-1;j++)& O7 S: q8 D, b! E
    {
    . _( w. I9 M  O0 W, B5 eline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    ( n8 r; b& q$ Wline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);4 i" {: ?( @* ~% u* }
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    6 A9 r: J2 K+ ]# u. N: v}
    7 j+ z( b# W5 g% l}' C- ~7 e( Q# s) B+ B$ q9 q
    }
    . ]! C* v, ~  i- G# P' i+ [
    ( i# T9 a4 G% G/ W
    3 X9 ]0 P; v7 T" Areturn 0;
    - y9 s+ y* I) o/ b- L. j3 O( T}
    / J0 B9 W, K& c) B! v0 S  @) Qint drawPerformance_TT(int x,int y,int memorry,int com,int wai,int cha)* e4 ^* [9 L. p
    {
    : {! b* B) S4 Z$ K2 O, a6 Kstatic int info[11][3],num=0;7 Q- d" H7 {9 J' z- ?5 F+ a( n  L( _
    int i=0,j=0,pos[10][3][2];
    ; ~3 H$ j& }: V2 O- Q0 tfloat temp,t;8 ^7 ?$ ~' x& w3 N6 O& J/ R3 V
    info[num][0] = com;
    & i+ v) ?5 C7 {% W% B3 _. e4 linfo[num][1] = wai;
    7 a8 W# V3 k. F4 ?" o% j8 rinfo[num++][2] = cha;
    - ?, ^  c3 Y& y5 ?9 u5 ~) r& W' qif(num>10)  //存储10个点- P+ P  G/ o2 m, n
    {
    1 ?2 J- F' S* Ifor(i=0 ;i<10;i++)  V! c* p5 K. e9 \! x. e
    {1 x* [6 S- z) A3 h$ h" d
    info[0] = info[i+1][0];
    # k* X( N, D; X. t8 p' Z. |info[1] = info[i+1][1];% L/ E; \# {3 y9 i5 z
    info[2] = info[i+1][2];
    : T( n: f% t" @}9 M  C: j6 X$ H5 L" F
    num--;
    * m+ A, o5 q2 Q/ y1 \& q/ R1 A}
    , W; s' h& I2 zif(FLAG_show==0)
    , i5 G% F" C9 h/ t& ^+ J$ z7 creturn 0;
    ( _. Z0 A4 A3 i) S9 v/ h' pfor(i=0; i<num; i++)
    " T: z7 g" l' k! U  J7 `{" }& i" m* N9 T7 X9 _: {
    t = (float)info[0];7 @0 K8 U8 O# Q; r
    temp = (t/101)*90;
    4 L" Q! g6 i3 x4 F: k% l* Y9 lpos[0][0] = (10-num+i)*25+x+100;, z; x! Q" N: G" K# M4 j: k4 |; y
    pos[0][1] = y+110-(int)temp;
    : G( L- D* o/ o5 J! Ot = (float)info[1];+ Z' A# D4 a8 k% {
    temp = (t/101)*90;
    1 J& u# }2 b8 \9 D% {4 a3 Q, k. Ypos[1][0] = (10-num+i)*25+x+100;
    , ~7 _4 u6 k3 Q/ m( H" a9 \; bpos[1][1] = y+210-(int)temp;
    0 {5 f6 Q  A7 _! S4 ut = (float)info[2];3 {2 }! }: d" Z1 S8 b& g
    temp = (float)(t/101)*90;
    + K+ l9 c/ E! ^* P. E0 k! t, o! Epos[2][0] = (10-num+i)*25+x+100;
    # }. X; r4 K, g, V4 _( e) {0 c, ~pos[2][1] = y+310-(int)temp;3 S& x) D; {% F; D& i* n
    }
    / V4 l, f& q- U6 L# Xif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
    0 o) y  h9 m8 s5 f2 i{
    $ H! d- K- I2 S( G6 R+ ]; o7 R" xclearrectangle(x,y,x+400,y+315);
    : Y3 Q6 ^/ R7 N# [7 U9 Dsettextstyle(20, 10, _T("楷体"));
    ' E( ~. Q" [( d) `+ Brectangle(x,y,x+400,y+325);
    + M+ V+ V: p) K- S1 V1 R9 W" V1 f* f! couttextxy(x+40,y+10,"CPU");       //画柱状图
    ) f. A6 u5 o% e% ~! ~outtextxy(x+45,y+10+100,"IO");
    8 E4 \3 @: k' ]5 b. W0 U7 wouttextxy(x+40-15,y+10+200,"change");
    * b2 j: \) ]0 d; l3 trectangle(x+35,y+30,x+75,y+110);
    4 j+ s& R+ R8 ^/ e+ trectangle(x+35,y+130,x+75,y+210);! Y6 b+ Z3 u3 j  Y* Q" ]% P
    rectangle(x+35,y+230,x+75,y+310);! M9 C8 S/ S( v/ U
    outtextxy(x+180,y+310,"TT");
    # C- M3 U1 S' X- V" p0 e$ l) C! et = (float)com;+ V( T* W$ g2 f; N+ _6 C
    temp=(t/101)*80;
    ' `: A8 m* h5 Y4 z! ?fillrectangle(x+35,y+110-(int)temp,x+75,y+110);8 O1 f1 {  K0 ~
    t = (float)wai;
    1 @. u( e' X5 S* p2 @. t, ]temp=(t/101)*80;1 d) [' X1 L4 p* L3 P4 c
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    , A, c5 p" i  F* B7 {t = (float)cha;
    6 t( V' I8 e* D0 k/ wtemp=(t/101)*80;
    7 w( ~9 ~# N# H1 ]7 xfillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    8 J( e, X% z8 f* _for(i=0; i<3; i++)   //画坐标   high=90,length=250
    ; O1 x$ T' _6 ]) k{
    " G/ r% r  J. N+ Tline(x+100,y+110+100*i,x+350,y+110+100*i);
    2 P& t, b5 H0 f+ s# h9 i( f3 R' E4 fline(x+350,y+110+100*i,x+350-5,y+110-5+100*i);
    & U9 h3 ?1 S7 N+ zline(x+350,y+110+100*i,x+350-5,y+110+5+100*i);
      ~* E! Y* u) g3 Y+ z% S
    # u% i7 I4 L% w: L$ s. ~* z" O6 x' w0 ^line(x+100,y+110+100*i,x+100,y+20+100*i);
    $ E0 ]& R$ @2 Q! F) @line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);7 P2 N6 G. g& P+ \7 l
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
    9 k  b% q- V( k% G( j. b- }8 Lfor(j=0;j<num-1;j++)
    * \) o% Q! f6 ]! C* b{
    : G) R- T; u4 K# I2 h% F& @line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    $ f; h5 m) o7 V& b6 I  ]" _) }line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    ! O9 n5 I8 @8 T# |line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); 3 ~" n! u; y! f' g
    }
    ! g& |' S: U0 j: m. R}1 _7 t/ N9 k" M* S
    }# Z. R; `. Y! P2 Q4 i' L0 _' U6 v
    else if(FLAG_TT==1)# T0 h7 c# P2 @0 _% ?1 [
    {  s/ ]4 ~1 f% O/ y
    x=0,y=0;
    " D0 N: u" o# ~+ E1 V' C' c0 Afor(i=0; i<num; i++)" N+ m: I) J$ n! S1 P$ p* q0 B
    {9 e7 \5 l- q2 B( p+ [2 {" r, o
    t = (float)info[0];& B  i+ `4 b9 y+ ?! J% T& G3 m
    temp = (t/101)*180;
    9 J! f5 k, o9 g2 Y  |# u  S2 J8 Dpos[0][0] = (10-num+i)*50+x+650;$ E7 O  N) y: i
    pos[0][1] = y+210-(int)temp;
    4 L; P" I* W. l( I: y  w& _' ^t = (float)info[1];, r7 [& s1 [/ I: g0 W% ]
    temp = (t/101)*180;# e" B& j! T# I8 f, S
    pos[1][0] = (10-num+i)*50+x+650;
    : w& D4 [+ P% I1 m* e+ kpos[1][1] = y+420-(int)temp;3 L/ `/ F, t( L$ o* B
    t = (float)info[2];
    2 N" k% |* o! E" Ttemp = (float)(t/101)*180;
    ; G0 z/ O' }. k% N) e9 g, `, bpos[2][0] = (10-num+i)*50+x+650;
    / {% U( L0 U  b2 Y( d- U  Zpos[2][1] = y+630-(int)temp;
    $ S4 q$ O: {+ a0 C. o}8 k; Y# O$ _% Q+ ?! j
    clearrectangle(x,y,x+1200,y+650);
    " b5 O. N" J7 O& ]& \+ Q" i1 T$ Lsettextstyle(40, 20, _T("楷体"));
    . F1 w- |2 D3 j. r' s; r# ^outtextxy(x+50,y+50,"TT");
    8 V: C( t8 H( |5 `+ B2 vouttextxy(x+280,y+20,"CPU");       //画柱状图
    ) u& G5 m# y, F1 g- Zouttextxy(x+285,y+20+200,"IO");% B; Z; y7 R3 K; J
    outtextxy(x+250,y+20+400,"change");$ _% A. h+ p7 y( R+ j+ ~- f
    rectangle(x+270,y+65,x+330,y+215);9 w8 n+ l; i9 o/ d
    rectangle(x+270,y+265,x+330,y+415);
    . R0 H$ z/ o9 R6 crectangle(x+270,y+465,x+330,y+615);
    ; C) N' z, s6 O7 [! y, wouttextxy(x+290,y+620,"TT");4 j6 N/ y  c+ A: S9 J6 l/ {
    t = (float)com;
      A6 y# Z% s4 i4 u& \. I) ]3 Wtemp=(t/101)*150;
    # N+ {/ t% H0 Q# tfillrectangle(x+270,y+215-(int)temp,x+330,y+215);
    * ~$ k  K; j4 I- \/ E6 [: j( G3 L7 Bt = (float)wai;: ?# ~5 o$ M% L. ~
    temp=(t/101)*150;3 L+ T. Y% _5 ]" O2 O) c
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);2 x) x$ a( F2 a2 y7 E
    t = (float)cha;2 X- d6 W4 K- h0 `3 ]% D; t
    temp=(t/101)*150;
    , _5 w4 [; d$ Z0 @9 M; Ifillrectangle(x+270,y+615-(int)temp,x+330,y+615);  N, O$ N% m5 [. h
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
      Y3 W6 A: Y* g+ W+ _0 O/ \7 Z* l{
    " S. U4 h1 o8 a8 Z: u9 y$ oline(x+650,y+210+210*i,x+1150,y+210+210*i);- R1 ]0 U7 L0 M3 M% {1 U
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);' A6 M) C2 J5 i- B/ Q4 q" p
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);/ C, b1 q" o) n4 z; S3 N! H4 {  h2 O6 l& u

    3 v# g# Z5 H" W" ]line(x+650,y+210+210*i,x+650,y+20+210*i);
    $ [5 \. c6 n( z- }% @+ T2 F1 x) Yline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
    - A1 k7 Y1 t5 H4 o- ~line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    8 b9 y' w9 K  u, R1 h1 h' dfor(j=0;j<num-1;j++)) e/ B, \; A4 B% l) ~
    {
    ) p' E5 S& i8 W$ P7 v$ uline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);6 d' d$ R7 Y. |' x* ^2 @
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    . d1 u6 U, w: ?- }6 ^: Hline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    # v( @& H2 i0 I8 v}# t5 D1 d6 l4 b
    }
    " c& a3 H! V8 e% M& o& ~}$ W9 n/ {$ O/ [; n
    ; S8 N' M3 M* w! X9 A) \

    , @; l( z& e% Z7 O1 lreturn 0;
    / |* _! ^4 X' n2 j; X  e6 A}
    ) k: Q1 d# f' c# bint drawPerformance_PF(int x,int y,int memorry,int com,int wai,int cha)
    3 j) r4 p% ]. b) p8 d5 T6 i3 }{0 F) F5 {  l$ B4 s5 H. e
    static int info[11][3],num=0;
    / J5 ?* L1 o/ cint i=0,j=0,pos[10][3][2];
    / |8 g9 A. d/ q7 x4 K& u& Rfloat temp,t;5 ^( Q. n+ l0 Z* @9 R
    info[num][0] = com;
    / w: H7 N3 _: V% V9 ~) Ninfo[num][1] = wai;( X, e4 H/ t/ T* U
    info[num++][2] = cha;7 f  u1 e$ q- G
    if(num>10)  //存储10个点+ u8 m4 B8 u0 y, a9 E6 T) p0 w: w2 [8 ^
    {1 Y: P1 O7 [* w) ~; ^7 ]  d
    for(i=0 ;i<10;i++)5 d4 p- s. o. O1 J) B* A2 s
    {9 v' s$ u+ ^3 i9 c
    info[0] = info[i+1][0];, N. l4 }* b4 V' I* ~" D
    info[1] = info[i+1][1];
    1 `( A' p  h! ?info[2] = info[i+1][2];9 c: g6 Y, [: D% a" x5 U: \
    }
    / B2 N% P  N5 e& }num--;7 Y3 I7 p4 |- D
    }4 a/ Q* l( S% L
    if(FLAG_show==0)8 K8 Z7 I! L9 @. w( R
    return 0;
    $ X$ k$ u  [/ T2 V- Gfor(i=0; i<num; i++). u: y& O5 l: v4 j, ^# [$ U" M
    {4 u% u  S% c1 ^/ I" C1 Z
    t = (float)info[0];3 H  \* i" _9 G  F8 f) t; e! `
    temp = (t/101)*90;
    , h* L( W. f9 v# _pos[0][0] = (10-num+i)*25+x+100;
    7 \* S9 S6 `# O; a) Epos[0][1] = y+110-(int)temp;0 q$ \- w$ `( D/ ^) ?
    t = (float)info[1];9 J. E# I. o% y; l% b0 F; M; T
    temp = (t/101)*90;1 X; e. }& o1 B5 ]* {; `
    pos[1][0] = (10-num+i)*25+x+100;
    0 o2 ~9 l* P9 x) _* E& _9 z  Y3 `pos[1][1] = y+210-(int)temp;
    / ]  X& M! K  {t = (float)info[2];7 r! b# {# }9 \: T! G  Q8 G
    temp = (float)(t/101)*90;  W# l( {/ o3 U
    pos[2][0] = (10-num+i)*25+x+100;
    $ c# ^$ D0 ?% ipos[2][1] = y+310-(int)temp;% A! [( }1 ]& ]* W( D6 L
    }6 u3 t( T4 q0 Z  l+ `( _0 E  i5 a0 d
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)5 z. T7 B% t& P) z8 |
    {
    + [) @0 K: c+ n1 C* qclearrectangle(x,y,x+400,y+315);
    3 d+ p8 A, J' }' esettextstyle(20, 10, _T("楷体"));
    ! A4 i+ I2 ^+ y9 ^* O# `- Lrectangle(x,y,x+400,y+325);0 ~! n6 Q; B1 ?4 x0 Q
    outtextxy(x+40,y+10,"CPU");       //画柱状图8 c7 a% g" }) V
    outtextxy(x+45,y+10+100,"IO");$ ]  o6 r$ j5 t' D* X; H! P# j
    outtextxy(x+40-15,y+10+200,"change");
    # q, }6 M/ W. A! R: Orectangle(x+35,y+30,x+75,y+110);
    6 A& \; k  L9 H- i0 nrectangle(x+35,y+130,x+75,y+210);
    9 Y+ c. b; L5 ^" p8 c! t8 o6 _5 \rectangle(x+35,y+230,x+75,y+310);9 i7 c" P6 Z' D6 h8 _1 S
    outtextxy(x+180,y+310,"PF");
    # I; i% L; g  E1 j) r$ ?1 ?% K, ^( et = (float)com;
    0 ~% U  y  ^# m9 W" `( I! @4 T% dtemp=(t/101)*80;
    & l0 e( W8 R9 d' k1 |$ r1 x, Kfillrectangle(x+35,y+110-(int)temp,x+75,y+110);5 {) q# k$ z2 x7 _2 K; I
    t = (float)wai;' o7 V8 d4 b- r
    temp=(t/101)*80;
    . b* [+ }) X& |. \7 |% hfillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    ! P0 @- P! j" Y$ i6 N* Mt = (float)cha;
    9 R4 k- P% M+ \9 ]/ m/ J1 J% Mtemp=(t/101)*80;+ z  _# w( |4 ?7 t
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    # Z2 o+ z" ~2 [( lfor(i=0; i<3; i++)   //画坐标   high=90,length=2506 a' s; E0 s5 g5 R: u; ~$ `
    {, o  }9 v6 x5 d  T% O
    line(x+100,y+110+100*i,x+350,y+110+100*i);) ~: f6 t2 U3 F% x6 g
    line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);
    $ N/ \* e8 F3 r* G1 ~9 I6 Lline(x+350,y+110+100*i,x+350-5,y+110+5+100*i);9 f7 }  u9 ~  F( O1 ^

    ' q; a' g; ]4 U+ [4 v4 jline(x+100,y+110+100*i,x+100,y+20+100*i);
    ! Q' E& ?2 n( b  y" Aline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);+ I+ j  q- z' [0 w3 T5 O
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
    1 C$ V6 U- p% K% J) o  @for(j=0;j<num-1;j++)/ D% b) B4 O6 u$ a. ~
    {) r2 \; |/ B8 e$ x4 R' y+ j
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    * r. K; o9 i# Q0 [7 X: kline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);6 m* K0 {9 h2 U7 a* ^; Z
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    7 h8 v5 B( i! l5 P2 t6 ^1 s}/ O; p6 O7 [9 U7 S( v! z
    }
    + u% ?- \: d- y, k}
    6 z- f7 f/ y! N8 u2 gelse if(FLAG_PF==1)
    ; [( L; ?$ G1 W0 p! P) o, C{( K0 S0 a" _" j( L8 I
    x=0,y=0;
    6 H3 Q# f2 e4 a- p/ @1 mfor(i=0; i<num; i++)$ H/ r4 {% a( T' {& s% b; \. U) `
    {& O# o/ |& I2 b  z4 t$ r5 Y
    t = (float)info[0];
    ; g' T8 U, L4 t( m. r4 W6 \0 O! w9 Itemp = (t/101)*180;! F  n, r2 S6 Z: E; u) Z. F% n3 E" u8 Y) _
    pos[0][0] = (10-num+i)*50+x+650;7 I# i1 R5 N* Y
    pos[0][1] = y+210-(int)temp;
    , D6 b# D2 @* t5 a0 E1 q. `! `t = (float)info[1];
    6 u: m. M3 ]0 N/ C" t" R) xtemp = (t/101)*180;" r1 x+ ]7 y. a) ~! @; ?
    pos[1][0] = (10-num+i)*50+x+650;
    / S1 e3 A# M3 P6 c0 D4 Apos[1][1] = y+420-(int)temp;
    $ Z2 v% R/ Q) zt = (float)info[2];
    & V; O; k  X; E' \temp = (float)(t/101)*180;
    $ V4 R9 l8 ~0 A+ Z, p' W) t* Epos[2][0] = (10-num+i)*50+x+650;9 D; p  {  k+ `* ~
    pos[2][1] = y+630-(int)temp;9 `$ q: S( J; d3 y" E
    }
    ' s2 c% @: r" n0 i! M$ A+ T$ Wclearrectangle(x,y,x+1200,y+650);; N/ z) R( n4 J" S
    settextstyle(40, 20, _T("楷体"));
    ; |/ R  r; l6 H" H  youttextxy(x+50,y+50,"PF");
    " A0 o4 b; G% b* g7 C! \( h) iouttextxy(x+280,y+20,"CPU");       //画柱状图: \, }8 o* V6 L( y% i# E/ m7 ]8 w
    outtextxy(x+285,y+20+200,"IO");
    9 t9 X, q% ^; |/ ^% louttextxy(x+250,y+20+400,"change");
    " n( e) j1 l6 q/ u: H8 [+ ]( Lrectangle(x+270,y+65,x+330,y+215);: S0 s2 _; c8 c# K4 H: s
    rectangle(x+270,y+265,x+330,y+415);
    ' n; E7 ~( E! d2 K; g1 Lrectangle(x+270,y+465,x+330,y+615);) p, |. d1 w! t: w' H0 x7 ?
    outtextxy(x+290,y+620,"TT");$ K6 [. J, |" k1 i. v9 e; A4 i
    t = (float)com;# H0 X* F+ n7 B7 K/ ^
    temp=(t/101)*150;9 r& H5 P! l- d+ [& I
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);
    - E0 ^+ \, P' A! P1 ~t = (float)wai;
    ) [9 _* M/ T/ H* u  {2 B6 `+ Ytemp=(t/101)*150;( ~- I2 R' ?$ J3 B' Y9 r) u; S
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);
    ' p( a7 a1 a) y0 C+ p* O$ H( St = (float)cha;
    1 O, A' N6 Y# _" z5 Ytemp=(t/101)*150;
    ' k5 j# F; E% @0 U- nfillrectangle(x+270,y+615-(int)temp,x+330,y+615);; ~0 }; B, K8 w6 }$ g2 P
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    ) \& u8 L, n  Q% N. ~& F{
    # C+ G0 d; U# S0 n' Qline(x+650,y+210+210*i,x+1150,y+210+210*i);7 K+ q+ g  W1 }: W1 q. \
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);, W6 ^, e% v3 S
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);. ?* \9 m  U; m5 u  D
    + ?/ I3 w6 a/ ~
    line(x+650,y+210+210*i,x+650,y+20+210*i);
    & z4 r( k4 n5 a$ k+ vline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);: t5 P' A5 [7 B0 U6 z8 z
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);" L8 E$ A+ G! J) D. \, A3 e9 @
    for(j=0;j<num-1;j++)
    , B" h1 G9 `; t- E{: T, v# i9 E! r0 b+ v
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);# j3 u& e% h9 \3 [
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);$ q: ]% S; B# `9 j
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); ' }1 x9 P6 w4 t# A  ]: h
    }
    + k0 R  {; h* R: D: \! B}/ X0 @( Q" ?' ?+ F
    }
    9 v: y" Y5 O$ L% u" K' Hreturn 0;
    1 u% I) t' g: [}. l3 M% \5 E# E% Y# b- P3 a: k4 s
    int drawPerformance_SJF(int x,int y,int memorry,int com,int wai,int cha)# {4 a1 ~5 e0 E) I" d; S( f
    {. W: ], c0 U+ F5 B$ g
    static int info[11][3],num=0;9 |  B% b) N! K5 M; [
    int i=0,j=0,pos[10][3][2];+ P/ N! k, Q. a5 v
    float temp,t;
    3 s2 M; z; H+ a) [info[num][0] = com;
    # {% g6 q0 t+ cinfo[num][1] = wai;
    $ p! ?0 ^) ^. L5 d# r1 U; Z0 ?info[num++][2] = cha;, {) b6 O# a4 w
    if(num>10)  //存储10个点$ F# K$ Z8 |& Q8 n  a3 T: ?! s( R
    {  W; ]$ Q4 ^: N' a" r: V* x
    for(i=0 ;i<10;i++)
    5 M& x) m, j, ]* n; n5 t{4 E! T5 l. X4 e1 j. j- ~
    info[0] = info[i+1][0];* k% q8 V/ q9 t* \
    info[1] = info[i+1][1];
    6 K" ?" ]6 e/ x) f+ X1 Zinfo[2] = info[i+1][2];
    ' @1 d) r/ g+ D" i}; g% C/ Q& w8 z; k" U: \- L
    num--;
    5 {; u. d1 F  l9 W! O8 [4 f! E, ~- C/ R}
    : x0 Z( S( \1 k9 xif(FLAG_show==0)7 w7 N5 _# Z; L5 M" W$ {/ s
    return 0;
    7 k1 q( T, T, K  o- R! Mfor(i=0; i<num; i++)  V' I4 x$ ?6 V8 E7 |* F: d6 w2 @
    {( N, W& v- y' ~
    t = (float)info[0];) n/ K. _! y* l$ J( h1 x5 x0 W) h
    temp = (t/101)*90;
    2 ?- k/ M" g9 H2 @( s' Y  Epos[0][0] = (10-num+i)*25+x+100;8 r/ E& d8 o4 p  e5 ?
    pos[0][1] = y+110-(int)temp;
    4 x+ f7 s* \# x4 M' J% v7 lt = (float)info[1];5 t* Y7 @% F" x" W! O$ x
    temp = (t/101)*90;  Y: P5 P+ a, O, |
    pos[1][0] = (10-num+i)*25+x+100;- V( ]. L, w: p: T$ z
    pos[1][1] = y+210-(int)temp;
    " @) M$ g4 ^1 ]$ t$ h) K& l: w' K- ^t = (float)info[2];* l9 l: d9 O7 N. t- v. H
    temp = (float)(t/101)*90;
    : z2 c. h, I: Opos[2][0] = (10-num+i)*25+x+100;
    ' P7 `& [2 D& g" L, Zpos[2][1] = y+310-(int)temp;
    # J+ \7 ]( Q4 W}
    : l7 c  e) C" l2 B# H* z/ cif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)$ u: ^% d% @4 ]% E, A! \3 V  S" w: b
    {
    ' _% A$ r! m8 \: A2 I* hclearrectangle(x,y,x+400,y+315);( |# W2 z3 z6 c% [* _0 v" b
    settextstyle(20, 10, _T("楷体"));$ o# b2 N! E3 ?" H/ ]) _
    rectangle(x,y,x+400,y+325);
    8 [; a1 _7 M8 A) R0 iouttextxy(x+40,y+10,"CPU");       //画柱状图
    * {1 k5 F! O- I# R0 }- K$ Aouttextxy(x+45,y+10+100,"IO");3 d8 o; L$ ]2 L
    outtextxy(x+40-15,y+10+200,"change");3 Q8 U$ y0 i% b2 W
    rectangle(x+35,y+30,x+75,y+110);
    $ ~. N4 q4 S6 ]1 ^" a9 |( x9 l3 krectangle(x+35,y+130,x+75,y+210);
    4 ?( B* h. y! ]0 T  J$ drectangle(x+35,y+230,x+75,y+310);0 T" D* \% b- A( F
    outtextxy(x+180,y+310,"SJF");, O4 Y9 A$ s1 M: J2 T' O
    t = (float)com;# d: X+ M4 O/ v9 e: Z! \
    temp=(t/101)*80;
    . D" s6 k, K" P) c( Sfillrectangle(x+35,y+110-(int)temp,x+75,y+110);1 {( s% N" e1 ?% _
    t = (float)wai;6 I  s0 n3 g; S% y
    temp=(t/101)*80;
    8 }+ y" q2 _4 A' Kfillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    ) i2 I9 r& ]& d. Ft = (float)cha;( r% B% g* y8 G2 [9 ^4 N
    temp=(t/101)*80;
    0 C$ u& U  p( e3 E0 Dfillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    - N/ i9 F& r, b9 s6 `for(i=0; i<3; i++)   //画坐标   high=90,length=250
    0 L( c/ e. J) k+ x! r( [{
    # J1 p4 E! b- N: K8 T9 Cline(x+100,y+110+100*i,x+350,y+110+100*i);
    ' S4 A! C# h0 X& K2 r; Iline(x+350,y+110+100*i,x+350-5,y+110-5+100*i);& u& m# M/ _" C5 x! s' {: g+ d9 O
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);- d, j, H% H$ t) _" n
    ( Y  @0 Y" W4 Z8 r& W
    line(x+100,y+110+100*i,x+100,y+20+100*i);! @: h: C( ~% b5 @; h8 m
    line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);- K6 l  ^* H/ W8 j3 p: A2 |. m. c
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
    ) }7 ~- k) r  o0 m* C& G2 f9 Pfor(j=0;j<num-1;j++)
    " U9 E( p6 S; v0 W/ z{
    % [# \2 ^; y" z6 Wline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);7 B" H  N( q3 H0 k/ O: i
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);9 E4 P% b. A0 o# q# c
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); + N/ Z4 Z& Z$ q+ @5 t; ~8 \
    }
    7 `( t% |; o0 x6 d}+ E* Z* q, g4 h  V/ X
    }
    . D/ ?4 W6 H7 a0 E8 Ielse if(FLAG_SJF==1)
    " o4 z" u" P; v/ ?! i1 \3 A{
    . K$ {" O9 `, p8 m% q& y; `x=0,y=0;( w  o  n/ L, n2 Z
    for(i=0; i<num; i++)  S6 t$ _- m3 l' j# S! j
    {
    7 f4 c3 e3 y; Y5 }t = (float)info[0];
    3 g. r/ R& L6 Z+ }temp = (t/101)*180;- \1 G, {2 u- }1 @! `) r
    pos[0][0] = (10-num+i)*50+x+650;- @) E: T0 J/ N5 q' P# _- Z
    pos[0][1] = y+210-(int)temp;- S9 L1 g: y9 y/ }+ z5 g# Y
    t = (float)info[1];" A( x% D2 \+ |) M, y' y
    temp = (t/101)*180;
    + K4 L5 f0 c) r# E6 o( I& dpos[1][0] = (10-num+i)*50+x+650;
    ! `: r1 e9 v9 F0 m! K0 s) m4 h9 ?pos[1][1] = y+420-(int)temp;9 f; l0 x% s. k1 d- l' B
    t = (float)info[2];
    + G! L$ i0 e  G3 O5 p# Ytemp = (float)(t/101)*180;' _* H6 d3 ~* ]! K* l7 b5 t
    pos[2][0] = (10-num+i)*50+x+650;
    , ?8 u' t8 d2 {. Ppos[2][1] = y+630-(int)temp;" j; ]5 _* o! k2 a6 _. \. o
    }
    ! B" D3 L- g) H, v( i3 Vclearrectangle(x,y,x+1200,y+650);
    ' a3 m6 i" H% S6 M: Psettextstyle(40, 20, _T("楷体"));
    1 J) e: u0 n' X8 S$ d! w# c- Qouttextxy(x+50,y+50,"SJF");  d9 {" M) X1 p) ~* u6 N
    outtextxy(x+280,y+20,"CPU");       //画柱状图8 g+ R# E) h+ |0 t; X
    outtextxy(x+285,y+20+200,"IO");/ \7 F2 L, |2 {9 L
    outtextxy(x+250,y+20+400,"change");
    . w& y# O' u# W7 \rectangle(x+270,y+65,x+330,y+215);6 {- l' \2 U( v2 h( b$ g0 w
    rectangle(x+270,y+265,x+330,y+415);
      S, P3 b& k' O4 X  @: ~, Xrectangle(x+270,y+465,x+330,y+615);
    " E& N4 j/ L5 ]: E- P& r/ I) Nouttextxy(x+290,y+620,"TT");+ c0 A4 G/ i0 J& {9 \2 [2 Q2 U9 m) |
    t = (float)com;! q% Q: _( I6 ^' D- I/ f
    temp=(t/101)*150;
    ' Q2 w' U8 ^  Z; v3 j/ dfillrectangle(x+270,y+215-(int)temp,x+330,y+215);* d' K/ c$ |3 G5 L
    t = (float)wai;! z: t* I2 h7 [( Z* p. U% X$ H! t
    temp=(t/101)*150;7 }" P, ?' \) E$ v1 k& w$ C
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);5 a& J- l( w% F
    t = (float)cha;
    : s+ N+ M- d: M9 Mtemp=(t/101)*150;
    7 T/ v% q, K2 T. ~7 Efillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    ' ^  Z1 ^7 }; v0 B( G  R, X1 Ufor(i=0; i<3; i++)   //画坐标   high=90,length=250( H" k+ N, \/ Q  p4 w
    {" Y0 x/ c  ?6 M% [# B
    line(x+650,y+210+210*i,x+1150,y+210+210*i);
    $ S. R$ s4 I% V% ?7 ^& l8 \! lline(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    0 Q% j: u2 ^' A4 q  a+ iline(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);' _( O4 E4 n  A; Y

    " W* d3 D, }1 g) oline(x+650,y+210+210*i,x+650,y+20+210*i);
    ) o- ~3 C; r1 _9 G% X! J  Yline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
      \1 O, c+ d9 n2 Fline(x+650,y+20+210*i,x+650+10,y+20+10+210*i);8 ~& ]) B9 `2 R, _; R4 O- @
    for(j=0;j<num-1;j++)! S0 \0 x! V, i/ \5 W
    {
    8 [% B% L9 H) A* y- ]& Gline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);2 X" U9 U& K- x
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    ; l( w/ ?% e& n$ Vline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    : N, h3 C, a+ U( R2 Q}
    2 Q# b( l2 A& y6 [5 J7 ]  f}
    * Y3 `; M; m. I* ?! f1 u  `}: [9 @' U$ i6 U4 T4 X
    return 0;
    ; f, Q# Q( }! }9 ?2 ^- O) O+ o}9 E' G0 g5 b8 q( m: V
    int High_response_ratio_dispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)& Q6 b4 c/ ^; I; l/ V. o+ I2 A7 K
    {
    " ~  j" R7 u$ n1 q! I5 @5 \static int compute=0,waitio=0,change=0;
    ! d: G8 f% }9 n" ~static int computeLast=0,waitioLast=0,changeLast=0;
    $ ~/ s5 \, C9 D$ ^/ N# l2 yint i=0;
    * ~4 z4 _8 `3 N$ F+ O* @if(draw==1)! B% ~- M% Y* M3 V0 R  h% i' Y
    {
    , l; D7 Z  J% Z! ^9 I: ^//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    3 B* J7 }5 A- G, C4 ?! HdrawPerformance_HR(400,325,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    " S+ w" l9 O6 V* }; t" m) hcomputeLast=compute;4 C' V& r) G* `3 g/ p/ a
    waitioLast=waitio;0 |4 {3 v0 w: D0 d7 G& n- D
    changeLast=change;
    7 M3 @. g; j) ~" `) o}0 y  i. ?6 S. C1 M6 v+ T
    if((* memory).p[0].flag==ready)
    & c1 z. c% l$ ?. p(* memory).p[0].flag=computing;: Y- t8 W4 x& i' v$ Q- m8 f
    if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)
    + a2 w. n$ b8 P2 t" p{' A, c3 j/ R8 }  L9 a! c- P
    i=(*memory).p[0].computeNum;' {% v8 W! i& r3 i+ T2 [3 C+ N
    if(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed& I+ |# Z8 _+ g1 U, H. Y$ |8 y
    {
    9 j, a# J$ _+ E: f. ^8 [  N(*memory).p[0].flag=IO_waiting;
    # G+ S7 ]0 x8 h9 C4 c! T8 X- ]1 }' g(*memory).p[0].computeNum--;" ]( C# D5 w" w* i& ]2 H. g7 ~
    change += exchange_IO_Compute;
    4 d2 J- p- f( z6 u: x* N: wcompute++;  O" o6 R! M+ F1 Z+ h
    }
    + d3 V8 v2 B- O: Kelse1 Y! i7 T8 U+ h& K9 C4 z
    {- B7 s5 V1 b  M5 C1 I1 f% D; }, k" R: Q
    compute++;
    ' b, K: v# T4 {7 J7 A: F5 {: R! i}' L1 I& K) Y2 f: w$ l  m
    }
    . S; N+ T$ Q9 e9 G$ }else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)7 C! M# \, [/ M* l2 w
    {! |- [+ m- z, I* B& {$ l
    1 b+ ^8 ~* O2 l9 g  I
    i=(*memory).p[0].ioNum;
    ' @) ?& K) L) N& I6 q( N3 F7 ^if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed# v/ h' c* }1 Z8 l+ c. ~' j
    {4 U9 `* s& K( ~3 _7 S8 k. }
    (*memory).p[0].flag=computing;
    . [' ^. |$ I3 q. n/ e$ D- e(*memory).p[0].ioNum--;
    : ?& ~- c3 f( H5 ?7 N- T( Qchange += exchange_IO_Compute;
    ) {& ^; N- B, p. K0 y: z& ewaitio++;
    : B$ y. j' C# ^}
    7 @. p- P! b7 x: Melse# z. A* I  Z; c$ G% ^6 a
    {
    ) N" w7 w+ W( V: \+ Uwaitio++;1 j9 n0 X- Q: H# N0 B+ U. h$ s# Z: E: w
    }; C. H5 {; ?# }, X8 W
    }/ m7 B  b" K  @* H; i
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)* {5 ~; ~) l; I5 k
    {' d* ~2 |" f, t1 U2 o, A
    (* memory).p[0].flag=IO_waiting;
    7 a: ~! V/ o6 n+ I8 ]/ Hchange += exchange_IO_Compute;
    ( \" w9 z' p; l9 U; p; s}: \0 Y) {$ d2 D# s* X3 [
    else if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)
    " c4 O4 E* p9 O/ i* |/ b0 j{2 @+ |; t$ x, w2 R* w4 v% u
    (* memory).p[0].flag=computing;" e& W* L/ i2 @* w  [5 F- H# W
    change += exchange_IO_Compute;" g3 w- r) C& J' Y, u3 [& r
    }
    ( f: P7 g0 b8 Nif((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成3 ]/ r4 a5 ]& T" O. Y9 O
    {5 \$ U1 _+ R3 G1 G: Q' c
    (*save) = (PCI*)malloc(sizeof(PCI));7 u- \4 J5 f8 u3 B
    (*save)->next = NULL;
    : w0 A+ G1 n: z2 N5 p4 f(*save)->processID = (*memory).p[0].processID;
    ; p) T) U; y. W(*save)->comeingTime = (*memory).p[0].produceTime;
    & d2 e$ t: U  H5 s7 Q9 r* e(*save)->askMemory = (*memory).p[0].askMemory;- ^; Q3 r# `+ ]6 S1 n
    (*save)->compute = compute;
    , ?6 Q: e: A$ t7 w+ h$ o(*save)->waitio = waitio;
    ; v4 k# b& k0 r: `) @# v(*save)->exchange = change;
    5 O/ h( _' t$ o. l7 ^5 ^- w) x(*save)->completedTime = systemClock;
      W. h% }' ]' z  h# x3 H(*save)->runningTime = (*memory).p[0].runningTime;
    ' E$ @& g5 b. m* F, k; C# e7 m) h*spareMemory = MAX_MEMORY;         //*spareMemory + (*memory).p[0].askMemory;
    - r) k0 o% l/ T+ X- z; pcompute=waitio=change=0;6 j- x8 m- h3 K
    computeLast=waitioLast=changeLast=0;
    & v# @* G- [/ p: Y. UHigh_response_ratio_s_to_m(&(*storage),&(* memory),&(*spareMemory),1,1);
    + Y2 ~/ J5 S1 K! `3 {/ |) cchange += exchange_process;. U: g, e) s9 `, n2 ?$ n
    return task_completed;
    & e7 L0 n7 `+ q8 b" X( G}1 v; e- r, Y4 }, t
    else* W# b, L6 y3 D2 l( Z3 T
    return task_not_completed;
    % U+ t. G9 m, u% c+ J& A}% |( z( y. j' N" w
    int High_response_ratio_s_to_m(processPool *storage,processPool* memory,int *spareMemory,int flag,int dispatch)5 {! c! l+ f" s9 V. G
    {
    2 E$ M: h7 N0 v' h1 ustatic int waitTime[initProcessNum],i=0,j=0;9 i& t/ Y) r! |; r) h( r
    static double HR_ratio[initProcessNum];
    9 m% p: O- z2 b- A3 ~if(flag==0)                    //初始化数组
    ! r4 y' G8 _/ `+ `* W{
    ( [" W7 r# n. rfor(i=0; i<initProcessNum; i++)5 p2 x8 ]3 e' J! s5 w6 B. B' d" l  b
    {
    0 e7 {7 p( l3 O" n" c; L9 swaitTime=0;/ d" k) V7 s/ B* W3 G+ @
    HR_ratio=1;
    2 U. G" W- ^% p}0 O1 b6 }4 h$ _% M
    }. m$ {! Y9 v8 H
    for(i=0; i<(*storage).proNum; i++)  //等待时间增加,重置响应比
    # D# y: {8 r9 u) Q/ J0 V% x. z{* ?" v9 g3 U# }. A/ d; F
    waitTime++;) E5 L9 R. k. E; q5 r% u5 F$ P: `! W
    HR_ratio = (waitTime+(*storage).p.computeTime+(*storage).p.ioTime)/((*storage).p.computeTime+(*storage).p.ioTime);
    # v" I( J1 A9 D$ i. Iif(HR_ratio > HR_ratio[j])
    9 H' @+ p' f6 c& ej = i;8 c5 z' U: e% z
    }/ i, }) _8 N$ T. Y, w0 ]
    if(dispatch==1)                    //需要调度一个进程到内存中执行# [+ \' s: D/ V* b
    {, T( R# J) E' [7 a3 {/ f
    if((*storage).p[j].askMemory < *spareMemory)$ |' p' R8 J, M. x9 R8 J/ v0 V
    {
    ( I( C  f% V$ \(*memory).p[0].askMemory = (*storage).p[j].askMemory;
    6 V% l/ l" f" p; {: x  H(*memory).p[0].comeingTime = (*storage).p[j].comeingTime;
    ) r* p+ U- W7 K. w2 a4 H(*memory).p[0].computeNum = (*storage).p[j].computeNum;
    " {2 j1 o, p& F1 L! Q# ^  L(*memory).p[0].ioNum = (*storage).p[j].ioNum;
    1 b  _( A4 `; j(*memory).p[0].processID = (*storage).p[j].processID;! Q2 B+ c- _* |5 ^' V- s! d' O1 w
    (*memory).p[0].flag = (*storage).p[j].flag;
    9 {* v3 a) r, w% l(*memory).p[0].ioTime = (*storage).p[j].ioTime;
    + q0 G6 d* u* t+ |, T' @9 Y(*memory).p[0].computeTime = (*storage).p[j].computeTime;" E6 I8 P  F  G/ Y- O  k# i
    (*memory).p[0].runningTime = systemClock;- G8 N; o  i# O% g( d" a. P
    (*memory).p[0].produceTime = (*storage).p[j].produceTime;1 j0 a( D. O7 k" p
    for(i=0; i<(*memory).p[0].ioNum; i++)
    3 L" Z  `: f; j' U% I# J(*memory).p[0].ioClock = (*storage).p[j].ioClock;: v) G5 U; y! j
    for(i=0; i<(*memory).p[0].computeNum; i++)
    + w6 \7 Z+ q+ w7 q- f1 p$ E(*memory).p[0].computeClock = (*storage).p[j].computeClock;* I7 r5 r' E9 I/ w
    (*memory).proNum=1;$ Z3 V5 T. B" i3 b3 v
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;
    : i0 V; m/ g* k' {- O" b, Hproduce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程
    $ I8 U& @# A& q( V7 q  e( ~(*storage).p[j].produceTime = systemClock;
    # F* k# J8 K' lMAX_COMING_TIME = (*storage).p[j].comeingTime;, w# u1 v! j% p" Q' k0 U) X
    waitTime[j] = 0;
    5 `  ^! Y6 ]3 f9 GHR_ratio[j] = 1;% b- e% e2 R9 p7 ]( e9 s2 l8 Q/ n" E
    }7 D. f0 C; p& x; U
    else
    " n$ h/ I; Y7 R: ~" M- H{
    # r4 X, p9 ?6 v2 l9 G& K/ P1 k9 k, pprintf("A process ask for a memory overed the system capacity\n ");" s9 ?- k2 Y5 M
    exit(1);
    ! q2 @2 |& R' v( |6 Y4 T}
    $ S8 W$ i1 N) O; Y2 k; ~3 n4 w3 j}
    6 @/ P4 ?1 o! B: ]  S/ Sreturn 0;, W1 w6 [. @% V+ _3 c  D
    }
    + u+ ]0 |% G& s0 c% U8 R+ o- _2 Bint PriorityDispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)7 m( h% `. B7 }
    {
    $ D$ c- t8 e% O& a$ T2 l5 ~0 c/ Xstatic int compute=0,waitio=0,change=0;+ @; N" T  |5 w$ E
    static int computeLast=0,waitioLast=0,changeLast=0;9 @+ T  M9 s: ?
    int i=0;$ S5 h: ?$ y' z
    if(draw==1)
    ' x4 d( ]/ d4 M; u# H{; t0 [& i4 J; T" q* \! n
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);( r; W" [7 u* V: Z. V
    drawPerformance_PF(800,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    ! n, e) Z9 \0 h
    9 B. \. h5 @: V0 _
    ) l. ^' M. X" e% b5 ccomputeLast=compute;
    * o. ]2 Y* g1 WwaitioLast=waitio;7 }8 P& o; _# W# d
    changeLast=change;
    , t& H7 W. P) P8 Y3 D* U/ K; _}
    : r, o) j& u9 ^4 G+ lif((* memory).p[0].flag==ready)( K. c4 P: F1 e  x
    (* memory).p[0].flag=computing;7 G- j2 q( f$ v! M9 c! F4 B
    if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)
    ! Z( b' o% B3 _+ F{0 C; ~( a5 Z8 `4 l9 q+ _
    i=(*memory).p[0].computeNum;( U/ T6 w  l3 R3 p5 r8 k
    if(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed
    & T5 c* }+ d- P, u& P  F1 B  a{, P% H  d' C* p/ A0 N# Y
    (*memory).p[0].flag=IO_waiting;
    5 n8 z8 E, ^' n" w(*memory).p[0].computeNum--;7 c# M/ ]* i, k  E' e+ z
    change += exchange_IO_Compute;
    . F+ k# D! a, Xcompute++;1 u3 b3 b# {0 Q3 r8 ]+ X
    }
    2 z# I5 o$ z! ~# u; Z7 T1 ?) _% Z: celse8 Z) w: `$ E! L8 u1 b# }
    {1 M1 q4 y4 O( d- j. @2 ?
    compute++;
    9 ?0 ]' F4 g2 J2 m5 _$ X}
    ) v$ T! Y6 a# m! B9 ]}
    7 b6 z/ D# H+ @8 i% E/ xelse if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)( H' P7 n  i( j& x: h$ p7 ~
    {, P) J5 q* W+ l" R. ^
    $ Y1 j" j* }& W# h, d+ U3 q" f/ P9 U) r
    i=(*memory).p[0].ioNum;0 I2 l% \& O( ?6 [5 o5 Y6 i; U5 r
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed
    3 s' O, G% I$ L3 T{
    7 {. r" m& H- Y(*memory).p[0].flag=computing;  D, k1 r4 e3 N8 _  z
    (*memory).p[0].ioNum--;0 x; H; c  x: d7 b) X1 F4 |
    change += exchange_IO_Compute;) A) I+ |: m. d, M9 ?8 z1 S
    waitio++;0 W& |: \/ k0 _4 g7 ^- \* O$ C
    }
    ( M! T, C9 |3 r$ Y9 Yelse! ~, M( N4 z: D# u# k
    {. L  G: E2 a9 u+ A2 x0 W
    waitio++;
    ! ]* M9 S" [) O5 g, S3 d}
    ' l+ Y, c4 [# x5 [8 P  C2 X}
    6 u6 E! l# q& h! j8 E* ~( aelse if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)
    8 x* B8 o" G3 a7 A) H{' T/ }% A  O" U2 C/ j; k9 }: K
    (* memory).p[0].flag=IO_waiting;
    * `8 p7 K% p% pchange += exchange_IO_Compute;' ~* x% `+ G% ~. V& j
    }
    2 n+ U+ n1 B+ Q+ f- kelse if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)
    - ^$ m* i! n8 n0 ~# A{
    . E) ?9 p# V( s' \(* memory).p[0].flag=computing;
    1 U8 O% W& \3 I# F, ^4 j% @: [5 Q2 pchange += exchange_IO_Compute;
    + O" ^! E3 n' M$ i3 K" {}
    5 z& Q* [# z. `; G0 X' c- k% tif((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成6 _- N1 W" Q$ w, U1 n
    {' x5 y5 s( \) k8 ]/ P  r$ |
    (*save) = (PCI*)malloc(sizeof(PCI));
    ! @+ o. z5 ~% q6 k* {+ \(*save)->next = NULL;
    4 {- A& R7 s# H$ F(*save)->processID = (*memory).p[0].processID;* Q' \1 v  Z2 C- g/ A, d
    (*save)->comeingTime = (*memory).p[0].produceTime;
    ( D4 |4 y  K, H8 P' x& r5 l: l(*save)->askMemory = (*memory).p[0].askMemory;8 e  }4 Z# Z, [
    (*save)->compute = compute;5 ?6 U- a5 E( }
    (*save)->waitio = waitio;! a7 n# i! A7 C: _( p
    (*save)->exchange = change;4 h4 C( u- U  b, a3 ]
    (*save)->completedTime = systemClock;
    8 w; N2 g: R; o9 X; d(*save)->runningTime = (*memory).p[0].runningTime;
    - y* P2 Q1 F' w, K3 J*spareMemory = MAX_MEMORY;      //*spareMemory + (*memory).p[0].askMemory;* y" @1 J+ E; z! V9 @' j) L
    compute=waitio=change=0;' s$ a$ Z( g( x% R) E
    computeLast=waitioLast=changeLast=0;! R( r# [& I' k
    Priority_storage_to_memory(&(*storage),&(* memory),&(*spareMemory));! B' u$ c; ]& R' w6 o5 R
    change += exchange_process;
    ( i: V* F/ E+ Jreturn task_completed;
    0 p' u7 o- P( a- C: |9 g5 ^4 S( I}
    # t' E2 k  F) f6 p  W# velse
    / o- ^6 X4 F7 h2 U3 K: qreturn task_not_completed;4 c! K+ d& z* l/ k1 h* C# Q& P
    }
    " e8 s+ F' D" u1 x2 B: Vint Priority_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory)
    ) }- e7 h7 Z2 k/ B) v{
    . ~& K: M4 W1 @9 Lint priorityNum[initProcessNum],i=0,j=0;
    7 g/ C9 k8 i7 B0 B0 C* mdouble temp=0;$ @8 y8 x7 s( ^: h7 t
    for(i=0; i<(*storage).proNum; i++)    // setting priority to each process
    * J0 Z5 P& |  v{( E6 l$ |; p' p& d. R: R/ @: v
    temp = (*storage).p.computeTime/(*storage).p.ioTime;
    # o5 f; N5 ?& R+ e: Kif(temp > 0.8)
    8 l" D- t: X% _) z1 w8 @priorityNum = 6;
    2 {% l6 k# S" U" ?4 k2 ]else if(temp > 0.7)5 ?6 Q6 y: P5 t$ Z3 j3 ]" X" L
    priorityNum = 5;
    * `& Q* @  E; v3 uelse if(temp > 0.6)
    * f) b' M6 Z6 }' M5 c$ Y! TpriorityNum = 4;
    . Y+ @9 b, y7 V2 O' u9 helse if(temp > 0.5)
      B9 A! p7 t4 u& d* [  C3 cpriorityNum = 3;
    ! H4 {% o& U0 h. d9 H4 V& _- welse if(temp > 0.4)3 J: W& M5 l& H% z# w
    priorityNum = 2;+ }- B5 ~) v3 w7 ?) e
    else6 ]8 m' }: }7 q% a
    priorityNum = 1;% m0 X6 A3 l' c: D# d
    if(priorityNum[j] < priorityNum)1 z2 ]. \( a% g$ ~  d5 t( U
    j = i;& e  D& q$ ~  V* R& j( P+ r# [
    }
    & }- N9 s4 }' c3 xif((*storage).p[j].askMemory < *spareMemory)
    % E, y! s! ?/ i' ]{
    # y9 y5 ~; B) h$ D(*memory).p[0].askMemory = (*storage).p[j].askMemory;. L% ^7 h- x% b7 T' l4 a
    (*memory).p[0].comeingTime = (*storage).p[j].comeingTime;1 P3 S3 E. m# F. b7 |# m) X
    (*memory).p[0].computeNum = (*storage).p[j].computeNum;
    , s3 c8 f9 C6 }- S1 h(*memory).p[0].ioNum = (*storage).p[j].ioNum;
    5 c% m" _/ f4 R, K% a! o. M& k; `(*memory).p[0].processID = (*storage).p[j].processID;! K# u0 I# R1 E
    (*memory).p[0].flag = (*storage).p[j].flag;- j% N+ `0 h5 a  V0 ^& ]7 h
    (*memory).p[0].ioTime = (*storage).p[j].ioTime;
    ! a1 e0 M* b3 Q2 e/ W: j+ l(*memory).p[0].computeTime = (*storage).p[j].computeTime;" Z5 I* i/ y$ ?3 |
    (*memory).p[0].runningTime = systemClock;
    5 f, @. k3 P  M" V& r(*memory).p[0].produceTime = (*storage).p[j].produceTime;& T2 B6 V3 g7 G
    for(i=0; i<(*memory).p[0].ioNum; i++)
    ; t7 K2 [0 ~. J9 b' U8 [) H& v(*memory).p[0].ioClock = (*storage).p[j].ioClock;
    ' p; j) g' H% w5 @* \3 Mfor(i=0; i<(*memory).p[0].computeNum; i++)
    " g0 ^3 ~5 r) F  ](*memory).p[0].computeClock = (*storage).p[j].computeClock;* {0 K% u" o* a$ I
    (*memory).proNum=1;: R( |( H0 ~* ?, t3 S1 B- v
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;' m6 O% @9 [: M1 @% {, |  _' O- f2 O
    produce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程( x) e" w8 f9 y7 K# l8 x# r1 D3 W
    MAX_COMING_TIME = (*storage).p[j].comeingTime;5 u3 |8 S2 a3 S/ ^& s0 f
    }: G! \7 x/ l7 i+ d
    else& t7 j" X% Y/ b  B& B9 s1 q2 t
    {) U6 [( {+ }3 T) w
    printf("A process ask for a memory overed the system capacity\n ");
    7 ^* B. f0 e) h- V$ bexit(1);
    4 j$ x+ x0 B0 a}( {7 s& ~" t9 a# ?: k$ \8 X
    return 0;' S' y8 R% V( d) O1 G& U
    }
    + |2 w) E3 c( ~0 \5 |5 Y4 \* rint ShortJobFirst(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)- B" \: A! ~9 g% Y5 G5 U1 Z( u4 I
    {
    " |5 F. ?* V) i& ^" dstatic int compute=0,waitio=0,change=0;& ]! k3 r9 X. U9 I3 }1 d
    static int computeLast=0,waitioLast=0,changeLast=0;
    5 q, }& O4 p4 F8 e4 jint i=0;
    6 ~6 P9 |; l- i! eif(draw==1)1 `% j; h' A; n% ~  z9 A
    {, L% x. f& p0 p  S
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    ( Q3 X/ T' B9 `' H# j+ H" A! c+ {drawPerformance_SJF(0,325,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);6 _9 J# q8 t$ c( e7 W6 N  W3 f' ^4 s

    8 E4 R5 s# q4 g, E
    , F& r! a3 b/ lcomputeLast=compute;
    ! V. S* P6 I& a% CwaitioLast=waitio;5 n" a4 R4 K- E- r5 ]5 J
    changeLast=change;
    6 D9 f6 y5 x" c+ A" O9 r( @2 }' g3 H/ }}' s; e. D2 x3 }
    if((* memory).p[0].flag==ready)
    ( q4 l, h5 q, x(* memory).p[0].flag=computing;2 k' O; {6 c/ f& f5 Z
    if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)
    - Z! S1 E* H% a, }5 v, P0 q% g) s{9 [9 T9 Y; Y( w! L5 H1 u- q& J' s9 R
    i=(*memory).p[0].computeNum;' h! {: P* v; l- ?8 h
    if(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed
    ) y( g; T* \/ Z- f8 @$ L1 F{
    6 T+ G3 i* E+ L% M(*memory).p[0].flag=IO_waiting;. ?. n6 t8 o! @2 N& W! L
    (*memory).p[0].computeNum--;3 H) ?- T% }( V& q+ q
    change += exchange_IO_Compute;
    ; C; N8 w) f5 {. z, F; [compute++;) {) {; h1 ~, ?7 x
    }
    & Y" ^, X7 h/ t* @else: f9 [5 U( ?5 L$ K* N
    {$ v3 ^$ I# E" J4 }$ B
    compute++;
    & I& P  P8 `; W}( H+ G' B- V8 w# N7 l' r) X, _
    }
    ! D% K' H1 _* _; r9 Z# [else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)
    / _' C% \# c2 p! W  a{2 \: D5 Y6 A) f9 P3 j9 Z; Z
    : ~7 `9 p. {: U, E' c
    i=(*memory).p[0].ioNum;( Y, N9 p" s9 z- |1 D* M: c
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed" B3 W  c; }- \4 {
    {+ g) _2 c2 C( t0 Q5 ~
    (*memory).p[0].flag=computing;
      u7 ?, `  g% E( W/ J(*memory).p[0].ioNum--;
    0 W! t3 l/ L. I4 o# ], D" vchange += exchange_IO_Compute;
    : C) h5 Z, _, b9 ?9 w! n. _waitio++;( w9 f# s  Q0 a5 _4 F" Z
    }7 j& M9 c4 h; {# C! j0 N2 z
    else
    " z; [3 M+ {$ E, p! \( ?$ r6 O2 J5 H7 j{
    # ~: P/ n7 S8 o9 J, H$ N) |0 X* Rwaitio++;
    ! a3 y. b' |/ f$ k}9 u/ `- d5 P) g
    }: @, Q: p9 ?1 z" @. Z
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)
    ' U( Z2 r9 z3 s1 f' Y9 T' S0 `. D+ {{. N9 f( ~$ K! t  F) B8 O+ o: S% _
    (* memory).p[0].flag=IO_waiting;+ Q0 p! K1 E# u' |, }) [, G
    change += exchange_IO_Compute;5 Q& o! H* K  j" R+ B$ H
    }
    0 d9 b4 p" r( b! X2 eelse if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)8 z; p1 F" @% M( z$ i3 d
    {
    * d- J( v( x# R0 C7 i8 L(* memory).p[0].flag=computing;# F8 I6 v8 T# G
    change += exchange_IO_Compute;
    9 {' S- w9 i8 U/ b  p) J}
    / P' s3 b) ^- f. K+ _. |if((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成- v( }- d0 v3 i( {* G- d  c
    {
    5 r- H* X: m2 }(*save) = (PCI*)malloc(sizeof(PCI));& n' c- [4 S0 Q5 R( T2 P# c
    (*save)->next = NULL;
    3 l; d9 k* e# Q2 }# M) t(*save)->processID = (*memory).p[0].processID;7 m7 `. D: P) ]3 D
    (*save)->comeingTime = (*memory).p[0].produceTime;4 g- `! Z' C& s- ]( G( X
    (*save)->askMemory = (*memory).p[0].askMemory;
    # C1 u4 A% k5 g- T& c/ r(*save)->compute = compute;+ T# w6 U4 S0 Q
    (*save)->waitio = waitio;: e9 z6 s  {, E+ E& ~
    (*save)->exchange = change;
    ; W# B1 P" J% I* g: m0 M5 i8 q(*save)->completedTime = systemClock;
    1 W" N- a! J' [/ W+ W(*save)->runningTime = (*memory).p[0].runningTime;3 ]( V+ ]. u: u
    *spareMemory = MAX_MEMORY;//*spareMemory + (*memory).p[0].askMemory;
    - }# D# l" T: e. h8 _) R" Xcompute=waitio=change=0;2 l2 Y# u, F* U* ?# d
    computeLast=waitioLast=changeLast=0;1 y+ q) N4 i, y1 K" Z  ?: W) J
    SJF_storage_to_memory(&(*storage),&(* memory),&(*spareMemory));
    5 i5 P0 ]3 S; O! N$ x6 _& wchange += exchange_process;/ q) @4 q+ Q. i
    return task_completed;
    3 R  ?( K: S& i- d$ w}/ p2 L! W) ^. y" I
    else$ ~2 F& \3 ^7 t3 r/ Z, J$ I
    return task_not_completed;- L9 j, w3 ]: `; Y
    }
    2 l4 r# U! {: l3 [int SJF_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory)7 T+ a( W- |2 d" n1 z5 ~
    {- Y* g% n$ Q/ p' x
    int i=0,j=0;
    , J+ b3 d& t  o7 u8 O# Q" k& M# Hfor(i=1; i<(*storage).proNum; i++)
    7 e) r9 X0 N: d+ N{
    + R" `# F+ ?: W! Pif(((*storage).p.computeTime+(*storage).p.ioTime)<((*storage).p[j].computeTime+(*storage).p[j].ioTime))
    ! Q, t' z6 E1 vj=i;
    / v  q. v0 U, g# b+ E0 G6 ~, `' ~}  ]6 {' d# U0 S+ w9 Q, ?- y
    if((*storage).p[j].askMemory > *spareMemory)
    ! Y; z- [) n- `. k{
    , s0 h+ ]* s: ?( a  Cprintf("The memory asked is overflowed than the system memory.\n");
    4 y$ m# Z, W  F, V5 g7 Y6 Kexit(0);
    * H# Q6 E( ~6 `1 N9 q}
    4 i) Z. I, m' b8 f7 Q( ^else
    4 g0 Y% k* V, J  S1 N{
    0 i, L0 M, J6 A7 m(*memory).p[0].askMemory = (*storage).p[j].askMemory;
    6 E. j4 O  m# E4 Z(*memory).p[0].comeingTime = (*storage).p[j].comeingTime;7 ]/ u! c, [: N8 j) ~+ X' t* O" X$ f9 n
    (*memory).p[0].computeNum = (*storage).p[j].computeNum;
    ' T. `; T* h0 i; d$ n(*memory).p[0].ioNum = (*storage).p[j].ioNum;. h9 O3 h) O! i
    (*memory).p[0].processID = (*storage).p[j].processID;. c: {2 b, Z4 e* f* P
    (*memory).p[0].flag = (*storage).p[j].flag;
    8 a5 }% ^- K0 {6 [" c6 @/ n(*memory).p[0].ioTime = (*storage).p[j].ioTime;# @  Z8 o( S  y. T
    (*memory).p[0].computeTime = (*storage).p[j].computeTime;+ m) z5 r! `6 J
    (*memory).p[0].runningTime = systemClock;" Y( ~1 ]/ J  R2 l/ Y
    (*memory).p[0].produceTime = (*storage).p[j].produceTime;( K8 j" h/ K* o. h# m$ I
    for(i=0; i<(*memory).p[0].ioNum; i++)( ]! r4 C; ~% C* _( H2 Z7 a$ S* r( x
    (*memory).p[0].ioClock = (*storage).p[j].ioClock;8 Y3 C6 {# \  Z7 A8 q6 k
    for(i=0; i<(*memory).p[0].computeNum; i++)
    / @7 I2 K" s  I1 Y, q) i(*memory).p[0].computeClock = (*storage).p[j].computeClock;
    ! e+ A9 C% b' ~/ n% Q(*memory).proNum=1;2 r0 d4 r% p( B. {8 C/ ]
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;4 B; q, k, |3 Q3 G, S; i7 p
    produce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程8 `4 Q1 Y, b6 B; N" K8 u, H. A
    MAX_COMING_TIME = (*storage).p[j].comeingTime;
    6 D& |0 P% X& N2 O" ]4 M}
    ! _% v9 e! V' C. u0 {5 y8 _return 0;" j( U/ S4 t' v
    }
    2 P4 u  \# K; U1 y2 T% b4 {int TimeTurning(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)$ H: R. U# e* ?3 O4 F# v
    {% {4 P5 U5 X4 q6 ^( Q( [
    static int compute=0,waitio=0,change=0,clockSegment=100,poi=0;
    # B$ p; p1 I( w7 ?7 Xstatic int computeLast=0,waitioLast=0,changeLast=0;
    1 }9 L" P6 B, I$ H! m% e% H& ?  k, kint i=0,j=0,k=0;( t0 a5 z! {+ ]  l3 ^
    if((*memory).proNum<=0)
    " k: q$ E1 ~: m7 {. fTimeTurining_storage_to_memory(&(*storage),&(*memory),&(*spareMemory),-1);
    - _$ Y1 ?1 I' j7 G1 z4 C9 Q3 pif(draw==1)
    7 c  Q' ^' d7 s9 o2 N; U{
    8 V3 D) v$ [. Q8 f# M4 X//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    ! C% W& y& A8 c$ e- ZdrawPerformance_TT(400,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    - f3 n+ }; c0 ^% N- O) n2 R. q9 h% D9 G6 V+ ^- `: a2 r

    5 V, v# ^; j2 U  _& q/ p4 i1 m, bcomputeLast=compute;
    + f5 A' l: ^4 w0 fwaitioLast=waitio;
    1 j2 D9 W$ u/ G# F  }changeLast=change;
    % O0 K5 Z; V0 H$ `% c}
    - `1 n5 N. ?! p! yif(poi>=(* memory).proNum)
    : C" E5 b" r; l8 y1 R+ v; cpoi = 0;3 c/ _. J! E$ r
    if((* memory).p[poi].flag==ready)
    ) t3 L' {4 j) Z" C  x- D7 n: J(* memory).p[poi].flag=computing;
    : ~! Q/ c# ~$ ^. A- Hif((* memory).p[poi].computeNum>0&&(* memory).p[poi].flag==computing)
    7 D$ c9 ~1 J, L" D8 E$ V/ V6 E{
    ; p- A) g0 |4 \# Ai=(*memory).p[poi].computeNum;
    5 c$ [/ V) P. v  I2 q: mif(--((*memory).p[poi].computeClock[i-1])<=0)// one compute tase is completed) e5 y9 W: d( {
    {1 w# K- \5 {2 z0 M. k. f: ]
    (*memory).p[poi].flag=IO_waiting;
    * U4 ]* X5 a3 i# g, ^(*memory).p[poi].computeNum--;  f2 O. `3 ]# P; u& ?- ^% r
    change += exchange_IO_Compute;% u' M  r" \" _8 L
    compute++;
    7 U9 ?' ~: O+ |! K5 H1 M}
    ) c& G, ]$ b4 ?/ K! Yelse
    ; K; X4 x' \7 {% z6 a# G) h{& c/ W0 p) {- Q
    compute++;# f/ y/ Z; F$ G" U- k2 \
    }
    , f: X  U* T2 R1 z, B7 j7 |}, n, m& P4 \1 Y) m, r4 H# Q- N" S7 o3 f
    else if((* memory).p[poi].ioNum>0&&(* memory).p[poi].flag==IO_waiting)
    - S  I2 B- |2 ], S7 [0 h6 j( p{
    ) ?' m& R3 {4 |9 H7 i0 Q) u! ~  E' t/ t9 }
    i=(*memory).p[poi].ioNum;5 d; m4 _6 f# }) w/ T; n9 P7 K
    if(--((*memory).p[poi].ioClock[i-1])<=0)// one io tase is completed
      J+ T" Z  ^+ l3 W! T7 H9 F) c9 r{3 o5 I8 r' y& M, S& ^6 R5 R4 t
    (*memory).p[poi].flag=computing;
    5 {, S3 g1 k2 L, O(*memory).p[poi].ioNum--;3 \  P/ D7 ~4 O3 O
    change += exchange_IO_Compute;! }' |0 |& @% }/ }% A* g( P, }' h
    waitio++;
    ) g5 [8 }/ ]! k; f" }2 X}
    # t% X! V  J; ?; F8 o, C3 ielse
      A; Z3 N) w9 M: j{
    3 |- e& H6 t: `0 x  q( J) Z) t& Bwaitio++;. c1 j4 H7 g/ a$ g0 S% }. X
    }
    % I2 M5 e0 A4 c2 M+ v+ T+ ~& Q! B}
    " {4 _& e2 B7 |5 L; X$ p- Celse if((* memory).p[poi].ioNum>0&&(* memory).p[poi].flag==computing)+ x2 b' k( J: c0 K6 `
    {
    . K$ v- M3 b+ X3 W' C7 @(* memory).p[poi].flag=IO_waiting;; h$ s7 q9 Q) E2 z9 v" D; ?
    change += exchange_IO_Compute;0 Z6 Q( v: |% ?7 c, S  C" y6 k7 v
    }
    * L6 @! A' t$ V- gelse if((* memory).p[poi].computeNum>0&&(* memory).p[poi].flag==IO_waiting)
    . \& S( \/ h) T) K! Q& J4 V7 ^{- t5 S, ?* b" b, a
    (* memory).p[poi].flag=computing;
    " H) N9 X' k  Gchange += exchange_IO_Compute;: b7 C4 R" m+ b, z# S& e- ^
    }$ E7 y  j9 y$ s1 }* n4 O
    for(i=0; i<(*memory).proNum; i++)  //其他等待io的进程可以并行推进: W2 h2 y/ X* B& r4 `% M6 s0 n
    {6 @4 W! q" e9 j9 `, `5 Q, m' T
    if(i!=poi && (*memory).p.flag==IO_waiting)0 b/ I1 M6 P7 J7 K8 l8 [! W3 o
    {
    " U* ^- H7 s( f( B9 F# Gj=(*memory).p.ioNum;! a- z; S* p' s6 p7 r. r
    if(j>0)
    % H* v3 K  |) O, t& Z{
    9 c# q! g) ^" f# fif(--((*memory).p.computeClock[j-1])<=0)// one compute tase is completed" t+ D$ P/ j9 {+ y/ ^- i3 ?
    {; z3 p4 O4 B7 D1 H2 P5 g( R- y* C  H
    (*memory).p.flag=computing;; f% G$ X/ \. V' J# F' p* U/ W+ @
    (*memory).p.ioNum--;
    2 \2 w/ S" D: g. m& P% i3 Mchange += exchange_IO_Compute;
    5 q$ Z, i5 }0 j; `! T& v}
    # Y6 D9 a: t( g$ V! l) {2 v) W}
    ' e/ r$ I+ b0 j6 m( H}/ B8 R5 K% L8 T( X3 f
    }" W( b9 [) C& D& C! K% l! j2 ?: ?; Z7 y
    for(i=0; i<(*memory).proNum; i++)  //处理已经运行完毕的进程
    : ^/ N# t% g' ]4 J6 Z{  @  K. j( [7 q3 j6 _3 `- y0 [
    if((*memory).p.ioNum <= 0 && (*memory).p.computeNum <= 0) // a task is completed) D7 j; W5 J# R9 O: _$ e% @
    {  o/ o+ e" n6 ~# P4 |
    (*save) = (PCI*)malloc(sizeof(PCI));
    * l5 t# H+ C  S/ F! x(*save)->next = NULL;( Z' D8 g) X) E  B- [6 S
           (*save)->processID = (*memory).p.processID;1 J. w: a, Q# {% ~1 X$ k
    (*save)->comeingTime = (*memory).p.produceTime;
    . [! C9 i' H& G8 e; k) B(*save)->askMemory = (*memory).p.askMemory;. D# V6 E6 ]6 y# m
    (*save)->compute = compute;
    - E% {1 M; V/ J( J4 W6 p4 u(*save)->waitio = waitio;, ^2 y3 d& Z. u* a
    (*save)->exchange = change;
    * r: ]0 s- F, E1 }8 K9 [# b: V0 e(*save)->completedTime = systemClock-(*save)->comeingTime;
    # T8 e+ V$ w3 d9 w( ?. W( G(*save)->runningTime = (*memory).p.runningTime;4 h( Z4 f0 B4 B! X' M# ?5 g
    (*save)->completedTime = systemClock;
    ; f7 V$ M' B- s$ e. l/ R" F*spareMemory = *spareMemory + (*memory).p.askMemory;1 ?* ^8 O$ G- ^/ Y. l  q) \! J
    compute=waitio=change=0;! X; H: b# N: }( Z/ o
    computeLast=waitioLast=changeLast=0;
    9 u- M+ g2 w; O4 R0 Aif(TimeTurining_storage_to_memory(&(*storage),&(*memory),&(*spareMemory),i)==1) // 调入一个新进程进入. K: h1 ^, w( R7 q. n7 U6 F
    {
    # g* |/ d/ K1 fif(i==poi) //占用CPU的进程已经运行完,将时间片分给其他进程# m7 z: x& @& H  R/ R2 \* U
    {
    - K, a( p0 [8 N7 {$ F& npoi++;
    4 M( C5 n1 U2 Z# N   clockSegment=2000;
      G6 L" U8 r1 i/ |0 Q# x}
    8 a) q0 W: _2 I/ A6 d! w/ H7 k" i}' M) g! N  C2 g$ P: S
    else  //没有足够内存调入新进程
    8 E2 `2 \+ `6 c5 i{0 `1 y; i& ~1 H
    if(i < (*memory).proNum-1)
    ! L% {: T3 T% p! d2 q  |{/ c: r' H7 @2 z' S
    for(j=i; j+1<(*memory).proNum; j++)# W4 U' z6 m4 }1 e8 g1 z7 w& v; `
    {
    9 M4 |! g& o; }% w. O- L5 P1 o(*memory).p[j].askMemory = (*memory).p[j+1].askMemory;  ?3 y# x1 V, }# ?$ |/ ^% _
    (*memory).p[j].comeingTime = (*memory).p[j+1].comeingTime;, A% F: R- a$ R6 S' U  _& }
    (*memory).p[j].computeNum = (*memory).p[j+1].computeNum;3 b6 A2 t+ U' c4 O7 S# A5 n$ U
    (*memory).p[j].ioNum = (*memory).p[j+1].ioNum;3 j' a2 s8 Q, U0 h: K3 ^$ ?5 m
    (*memory).p[j].processID = (*memory).p[j+1].processID;
    $ |" u# w+ }0 B/ }(*memory).p[j].flag = (*memory).p[j+1].flag;
    9 A7 n3 L3 \6 }+ e* Z) j(*memory).p[j].ioTime = (*memory).p[j+1].ioTime;
    : O3 I3 ?# e9 ~8 Q" E3 Q) t0 j& l(*memory).p[j].computeTime = (*memory).p[j+1].computeTime;  K3 V$ S2 O) R- y
    (*memory).p[j].runningTime = (*memory).p[j+1].runningTime;
    ! w2 r! N& E! U/ }8 u(*memory).p[j].produceTime = (*memory).p[j+1].produceTime;% h) j4 |; h) F  E
    (*memory).p[j].completedTime = (*memory).p[j+1].completedTime;6 y- [, ]. Q3 J" ]8 U$ A
    for(k=0; k<(*memory).p[j].computeNum; k++)# V* i4 j4 Z# l  x
    (*memory).p[j].computeClock[k] = (*memory).p[j+1].computeClock[k];+ K. R# ?4 u6 i' t" B; I
    for(k=0; k<(*memory).p[j].ioNum; k++)5 z0 \* o$ C+ g( N/ \# b4 z
    (*memory).p[j].ioClock[k] = (*memory).p[j+1].ioClock[k];
    " K9 M& A" d' M6 @* v; U& r. y* N}% |# D5 U- q2 V& [9 `
    if(i<poi)
    : e) D4 p3 L& g* s: ipoi--;& X7 y% ]6 I1 j5 F
    else if(i==poi)  Q: R2 ~$ P/ D8 _
    clockSegment=2000;; y% c& L) K# d: C/ n! [
    }
    # i3 Z- s( c. c6 x) W& y3 O0 pi--;. g$ m( S# {" _! z
    (*memory).proNum--;! N6 ~7 q, d2 y
    }" i- J) l7 x$ b4 N* c9 X
    return task_completed;  M8 O! g% t& A% g; v
    }6 u7 M* Z* A4 s- i$ H& f* Q0 T
    }- |. {5 H# X, e3 E8 e. q% a
    --clockSegment;! t% S3 d# z/ V4 N) f" F/ q; t
    if(clockSegment<=0)  D7 Z: z5 @- V$ x, G9 x+ j* ^
    {8 O+ @2 _, _0 K
    poi=poi+1;, K$ \" a9 g4 ]- W8 e& E
    if(poi>=(*memory).proNum)
    9 I6 ?6 N+ {: n1 tpoi=0;( N: @- c- ], M& h$ ?4 U  V
    clockSegment=100;2 a! C" `: R6 X2 u7 G7 W
    }' _, H4 U$ G0 E5 [6 K( D% w; m) q0 Z
    return task_not_completed;; ]7 _! f% B' x
    }
      `) [+ e5 z  b4 }3 zint TimeTurining_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory,int pos)7 ^5 l  q4 Z( i" Q1 W/ I5 Q
    {6 Z- N8 \9 y7 x4 u" `9 V! n( ]6 ?
    int i=0,j=0,k=0,flag=0,translation=0;2 U- R. o9 ~/ Q2 m/ q6 s( R! _, v
    for(i=0; i<(*storage).proNum; i++)
    0 B3 A( S% r0 {{+ C$ t5 S# Y1 u% l! c: j
    if((*storage).p.comeingTime>MAX_COMING_TIME)8 G& ~) ^: e; d5 e6 _5 _7 X. {
    MAX_COMING_TIME = (*storage).p.comeingTime;
    1 H. Q( ~1 t" h; X8 G9 d}9 D9 u$ q5 i9 v8 M% r
    if(pos>=0)
    8 b! x) e: D# V  {/ \1 B{1 {7 T; V& X/ v6 V* A
    for(i=0; i<(*storage).proNum; i++)- v  x" J7 G& D# W# A
    {
    ' _) ~; Q0 U" Y+ n% n" o; G; L  s- ~if((*storage).p.askMemory <= *spareMemory)
    ) w3 ~' ~) M- N* A1 q, a3 U3 c- ~{
    ! L7 Q) u# u0 G4 U# b& q5 `  A: sj=pos;5 V0 a9 w+ }" C" f# C' Z" H
    (*memory).p[j].askMemory = (*storage).p.askMemory;* ]& {+ r- W0 `) a8 \. O- I; |$ u
    (*memory).p[j].comeingTime = (*storage).p.comeingTime;/ {* k# x1 t9 ?5 R3 ]
    (*memory).p[j].computeNum = (*storage).p.computeNum;! |8 f! w2 L4 G$ O! z% b5 j
    (*memory).p[j].ioNum = (*storage).p.ioNum;
    * B3 Q4 z, F" z) l: W) J( o6 {(*memory).p[j].processID = (*storage).p.processID;5 H2 m3 u0 O- S- \
    (*memory).p[j].flag = (*storage).p.flag;
    * v7 n6 t1 y* i- d(*memory).p[j].ioTime = (*storage).p.ioTime;: O9 d! V+ j" V9 M5 ?) S  F4 K; |
    (*memory).p[j].computeTime = (*storage).p.computeTime;
    / i6 I/ W, P; \. r0 y(*memory).p[j].runningTime = systemClock;
    . m5 H+ ~  B- ]0 \; z. S(*memory).p[j].produceTime = (*storage).p.produceTime;
    : b3 f2 _, k1 Wfor(k=0; k<(*memory).p[j].ioNum; k++)
    * s9 M( E; \5 I) p3 C(*memory).p[j].ioClock[k] = (*storage).p.ioClock[k];
    + t3 H$ N: E1 u+ Ofor(k=0; k<(*memory).p[j].computeNum; k++)
    " L- i0 f; N5 ^3 x6 I(*memory).p[j].computeClock[k] = (*storage).p.computeClock[k];
    $ D% f5 e) d$ a/ V  Q  @*spareMemory = *spareMemory - (*memory).p[j].askMemory;  D; e0 k4 ~1 @
    produce_one_task(storage,i,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程- h4 M1 G& ~& l
    MAX_COMING_TIME = (*storage).p.comeingTime;
    ; \2 Z$ i* C, _" z- l% Itranslation=1;0 X+ m7 G7 p$ A9 n2 `4 c
    break;' y& c* n3 S" M9 @8 \
    }6 S: ^+ ^4 N) g  W; h6 C
    }" h& i& n) z# |# k5 Q1 w% ]5 m
    }2 d7 X; f1 i7 L: f0 t5 z
    else0 C9 N# Z) ~: t* S6 G/ T7 O
    {
    + ^2 N* F/ _# p  R7 qwhile(1)
    3 s$ C' S; x! `0 o* @{
    4 Z8 B  ?3 P' ~. {! c+ Qflag=0;
    / y+ [, a8 j3 Pfor(i=0; i<(*storage).proNum; i++)- @' d0 T6 S! _( E  z4 I8 _/ i3 @
    {
      i0 H( @/ J8 _$ _' `if((*storage).p.askMemory <= *spareMemory)
    ' v8 m6 L5 t* s/ w4 C{: x" @+ V% Y9 @( O8 A6 `
    j=(*memory).proNum;, _* Q) e. f7 m' G  j9 h5 p
    (*memory).p[j].askMemory = (*storage).p.askMemory;6 m/ b5 Q5 V$ U6 S+ L
    (*memory).p[j].comeingTime = (*storage).p.comeingTime;
    ; i/ {7 M: L8 _& w8 \(*memory).p[j].computeNum = (*storage).p.computeNum;/ ]2 [6 l( v7 M9 c6 K: }
    (*memory).p[j].ioNum = (*storage).p.ioNum;
    % Z3 S7 o/ O4 Z. {' |2 g$ v1 m' z(*memory).p[j].processID = (*storage).p.processID;4 k$ V! \: H: {) B6 B2 ~
    (*memory).p[j].flag = (*storage).p.flag;
    * z- n) W. u! C' ](*memory).p[j].ioTime = (*storage).p.ioTime;) X! X; I1 p0 w; x" S/ i( l
    (*memory).p[j].computeTime = (*storage).p.computeTime;
    1 \% k2 \- E# q& |(*memory).p[j].runningTime = systemClock;
    * m4 R3 C; v! N& R( Y7 |(*memory).p[j].produceTime = (*storage).p.produceTime;
    ; ~/ p% V9 @$ P  T1 w& _1 K2 Jfor(k=0; k<(*memory).p[j].ioNum; k++)( ~& W3 \5 e: U5 F' `! d8 }
    (*memory).p[j].ioClock[k] = (*storage).p.ioClock[k];( \) H( f# o  g5 |! m
    for(k=0; k<(*memory).p[j].computeNum; k++)
    5 V, p% S5 ]  C# i8 E' W0 S(*memory).p[j].computeClock[k] = (*storage).p.computeClock[k];3 W( _6 D) B' r4 V; @- b
    (*memory).proNum++;
    ( \4 |+ b$ s. @1 _' W*spareMemory = *spareMemory - (*memory).p[j].askMemory;" I6 ]6 p+ \) K1 E2 H
    produce_one_task(&(*storage),i,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程! @' r6 L8 D4 ^
    MAX_COMING_TIME = (*storage).p.comeingTime;
    & q+ q; _4 N% V! ?4 I% Eflag=1;
    : r) ^* B2 Z4 D, {* V3 z) Xtranslation=1;
    4 g9 r8 \' a. ?4 ~8 E}
    ( Y' H6 ?! H5 G& [, w}
    , l- t4 v  T  L. o" cif(flag == 0)6 q6 d  d) r1 Y0 F" o
    break;
    % A& {- |5 {; \+ G4 N, p}  z. [. r6 h$ Y! u4 E/ c
    }
    3 Y, ~/ y. U5 a5 N) z% K5 U5 ?2 ^return translation;
    + [: f* P2 F  g& H7 d}$ Q# {' o3 r7 F) c- x% S
    int FIFO(processPool *storage,processPool* memory,int * spareMemory,PCI ** save,int draw)
    ' {' d& u5 D  L+ S1 A{
    # [5 d2 A) ]: t0 T) x' a& Mstatic int compute=0,waitio=0,change=0,flag=0,flagiocpt=0;
    ! Y: P1 i% o0 A$ Ostatic int computeLast=0,waitioLast=0,changeLast=0;
    ) n! {  E) p5 j7 Kint i=0;% o6 c4 Z8 l$ Y  p# m: i% S! O6 k4 `1 X. Q
    if(draw==1)
    + V- ?, F7 L# D6 q: \( n{
    8 d6 V  C! t3 a+ a' ~//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    , }; h. o' N& h1 |drawPerformance_FIFO(0,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    + a! @. K( i: Q$ V: b. }- \3 b" q9 g1 [( f

    5 e) G- b5 _- _. j2 YcomputeLast=compute;, R& c( L) U) Q5 W
    waitioLast=waitio;
    1 q+ ?4 t1 n3 ^6 echangeLast=change;
    ( K$ O2 R. a, Q4 a( ]! W7 D# Z  U. x}! V1 {* p( b# p  l: O$ g6 F
    if(flag==1)  ! {: r2 W9 r* i: [0 g
    {
    * U0 l1 i) Y) ~; x  l( e. nif((*memory).p[0].ioNum>0||(*memory).p[0].computeNum>0)  //task is not completed; W( Y2 P3 d8 b* d2 h8 @* F
    {: J) ]/ `" n: a+ ~& v( }
    if(flagiocpt==0)   // implement compute
    + Y3 Z: m! Y; y( A* K! a{! h4 ?& l/ M" F( z2 S
    i=(*memory).p[0].computeNum;
    3 s* s+ P% D: y* v5 a( F0 Sif(i>0 && (*memory).p[0].computeClock[i-1]>0)& ~  b9 r& ~1 w$ E% t6 Y
    {
    2 i: o  z! k3 [: D. h! K! b! z8 [if(--((*memory).p[0].computeClock[i-1])<=0)// ome compute tase is completed
    ) F. w$ l' H( Q" K; _( k; J{& g0 i( v- U* s3 j
    flagiocpt = 1;, S( [9 z9 h, x) Z/ d+ Y0 f
    (*memory).p[0].computeNum--;
    & r* P% M# A2 i) P" R. tchange += exchange_IO_Compute;
    + L# p; B9 K! q! Gcompute++;2 ]6 S! w8 z& t+ v; S8 i* d& O
    }
      W. Y3 A1 B. g& L2 s' f) _/ Belse
    & J- j2 g: Z3 ocompute++;
    1 c+ M: D2 \( W6 x8 ^1 @# I7 j% i+ M: @! Z: m* s* G' ]
    }' M8 z8 B! E1 R7 j6 n
    else
    - ~9 d( n1 ~( Pflagiocpt = 1;$ o+ {( Q+ m1 b: b, H1 K8 B
    }
    8 ]6 g! ~6 W0 delse  //wait io: n$ c( w9 K4 t( G* H6 n* v
    {
    , V: a) [+ G. `( [7 Zi=(*memory).p[0].ioNum;1 o( t5 C- N" |! s
    if(i>0 && (*memory).p[0].ioClock[i-1]>0)0 ^5 z9 W5 A( k2 |+ {
    {3 S! V8 z8 f4 ~. A& ?$ U
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed* {  \7 H8 @# [4 [! D: s- p
    {
    9 l4 G# D6 R+ b$ R+ R. [' E" zflagiocpt = 0;
    . a  o1 R! }) R* W( y! w(*memory).p[0].ioNum--;
      ?+ Y0 ~7 o* @* @7 \& Qchange += exchange_IO_Compute;
    " l6 m$ M' K2 z, o* t  lwaitio++;
    & V! I: ~+ _4 B0 y/ f, b! G}" m7 R2 }% u/ Z; V0 g
    else
    7 f0 `* Q  A* g& T" p+ y9 c" }waitio++;
    ( k* H1 L" L0 j% s$ L
    7 P; p+ V, L  `7 ]: w}
    2 u3 u) T4 g7 m; r' p9 H6 Zelse; w. F+ T) [! R) ]6 H8 f! E7 `4 O( l: Z
    flagiocpt = 0;) w# p. `6 @9 n- U' W8 o9 D
    }: ]3 A  C/ X4 T
    }
    ' s# J$ D2 E& L( v( _$ r! `$ selse  //task is completed
    ( U9 J, M1 d- x7 o& \/ s{, Q* B0 o) _3 ]: G% b! I
    (*save) = (PCI*)malloc(sizeof(PCI));
    * h) c6 L% J' p+ y; m( r2 u(*save)->next = NULL;
    ; O" z% ^! o( N- ^; W# n( x6 E       (*save)->processID = (*memory).p[0].processID;; u3 o/ y7 ?) p/ R; G+ ]* T& G: P
    (*save)->comeingTime = (*memory).p[0].produceTime;
    + _8 E; u+ [. b6 p  m" d  a3 K(*save)->askMemory = (*memory).p[0].askMemory;( s$ Q" T  h5 o+ s( k) o
    (*save)->compute = compute;( C3 H7 o  \. p# M9 K# q  ]4 T
    (*save)->waitio = waitio;4 x, k1 U- Y9 q/ K2 U! Y4 W' N
    (*save)->exchange = change;
    - _# |+ ]. @" T1 x. T(*save)->completedTime = systemClock-(*save)->comeingTime;- P* J  Z2 H. l0 V. J
    (*save)->runningTime = (*memory).p[0].runningTime;3 Y" ?: j" z( O2 G  o2 U
    (*save)->completedTime = systemClock;
      W, l; w$ y$ f2 S4 i//*spareMemory = MAX_MEMORY;
    2 ]4 r1 ~4 f, Z3 E, Z) M) Nfree((*memory).p[0].ioClock);4 B! y4 g/ s- H0 s3 Q
    free((*memory).p[0].computeClock);  [: N( B8 w, o
    free((*memory).p);6 \  g# v1 f9 l
    flag=0;
    ) C* j6 p% @/ p! l! H' o4 \, |  ]compute=waitio=change=0;
    0 l) e/ L0 K. H: YcomputeLast=waitioLast=changeLast=0;& H8 v  e# V* ~- c
    return task_completed;
    # @5 K  J$ T  W) v}
    / Y" M/ a4 j: S; h/ w0 r}
    4 s' \6 L* E3 `+ O3 \3 B# q) `else         8 ^! ]) F% F$ H6 K1 ?! b% l
    {
    3 t9 E: {$ u* F' }5 OFIFO_storage_to_memory(&(*storage),&(*memory),&(*spareMemory));  D6 N% ^' b8 w) e5 Y
    change += exchange_process;
    4 R+ \  L& I" j% B. n//*spareMemory -= (*memory).p[0].askMemory;
    : E6 W. g8 j- N9 }; N" ?flag=1;
    2 c0 ?6 D, X' \8 r1 Q+ Z/ L8 g//showProcessInf(*memory);
    - D: t' A: m% i2 u- V* q5 r# lreturn task_not_completed;
    " R5 h% a- O# P/ x' x  L/ k}
    ) U% J; p, I3 A/ b; ^8 [return task_not_completed;' S% B* M$ p. t& k! F- Q" q
    }
    & v1 @. ?; \8 z: ~& ~int FIFO_storage_to_memory(processPool *storage,processPool* memory,int * spareMemory)
    2 H0 W0 g# P1 a! p* L5 T3 y{
    , K* q9 m3 a* M7 r) Kint i=0,j=0,k=0;" Q7 V9 q# t' ^, y5 s, C( a
    MAX_COMING_TIME = (*storage).p[initProcessNum-1].comeingTime;4 ?- S' j& C7 u1 l7 z* \1 i
    (*memory).p = (process*)malloc(initProcessNum*sizeof(process));
    " \/ Q! v  v8 x6 i4 pmemory->proNum = 1;
    5 y4 I# P# V9 n5 ^for(i=0; i<initProcessNum; i++)& v* ?/ ^# v; A6 z. ~5 s! p9 C5 f
    {5 m1 m" B. w% F% f' @4 n0 O
    if((*storage).p.askMemory <= *spareMemory)
    $ j* t+ Y- v9 u{1 k0 D) D' P' `6 A* Q
    (*memory).p[0].askMemory = (*storage).p.askMemory;5 ~0 n8 r5 a, j+ l6 _9 m
    (*memory).p[0].comeingTime = (*storage).p.comeingTime;
    ! \, O* n! N. h0 X(*memory).p[0].computeNum = (*storage).p.computeNum;
    / }7 T2 ?3 a& q  r0 o(*memory).p[0].ioNum = (*storage).p.ioNum;- U' @) q% V  H5 O- C
    (*memory).p[0].processID = (*storage).p.processID;
    ) e/ N" H8 K" S% N6 \0 ~(*memory).p[0].flag = (*storage).p.flag;
    # N. d  q& q5 ^& F0 V1 ~& F* E' `(*memory).p[0].ioTime = (*storage).p.ioTime;
    4 ?: |; |& n. W- v(*memory).p[0].computeTime = (*storage).p.computeTime;% O1 n* a& d( i# ~, V; w
    (*memory).p[0].produceTime = (*storage).p.produceTime;  K7 B" i. U" u' D  d: e7 b8 p5 u
    (*memory).p[0].runningTime = systemClock;5 Y) I7 Y1 q" @8 r! s
    (*memory).p[0].computeClock = (int*)malloc((*memory).p[0].computeNum*sizeof(int));& ^3 l$ ]+ n4 x; d
    (*memory).p[0].ioClock = (int*)malloc((*memory).p[0].ioNum*sizeof(int));0 q6 X3 q* t3 _. [8 `' i# o/ P! ~
    for(k=0; k<(*memory).p[0].ioNum; k++)
    + O; ^" r. A% f7 ~(*memory).p[0].ioClock[k] = (*storage).p.ioClock[k];1 \% `8 m+ @. E3 e. W! ?% g$ w7 F  L; E
    for(k=0; k<(*memory).p[0].computeNum; k++)
    4 e* Y4 `, I  O; x" {# P6 O(*memory).p[0].computeClock[k] = (*storage).p.computeClock[k];
    ) D$ B) q* ?1 z) w6 Y) fbreak;
    5 `$ K. T7 g% `8 d4 t1 q) W0 {}, y" Y6 i" v  y- J- o4 S9 s
    }
    ! p; h0 x5 V9 B8 m/ B* c4 Lif(i<initProcessNum)  //调用一个作业进入内存后,并再生成一个作业等待调入* z9 u8 J- W! ]" O
    {
    + F% R& F1 }. ?( C6 N  `- A, c& Vproduce_one_task(storage,i,ID_FIFO++);) W3 F9 I+ J7 [/ @; N" K
    MAX_COMING_TIME = (*storage).p.comeingTime;
    : f- _1 u7 V) ~sort_by_comingtime(storage,i);( x2 n' u: k2 |8 u4 N& v
    }/ D( k& ]6 C" a% b  o8 T
    return 0;
    - s; H: B$ N2 x+ V/ j  [}# j1 K- `0 m) P' H
    int sort_by_comingtime(processPool * p,int pos)
    " B* Q" [2 H- a, {  u9 G{% x3 N% P1 I* y: f' K! |2 j
    int i=0,j=0;  G& n: x2 T5 }* i) S# Y' N0 y. g7 w
    process temp;6 N( D( O0 y$ O0 p8 S
    if(pos<0)
    ; e  @' ]; f4 }9 F( V6 k% Y{; _9 ?) l% @/ @% r/ u
    for(i=0; i<initProcessNum; i++)
    + X8 E  F8 z5 V" E1 ufor(j=0; j+1<initProcessNum-i; j++)
    4 r: {; `8 ?% c{( j) H" p4 q, P$ n* @
    if((*p).p[j].comeingTime>(*p).p[j+1].comeingTime)
    + V0 O& B6 D) ?5 n2 Q& S( ?{7 `3 U+ @& S) J% `  ]" d
    temp = (*p).p[j];, `1 L9 i" \3 @9 m( c% I) ^$ f
    (*p).p[j] = (*p).p[j+1];% j' D6 D& v) a4 e. O; V
    (*p).p[j+1] = temp;
    / S! H% F2 @1 W$ d7 V' C( N}
    9 ?! V4 k$ R0 @8 }}
    + j  n* Z) y/ W6 t, v) Y}. }3 m3 P5 G: t8 q8 W
    else if(pos<initProcessNum)
    ! N. @8 @4 W9 d* G  [2 M{
    / Y$ v' V: o5 m' k/ U; afor(i=pos-1; i>=0 && (*p).p.comeingTime > (*p).p[i+1].comeingTime; i--)) M# e$ b* p5 Z' g! e. p8 Q) C$ r' M
    {) ~1 ^6 P, X0 [9 B2 J
    temp = (*p).p;6 ]; U' i; l" k5 z0 i4 T
    (*p).p = (*p).p[i+1];
    / a" o3 k  G/ w) W$ Z! L$ F" d# |! h(*p).p[i+1] = temp;
    $ W+ l! [  R- \5 n* p* g  q& S}9 [) |7 K2 }* s) `% c) D
    for(i=pos+1; i<initProcessNum && (*p).p[i-1].comeingTime > (*p).p.comeingTime; i++)1 O. o, S" \- j
    {
    * p; Z6 O* ]: ?% |: Htemp = (*p).p[i-1];9 Y; Y; J3 W! N4 y8 p1 |
    (*p).p[i-1] = (*p).p;
    ) I" Y  E, K- ?3 l! m' C(*p).p = temp;. B, N. Y: R0 a. J' Z4 f
    }
    + \) ?4 L2 |9 R1 d# A$ r- o}; D# i; i0 p9 F$ I
    else
    7 ]' ^; m) M0 s( yprintf("position eror\n");0 N" H% B" B/ g2 z# q
    return 0;- f, V9 _* @+ Q! g/ n8 b
    }
    4 d# l& n4 o* |" ?6 Sint InitPool(processPool * p)
    5 a, I( [% L4 b. T5 K{
    5 s6 X* y1 D: e) W" `0 a! Mint i=0;9 j+ P* C- m: x  P+ Z
    (*p).proNum = initProcessNum;
    % O  Z3 C+ u6 J3 d% E7 a+ [8 B. `(*p).p = (process*)malloc(initProcessNum*sizeof(process));2 J% Y% w3 _8 d9 z2 A3 J3 h. y% G
    for(i=0; i<initProcessNum; i++)                                        //init process information, D9 D) ^9 M! _/ K3 n  U
    {% f% D! J7 [" e) K1 P: ?- M" h! J8 C
    (*p).p.computeClock = (int*)malloc(initclocknum*sizeof(int));
    , V+ V0 u# L; Q) z1 r5 y1 t, W(*p).p.ioClock = (int*)malloc(initclocknum*sizeof(int));
    2 H( w# m% O  _produce_one_task(&(*p),i,ID_FIFO++);
    4 A- X3 W3 E$ S! L, m& A% C}
    1 Y$ x1 E% P# Vreturn 0;
    $ Y& b$ J& V, w8 B& s: ^$ I7 Z$ @}* D' d" y( a! |4 E3 W4 M
    int produce_one_task(processPool * p,int i,int id): D& r' c8 x! `& ], N" B
    {
    5 P$ J1 R  B3 p- Mint time=MAX_COMING_TIME,j=0,totallTime=0;
    ) [0 f0 L8 v5 D. D# O(*p).p.processID = initProcessID+id;           
    9 @+ o4 ^5 e, M6 {  F(*p).p.comeingTime = time+rand()%(MAXProcessRunTime/5);0 t) r0 E: v" Z3 N) m$ t
    (*p).p.produceTime = systemClock;
    : z; T0 }; ]8 m) [* B- B" x(*p).p.ioNum = rand()%4+20;                                        //IO number setting to 2--5;
    + R; a$ \; L( h2 E' Z: c( x* ^/ l(*p).p.computeNum = rand()%4+30;                                   //computNum setting to 3--6;# F7 f" l! \$ w: T1 j) I9 c
    totallTime = (*p).p.computeNum  + (*p).p.ioNum;
    4 w4 o3 O; W6 s( |( H( Y! \(*p).p.computeTime=0;2 T: p5 {" m5 [, F( L- m2 s% B
    for(j=0; j<(*p).p.computeNum; j++)
    ) T5 @# }; Y8 T* D1 f8 {{
    - D" n9 @+ W+ Y(*p).p.computeClock[j]=rand()%(MAXProcessRunTime/totallTime)+1;
    & s' D# w! h4 S3 O" s(*p).p.computeTime += (*p).p.computeClock[j];
    ( {# n6 e7 M7 j. E4 f}
    9 f: `1 u8 z  K1 }(*p).p.ioTime=0;+ \) k0 S$ ~6 d
    for(j=0; j<(*p).p.ioNum; j++)
    : o+ N. w$ E- E& S' N4 m{' R0 L3 |6 f+ h- p
    (*p).p.ioClock[j]=rand()%(MAXProcessRunTime/totallTime)+1;
    # ]1 @. Y, g0 O5 N: e2 s(*p).p.ioTime += (*p).p.ioClock[j];3 z& Y! ^, @: [1 S6 d% M
    }! x3 y" b7 A- z5 b
    (*p).p.askMemory = rand()%(MAX_MEMORY/4);, h. l; T" {4 y* |
    (*p).p.flag = ready;1 n% f6 R, B- ^" C# s- @
    return 0;
    ; I3 v, T& e0 j0 d/ p3 [. q}8 ]  S1 ?  c! S% l9 R. k
    int showProcessInf(processPool p)
    : c- B, O3 J: @& u/ d{2 c, l0 Q6 K% c& O  N3 r6 N- h
    int i=0,j=0;; l, K: z$ I7 H; p+ h' q0 W
    for(i=0;i<p.proNum;i++): o/ c4 G0 P- x5 p+ }
    {
    0 ^) u7 q0 P- K$ m1 A- \: f+ xprintf("ID:%d,%d,%d,%d,%d,%d,%d\n",p.p.processID,p.p.comeingTime,p.p.ioNum,p.p.computeNum,p.p.ioTime,p.p.computeTime* r1 q. M/ w% g0 W' L" _( n
    ,p.p.askMemory);
    4 e) M; v! U$ i) }7 f1 lfor(j=0;j<p.p.ioNum;j++)
    " s( a& h) w! V8 U+ f" x# j{8 Y1 j7 h" Z& Y  J! t! _5 Z% b5 L
    printf("%d ",p.p.ioClock[j]);
    1 X; C4 i6 o% k! |# ?# J}
    3 d9 d8 `5 R. v: dprintf("\n");; B3 g6 x! m, h- W  o- z
    for( j=0;j<p.p.computeNum;j++)
    ! {. B; O" e8 Z. M6 S+ `: w, M1 h{* E  S4 ?" d, j" N( s7 L
    printf("%d ",p.p.computeClock[j]);
    + `' l3 B0 L3 O0 y" t}" s. D3 R" ~. u: T% h- q) P
    printf("\n");
    / P  Y; _6 [0 J5 {, Y9 S}2 t2 z! v0 {3 K1 F. o, U: W) l
    return 0;
    . v3 ~/ X1 }  P6 M# x2 Q! {$ k1 s5 \}
    " i. U3 @( z  d# O' V( Y  U————————————————5 `$ Q, D( G; O$ _. P6 Y
    版权声明:本文为CSDN博主「wang_dong001」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    ' y9 b( \) i$ L. a; l原文链接:https://blog.csdn.net/wang_dong001/article/details/47843519
    : n  {" }2 O2 N5 i
    ( T( G4 G9 S  U  _( I' S
    ' u" {% G$ M0 l* v& s; Z
    zan
    转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
    您需要登录后才可以回帖 登录 | 注册地址

    qq
    收缩
    • 电话咨询

    • 04714969085
    fastpost

    关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

    手机版|Archiver| |繁體中文 手机客户端  

    蒙公网安备 15010502000194号

    Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

    GMT+8, 2025-5-16 11:50 , Processed in 0.409529 second(s), 51 queries .

    回顶部