QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2288|回复: 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
    + P( ]; T8 P/ n0 n! n, B
    经典任务调度算法的模拟程序
    3 E# f$ A7 l8 r! ?本科毕业设计写了一个经典任务调度算法的模拟仿真程序,测试了五种调度算法的运行性能。在程序中虚拟了任务的进程,按照不同调度算法策略从进程池中选取任务执行,在任务执行过程中,保存相关的统计参数,最后对这些参数进行处理,反映各个调度算法的实际运行性能,程序中可以通过修改任务的相关参数改变任务特点,测试不同任务环境情况下,调度算法的性能适应性。程序是通过C语言编写的,为了对运行结果图像化,采用了EasyX的图形库。由于计算机中实的任务调度过程比较复杂,在实验中为了简化程序的实现,在某些方面进行了特殊处理。
    8 k: H' Y7 D4 {: ~+ L3 H/ Y  j. N" p: e! D0 p! A2 ^& ?
    编程平台:VC6.0+EasyX图形库环境。* j' X' g. ]' D8 k! A' ]
    ' S% x6 O7 O$ }) w9 C5 }. d# q
    以下截取部分程序运行图::5 o* a+ W7 P7 F. W, b8 E* @
    8 I/ O! p4 w) W% }0 z
    源代码:. u' u- \1 ~' M" j6 F+ q! b) \! i

    , g2 @* {3 v3 L' l#include<stdio.h>& r! x# W0 ?2 k
    #include<stdlib.h>- M5 n" T# |! J
    #include<easyx.h>5 D( e8 O: r2 [
    #include<time.h>4 y6 ~& ^5 Y$ J  ^  F  Q
    #include<conio.h>
    & @1 W& i: T6 e) t3 ^* x5 q$ m#include<graphics.h>
    ! d( @! i) B, {$ }$ ^#define initProcessNum 103 M; o7 B: l  l5 a
    #define initProcessID 1000
    3 x9 N2 Y2 `1 ?$ B) y0 \#define MAXProcessRunTime 10000) @" q# _3 n/ z
    #define MAX_MEMORY  40001 s4 ]9 P1 H( e* b5 }& g+ B
    #define exchange_IO_Compute 10; @/ i1 w8 x2 r! ?/ {! T/ @
    #define exchange_process 25, M7 Z) Y. w. g
    #define task_completed 1: R9 J9 ?. T1 o6 q  M" w2 l
    #define task_not_completed 0$ N" T1 N  o: Q( H0 K: Z
    #define initclocknum 100
    & d6 u7 c9 @$ w* B1 n) y7 W( lenum condition& T- z' N; S. Z
    {) ~' B+ J* f3 l& O' W
    dead,computing,IO_waiting,ready
    , }$ t% Q& Z5 Z; R% ^. O! u};# e3 @0 x# z1 {) I' w
    struct process# q0 y; b. e" m4 u$ h$ W1 [8 `
    {
    4 f6 O5 h; j' k# D! ]4 v9 x! z; Uint processID;; q$ H- H/ ~( X" w+ ?: p& D9 o1 M
    int comeingTime;
    0 @' ^# W, n4 m2 S6 bint ioNum;
    $ O3 a5 f% _6 }" o$ y0 {; Yint computeNum;. n" K, S1 k: _
    int * ioClock;
    # e' t0 d$ }+ }int * computeClock;7 e5 x0 @1 A8 h8 v, C, m
    int ioTime;
    8 I3 ^  w( S' ^int computeTime;
    / k, D) m( R7 r8 Z. ?0 g7 @int askMemory;3 J; u1 D* o, H% D% f+ S
    condition flag;2 T- i5 s9 Z" H, x) H
    int produceTime;  //生成时间,以下三个数据成员用以计算相关性能4 d% T( ^5 `$ K' l9 I' @
    int runningTime;  //第一次占用CPU的时间
    : z0 X+ ]' s" sint completedTime; //进程完成时的时间
    4 @& a4 n8 Q8 Y; t5 w* ~( E4 m};( S# l9 W6 F) k0 e' q
    typedef struct processCmpletedInfo  //保存完成一个作业的相关信息
    , {0 l3 ~1 R# N7 G* r0 h{" @+ k9 S. v: i; \! x9 o# z
    int processID,comeingTime,askMemory;
    ' Q' _0 k. N; ^, _( z+ `int compute,waitio,exchange,completedTime,runningTime;1 X! M% a; m7 e, `! V1 s1 N, H
    processCmpletedInfo * next;! ^: \0 P6 y! m
    }PCI;1 O2 n8 c7 q- G
    struct processPool
    . I6 }% d5 P& \. o5 ^{5 x8 i, ]) L8 O! @* r' F
    process * p;2 ^) y5 E" p/ M& ~
    int proNum;) y' ?8 _7 a+ d2 Y: F: s
    };" ~" A8 {0 |( s" O& l
    int 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;' M- R: Z5 J: ~. _2 L
    int InitPool(processPool * p);
    / ^$ M$ n8 C5 O) Sint produce_one_task(processPool * p,int i,int id);
    " I. j! M4 n5 c/ h+ C5 dint FIFO(processPool *storage,processPool* memory,int * spareMemory,PCI ** save,int draw);
    . T! ]( L; y# R8 @7 @$ U+ l# P& M+ \int TimeTurning(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);2 s( L4 a, ?4 A& T
    int TimeTurining_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory,int pos);- f( L0 K- w8 d5 i
    int FIFO_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);( L6 E1 p: D4 u' d
    int ShortJobFirst(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    3 _  g2 N) r* m; s$ I/ T) m2 u* r9 Gint SJF_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);/ v  v2 m( w7 Y( \$ N
    int PriorityDispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    & U2 \0 j9 D) G1 f: A, y) iint Priority_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);3 o7 d0 d1 m8 B7 z. Q; t
    int High_response_ratio_s_to_m(processPool *storage,processPool* memory,int *spareMemory,int flag,int disatch);, E8 @; d* G$ w- j
    int High_response_ratio_dispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);) \! @; _2 g0 E( z" a
    1 L! U* I  @9 F% x4 j! m$ Z
    & t' {0 O, t# E  U9 ~) b
    int sort_by_comingtime(processPool * p,int pos);+ `# F$ P$ F$ X5 d; k9 C
    int showProcessInf(processPool p);3 F/ p6 D. e' O, H1 }4 k& y8 W
    int drawPerformance_FIFO(int x,int y,int memorry);2 L  l6 V5 C7 u2 F" V8 z2 n; P8 z
    int drawPerformance_HR(int x,int y,int memorry);
    % Y' r6 O. L" Q! Sint drawPerformance_PF(int x,int y,int memorry);  o) l1 ^% o7 V1 d7 c8 ]
    int drawPerformance_TT(int x,int y,int memorry);+ |) y) e3 a8 B( j1 h3 K
    int drawPerformance_SJF(int x,int y,int memorry);
    . C9 g) Z! I( P# fint MouseListening();
    ' K1 [, W2 c3 D0 d: dint MouseListening2(int *flagShow,int * showTime);
    $ K: w! c0 A( ?! ^# o$ r# Aint showRunningResult(PCI* FIFO,PCI * timet,PCI * SJF,PCI* PR,PCI* HR);
    / j; j/ b5 I7 q- Z4 d/ Q; ^3 v! L
    5 ?, M6 {: N& @* y* B  f1 q" N, C3 \/ ^, |' r( F, o* M; U" m
    void main()  A) ^) T: Q; D; a; A
    {) J9 E1 r( u6 \  _: b  O7 _
    PCI* FIFO_save_head=NULL,** FIFO_pri=NULL,* Timet_save_head=NULL,** Timet_pri=NULL,* SJF_save_head=NULL,** SJF_pri=NULL,
    4 R1 P; D8 S) f+ {; T" B/ `*Priority_save_head=NULL,** Priority_pri=NULL,*HR_save_head=NULL,** HR_pri=NULL,* p;
    7 m) q6 x6 v9 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,# u7 Z& Q+ y/ l% H( x* S3 u
    flagDraw=0,showTime=100000;
    / u3 F( h# X5 W& l5 V" aprocessPool FIFO_p, FIFO_mmy,Timeturn_p,Timeturn_mmy,SJF_p,SJF_mmy,Priority_p,Priority_mmy,HR_p,HR_mmy;
    0 o2 Q/ o+ t+ f1 Q1 kFILE *fp=NULL;) `1 y3 n( G# @" H: w: U! |
    //processPool HR_p,HR_mmy;
    9 L  H1 I7 W: Z9 X0 r0 ?& ^9 W1 u2 S4 |0 H5 M$ @2 Q  Q* T6 |
    5 `3 E# H1 V5 P9 n
    srand((unsigned)time(0));
    6 {. X3 T2 u/ u1 csystemClock=0;
    8 U  `% m# L: D% C1 winitgraph( 1200,650,SHOWCONSOLE );
    + ]; t3 h. F( f0 asettextcolor(GREEN);9 B% u% G$ o- \" _# m
    setlinecolor(GREEN);8 p; p9 [5 ]$ i7 }6 ~5 J
    setfillcolor(GREEN);
    / P0 }: S' f* s$ ^" m2 [9 gInitPool(&FIFO_p);3 j  E  F  J3 B
    sort_by_comingtime(&FIFO_p,-1);+ [" h- L& q  P, k" s7 F
    InitPool(&Timeturn_p);
    * _/ }; |: S" ^( _InitPool(&SJF_p);
    # c/ H8 s! k* F$ a& N, cInitPool(&Priority_p);+ V1 I8 U5 x2 O/ F
    InitPool(&HR_p);9 j5 f: D" b% G! u+ ?
    //showRunningResult(FIFO_save_head,Timet_save_head,SJF_save_head,Priority_save_head,HR_save_head);! q1 x# l( p- o4 W; I
    //Sleep(10000);: w# z* c. _5 R: }
    : }" w) Y9 C' p: w$ T
    ) b) |9 {! ]3 H9 C: \4 L6 R3 {) C
    Timeturn_mmy.p = (process*)malloc(initProcessNum*sizeof(process));
    " ?* X) ^/ @) b; B0 xSJF_mmy.p = (process*)malloc(initProcessNum*sizeof(process));
    ) e7 f5 I  q. F, RPriority_mmy.p = (process*)malloc(initProcessNum*sizeof(process));
    # d/ S5 f/ O: Y% L' S) x1 u. e( b1 HHR_mmy.p = (process*)malloc(initProcessNum*sizeof(process));) P' V+ u/ x5 ~& ]) \8 N
    for(i=0; i<initProcessNum ;i++)$ V( }  _. ^0 h* A& M( F9 W
    {) A( U+ v) a# |& Y& S/ s
    Timeturn_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));0 \8 r' E5 K- N, _, }
    Timeturn_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));
    - R( N2 `3 b% TSJF_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));
    ! l+ Y2 S" H2 [; c5 F* O+ hSJF_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));. k! ~, @1 D* b' ~6 ^
    Priority_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));
    4 I) O9 q% s6 P5 I, E- RPriority_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));( a2 y6 Z! Y- c6 S" u$ Y
    HR_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));
    " s3 ^2 }8 B7 P. P: l' ]& NHR_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));2 ]7 l7 q3 O- ~/ X# p; m
    }
    - ?- t% i$ v* \. sTimeturn_mmy.proNum = 0;
    & Q* Y9 L) `7 B' nTimeTurining_storage_to_memory(&Timeturn_p,&Timeturn_mmy,&Timet_memory,-1);( k1 l" X0 ]  F( q; d7 o' P
    SJF_storage_to_memory(&SJF_p,&SJF_mmy,&SJF_memory);
    " z" O  d8 a# j; t: b1 MPriority_storage_to_memory(&Priority_p,&Priority_mmy,&Priority_memory);1 @0 N5 A) G: u( Q% S4 [6 T2 w
    High_response_ratio_s_to_m(&HR_p,&HR_mmy,&HR_memory,0,1);( E# p  F$ @' T% W% _( w- ^
    //showProcessInf(Timeturn_mmy);
    9 `* T; }. m8 n, y" xFIFO_pri = &FIFO_save_head;
    & B1 l. ~* f: A  s! s3 KTimet_pri = &Timet_save_head;
    5 Z$ w4 v  C  W' [- R" P/ ^8 RSJF_pri = &SJF_save_head;
    , n9 ?2 p$ R4 m2 J( d; ~Priority_pri = &Priority_save_head;! t* e8 Y! j9 c/ Z) _1 l% ^
        HR_pri = &HR_save_head;
    - H1 N# h; L* w* Q5 w6 Dsetbkcolor(WHITE);& z: S+ ^0 N) I4 t
    while(1)- N3 I. U5 Q4 v( t1 G' [
    {) ~2 |" l$ I2 Z% q. `
    if(MouseListening()==1)9 `! x0 W7 ?: [" Q/ Y( x5 v
    flagDraw=1;4 g9 q- v% L3 W/ n. P
    if(count==100)
    5 s8 A8 |' X7 X' V{
    0 `. h1 {+ r* O1 j1 i. Q' a5 Eif(FIFO(&FIFO_p,&FIFO_mmy,&FIFO_memory,FIFO_pri,1)==task_completed)
    8 e/ h: m9 Z5 N6 t2 }{
    5 W' ^0 [" `5 F! W( J" UFIFO_pri = &((*FIFO_pri)->next);9 ?, k, y4 k/ _" ?& Q( c, d  A

    3 {4 Q8 O0 h* y( @8 @' B1 E9 {//printf("hello");
    / P! N' q5 {$ V0 i3 ]' H' E}% t' Q4 f. R7 {) A1 |
    if(TimeTurning(&Timeturn_p,&Timeturn_mmy,&Timet_memory,Timet_pri,1)==task_completed). |2 V( o. F" \
    {4 f$ r$ b% _0 ^: J% r
        Timet_pri = &((*Timet_pri)->next);
    % N+ `% u! Y7 {//printf("hello");
    + q$ R" T% D/ q% x+ ?& E}
    7 b. _* K4 |; ?2 Pif(ShortJobFirst(&SJF_p,&SJF_mmy,&SJF_memory,SJF_pri,1)==task_completed)+ T( a* o4 W! Y2 ~+ |# `! O' Z
    {+ A8 j& W& t$ Z4 _, F
    SJF_pri = &((*SJF_pri)->next);# l3 ]1 _) Q  q- S: p" t# b, N
    //printf("hello\n");3 U; v2 [6 C" Y, V! X% ?
    }% Q3 O8 _( l% H
    if(PriorityDispatch(&Priority_p,&Priority_mmy,&Priority_memory,Priority_pri,1)==task_completed)
    " i/ S* t3 B+ C% h( ?# U" e{
    7 x1 P: E; @9 d$ t* F) s3 K5 U' kPriority_pri = &((*Priority_pri)->next);
    % V; }* c/ p6 K: C//printf("hello\n");: Y  h7 v) `5 k; Y
    }2 T& s3 }3 h7 {; T" E
    if(High_response_ratio_dispatch(&HR_p,&HR_mmy,&HR_memory,HR_pri,1)==task_completed)
    : |  s. V/ X0 Y1 a{
    0 W; n6 P4 m  QHR_pri = &((*HR_pri)->next);
    4 [6 x) t, \5 ^0 N9 I//printf("hello");
    4 ^2 Z( U3 i7 i* F) c6 ?+ }7 [}
    + P) a! {- ^3 R9 wcount=0;
    & u4 T# E* ]. ]' K}- e* O/ o% D, T3 o% N
    else
    2 t& v5 F( o5 e4 w* z{
    6 Y0 B4 ~: B% R  ]$ b* c2 jif(FIFO(&FIFO_p,&FIFO_mmy,&FIFO_memory,FIFO_pri,0)==task_completed)
    + h  o$ E, m5 a8 z& n. q$ c{' A& Y& I/ y3 ^9 a3 S' {6 ]( ^
    FIFO_pri = &((*FIFO_pri)->next);" S& i3 o/ @( y7 R: E$ Z/ r$ J
    // printf("hello");7 x+ J' K) v$ v# d" z
    }
    9 Z, Z& W  ^3 W' U. lif(TimeTurning(&Timeturn_p,&Timeturn_mmy,&Timet_memory,Timet_pri,0)==task_completed)! Q; y& ?. }* \  f
    {
    ) S+ O5 B$ n3 p' a" o9 l2 xTimet_pri = &((*Timet_pri)->next);" ]2 R6 X& A6 q/ ^) h
    // printf("hello");: ]4 m2 h3 J1 Z7 j+ r
    }
    3 q# R8 E5 ^& q  uif(ShortJobFirst(&SJF_p,&SJF_mmy,&SJF_memory,SJF_pri,0)==task_completed)
    . v# d9 \# J! S8 d{: \4 w6 g* Y) X
       SJF_pri = &((*SJF_pri)->next);
    + d8 p4 D5 e( D( Y7 Y: z// printf("hello\n");$ }/ X7 |. B. Q5 |& @: R0 f
    }* m4 v& t; J: x4 v/ X& I0 R
    if(PriorityDispatch(&Priority_p,&Priority_mmy,&Priority_memory,Priority_pri,0)==task_completed)
    ( B. H( K0 m4 ^4 h# y) ?% }  g' C{
    5 s! ?8 y/ y8 b0 ~1 ?, X9 @; |' N; XPriority_pri = &((*Priority_pri)->next);* X2 O' y9 G; r2 Z6 U+ F+ x6 i1 y
    //printf("hello\n");3 X3 \& I, j# [1 L: D+ z; D# b
    }; A, Q% ]. S' u, A/ q
    if(High_response_ratio_dispatch(&HR_p,&HR_mmy,&HR_memory,HR_pri,0)==task_completed)0 e6 @3 G. k' V7 z3 _! ?# e
    {
      b& s2 g8 h' @+ \( Z- O0 PHR_pri = &((*HR_pri)->next);
    5 s* ?) ?6 v# i' m/ X" _+ X//printf("hello");
    $ a/ |5 L- Y7 b) c* c5 N//Sleep(1000);
    1 @3 Y9 s  [8 G8 W5 ^}9 |( y8 z$ k/ m" O1 |' N# X
    count++;3 t3 W3 M. X, h/ x2 s: ]% h
    }
    0 ^8 J. B' Q2 x( Iif(systemClock==showTime)
    1 b  l2 `8 J* A{! D5 f2 d: k7 h( v- W/ u' P
    /*PCI * p=FIFO_save_head;
    5 E6 Z: K. W5 x' Q6 _  T/ p  Lint i=0;, b% X: j# D7 @0 m. p
    for( ;p!=NULL;p=p->next)1 p- W5 P" Z: N
    {# j3 i4 W4 M3 [. S* Q4 r) p
    printf("Id %d\n",p->processID);& v: e( d5 C- b' m) A( r, |
    printf("comeingtime %d\n",p->comeingTime);
    : n8 r" ]7 i6 b) `- T/ B$ Eprintf("runningtime %d\n",p->runningTime);
    0 s- m$ o% q: [( dprintf("asdmemory %d\n",p->askMemory);4 u8 Z; K, Z+ R3 x
    printf("completedtime %d\n",p->completedTime);
    + G: {* e" {* `9 t- [' D; D5 ]printf("compute %d\n",p->compute);( T3 M0 M7 r7 ^" H' X# G
    printf("exchange %d\n",p->exchange);
    ( ]; D% r, n4 S0 g2 ?  d1 F: nprintf("waitio %d\n",p->waitio);# M/ d; \# ?& }
    i++;
    6 p( f( A6 [- @& w5 v" C) x8 H6 J, G" O; Y# C* f# ]
    9 n  N- z( c9 p
    }
    . {7 K% v) u' ^( j/ j4 M" C2 Kprintf("%d\n",i);*/
    2 |1 D; i3 A- V( w0 i7 ?if( (fp  = fopen( "data.txt", "a" )) == NULL )* s  {( B3 C: W4 M$ j+ N
    {1 n  m+ V* T' \- ^8 t: Z$ {# Y' a
    printf( "The file 'data.txt' was not opened\n" );) L- E+ C, V" @( C  E; M
    //return 1;
    - ^) Q0 o. ^8 D2 `! T4 X3 r}( b6 W! W, w- I
    else
    8 [1 e' C( X+ D2 H+ Z. ?, O{
    5 ]4 I* F" K# ?  b) ^7 R2 ~fprintf(fp,"FCFS \n");
    ! H: I2 W/ s, ~& _" g& pfor(p=FIFO_save_head;p!=NULL;p=p->next)
    : C2 z3 H; B+ `3 Q' h: wfprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,) s5 e- ~6 z% b/ x
    p->exchange,p->waitio,p->runningTime);6 n+ l: Z/ D8 i
    fprintf(fp,"\nTime turn \n");8 Q, D. t9 p1 Y
    for(p=Timet_save_head;p!=NULL;p=p->next)
    ' R1 H8 B) p8 }7 b' rfprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    2 M) y6 V6 S* y5 E0 w% E7 N2 wp->exchange,p->waitio,p->runningTime);
    & N( e1 _) n* s5 D9 z6 Xfprintf(fp,"\nShort Job First \n");  H. u# u) G7 _; @# A9 ?* P
    for(p=SJF_save_head;p!=NULL;p=p->next)4 s4 V/ H: [. ]2 Y/ d% Y# p' t
    fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,/ K) s& ~5 P9 w& A+ r  {
    p->exchange,p->waitio,p->runningTime);
    / C4 K. j( k$ Afprintf(fp,"\nPriority  \n");% E" l8 Q5 U9 R9 X: L  g$ d4 F8 s
    for(p=Priority_save_head;p!=NULL;p=p->next)3 g8 x0 ^* e8 x
    fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    4 B8 E( _; K6 J: P2 z" n! N! Bp->exchange,p->waitio,p->runningTime);
    & n, Y; k& e4 c/ qfprintf(fp,"\nHigh response \n");
    7 }' V( v. W7 c# B5 v" [  b8 W1 Pfor(p=HR_save_head;p!=NULL;p=p->next)
    7 r3 O& f3 j, h9 m/ C  I& `2 k- T6 e8 nfprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    7 [" d2 C0 f+ @  }' [  n4 zp->exchange,p->waitio,p->runningTime);
    : C+ _* p0 N. k: f* B9 E. w# L3 Zfclose(fp);' W' i1 ?& o0 W( o
    }! f5 q. z! j( d) Z3 W* S0 [2 t) P
    showRunningResult(FIFO_save_head,Timet_save_head,SJF_save_head,Priority_save_head,HR_save_head);  y6 t3 X7 V) f0 W
    MouseListening2(&flagDraw,&showTime);' K$ a  i" M4 B) k8 t/ q9 m
    }
    5 j% [: I; C! I( {! o% T$ g" TsystemClock++;1 A4 g  U! `2 t" G8 i* d4 I
    if(flagDraw==0)
    % |: R$ _( U1 O2 I2 D  Sleep(10);/ N8 E3 ?% [. m; ~4 [
    }2 Y. g. e4 x9 \# R6 S

    * b0 L0 e) e, |: {" m0 _8 L8 N& M- D
    6 F$ g# I$ {& h) Q& d+ |}
    : A+ w9 i; V' e3 c4 Hint showRunningResult(PCI* FIFO,PCI * timet,PCI * SJF,PCI* PR,PCI* HR)
    6 s6 r' q; x' O{0 S. t0 ]1 o( Q1 A  `# E/ h  _& z
    PCI * p=NULL,* name[5];
    3 ?3 V. M. _3 O, _+ n' Uint count=0,i=0;
    4 S0 A& {- d; F5 @7 A% Z! y8 x: |char ch[5][10]={"FCFS","timet","SJF","PR","HR"};
    + }, ~; t0 u; N: U7 b* Ndouble turnover=0,wait=0,c=0,w=0,change=0,pos[4]={0,0,0,0};
    + Y; d4 M, S. sstruct info4 s0 f& B% S4 J5 B2 N
    {
    6 \! c, Q& C0 z$ ~% O9 Lchar name[10];
    . l5 H' w+ C, R" P, Zdouble throughput,turnover,wait,CPU_rate;
    2 Z  _# |0 \/ j, e- ?9 y3 @}inf[5];
    $ m4 q  J  j! p! J' K  d# ^+ Kname[0]=FIFO,name[1]=timet,name[2]=SJF,name[3]=PR,name[4]=HR;
    1 a) ]$ [1 P# \printf("调度算法..........A\n");0 c6 b7 `/ w6 i% A5 Y+ Z7 c
    printf("吞吐量............B\n");! [, P8 H! w9 }$ Q
    printf("平均周转时间......C\n");
    : O; A) p( O3 R  t2 `! c9 D" nprintf("等待时间..........D\n");
    8 L. M7 a1 n. {. V( Pprintf("CPU利用率.........E\n");
    9 U/ i* o6 A/ H' c% l+ |- bprintf("A\tB\tC\t\tD\t\tE\n");
    1 e/ {1 M9 c5 V. ]0 k5 z. Bfor(i=0;i<5;i++)
    ; o7 }) Y8 D) r1 L" R7 l5 R% V7 q{
    : x7 t$ `  u3 {+ A! mcount=0,turnover=0,wait=0,c=0,w=0,change=0;
    ! r8 `* A7 g; [  N( @for(p=name; p!=NULL; p=p->next)7 k( c! O  v4 i, H5 v. y
    {
    . V! n. R( j: S3 U$ O7 W# Ucount++;
    9 J& z; @0 h/ d* eturnover += p->completedTime - p->comeingTime;
    2 E. M/ W( Y' s# ~/ r4 i6 {/ ewait += p->runningTime - p->comeingTime;
    $ N$ Q; L5 t7 w* o/ |c += p->compute;
    2 F" h6 z) x& R4 q( A: r$ Aw += p->waitio;+ D% m  k1 X  k; F9 U) t0 z
    change += p->exchange;
    2 C( g& y8 J" V4 d}+ N' o# j3 l; [( q
    turnover = turnover/count;
    # F: X4 o2 M: E: K8 nprintf("%s\t%d\t%.2f\t\t%.2f\t\t%.2f\n",ch,count,turnover,wait,c/(c+w+change));
    3 {" \; p9 P4 Y" u+ kstrcpy(inf.name,ch);
    6 h+ y/ v; U& ]6 Iinf.throughput=count;
    3 f1 u6 {6 s, ?  z# m. Vinf.turnover=turnover;7 `' J/ Y2 A, _, b2 J( t6 x
    inf.wait=wait;
    + h# j" d+ D* E( n1 u, j6 d5 Ninf.CPU_rate=c/(c+w+change);+ L5 j, P# j: g6 N& s+ C2 x
    }6 ^' ]- M4 V/ H) Z8 a) X
    //画图9 w; W% ?, L) I3 y- |1 ~
    //cleardevice();3 z1 @8 M$ O/ X! ~- v7 x
    line(0,600,1200,600);& V2 v/ I! r( L
    line(10,600,10,200);
    8 o/ r, p: `. Z3 Mline(10,200,5,205);
    $ l# \0 [. ^) L* l: l4 `6 G7 y/ bline(10,200,15,205);
    / d+ ]# k* K( v& C2 Iline(310,600,310,200);
    % B: P1 }; E0 g; |' A" E, kline(310,200,305,205);. a* G* R- E1 L! H" N
    line(310,200,315,205);) q5 {# e; K/ K! T0 h
    line(610,600,610,200);
    , T; X2 r" V' c) N' g$ a1 F( V7 E) ]: Yline(610,200,605,205);
    / O1 f6 g: \# j4 sline(610,200,615,205);* g4 ^' X$ G/ i
    line(910,600,910,200);) ?+ E5 L  A' |$ N! W
    line(910,200,905,205);; Y: `6 _. y4 D0 V5 v( y2 G2 U
    line(910,200,915,205);//最高的长度400,宽度均为408 s5 r- s6 Y* f! x- D7 M- Q2 K
    for(i=0;i<5;i++)
    + [9 _( k5 F& U3 d7 |{
      ]+ M: T6 B7 d2 O6 i1 sif(inf.throughput>pos[0])2 P4 {+ W% T1 g
    pos[0]=inf.throughput;. |  G4 v" S( m: i$ Z: C2 E2 l
    if(inf.turnover>pos[1])
    5 ]) L6 w( j; O6 W/ ?pos[1]=inf.turnover;
    ) p) P$ G; u3 G3 f3 n1 ^3 h6 Eif(inf.wait>pos[2])0 Z* D$ x- h8 R% e8 ^) N: a7 Y
    pos[2]=inf.wait;
    * D$ ^6 {. l9 g& @0 _if(inf.CPU_rate>pos[3]), y$ I9 N1 ~" I- ]$ S
    pos[3]=inf.CPU_rate;
    , P/ ]& S" P3 P! q& F3 z8 {}
    . M6 J4 T; ?* K. T2 m5 @% r: osettextstyle(30, 15, _T("楷体"));7 P/ Q0 N  ]( C' ~1 D! q; C
    for(i=0;i<5;i++)
    ; R% _2 i( T7 D7 M8 I; p{
    ' p4 u! |6 b. \switch (i)
    4 m. k/ V6 a9 |7 F( b& @{0 B# e) `% B4 ^" g7 v
    case 0:
    9 U6 H& c- h# \& _setfillcolor(BLUE);( P6 s+ Z1 a% n+ v7 N' a
    fillrectangle(100,50,150,100);. H& P- n' K; f$ t; t  h8 L) x
    outtextxy(160,50,"FCFS");8 ^) ~, Q8 S! P$ `0 z1 ?  h
    break;
    ' r' N% J2 Z% i) Z3 _( S; qcase 1:
    5 d" ^$ Q" T$ j4 Bsetfillcolor(RED);
    $ O. p% e" b$ x; K/ F8 {- Q0 W) Afillrectangle(250,50,300,100);
    0 i* D! P* R" {outtextxy(310,50,"timeTurn");0 h  e% m! g( @3 G
    break;
    1 D2 J5 f& |6 V5 [case 2:$ ]1 v! A5 ^6 K4 T
    setfillcolor(YELLOW);
    + p9 u3 U) F$ Z4 Gfillrectangle(450,50,500,100);
    ) i) `' `+ K5 r2 F* s; j8 t3 Gouttextxy(510,50,"SJf");8 _! q( o8 Z) Y, f" [. R
    break;! W  _8 e2 [, G% o1 K& y: [
    case 3:2 c! P: u) s: Z  n
    setfillcolor(BROWN);
    % X" b9 D1 p) n5 A3 U1 P9 {fillrectangle(580,50,630,100);
    / }# q# q3 y5 o, jouttextxy(640,50,"PR");+ g$ e" q4 p1 E5 ~6 J7 g
    break;
    . S9 N5 ]4 U% n1 K! Acase 4:
    5 J; g' y( m: j  bsetfillcolor(GREEN);
    / s+ i$ f& G- R# M5 Xfillrectangle(690,50,740,100);
    8 x4 H  [8 t5 }$ ~: h6 louttextxy(750,50,"HR");4 J. Y$ a* w, L
    break;
    0 [4 I! |! w! r% J}$ K) D3 j1 e7 s. B" a% A* }
    fillrectangle(50+i*40,600-(int)(inf.throughput*400/pos[0]),90+i*40,600);# H. v4 S% E8 y& A
    fillrectangle(350+i*40,600-(int)(inf.turnover*400/pos[1]),390+i*40,600);
    : U) K0 j7 O6 K" x4 u. u; Tfillrectangle(650+i*40,600-(int)(inf.wait*400/pos[2]),690+i*40,600);
    7 d4 n0 p" b" X/ U2 s' _fillrectangle(950+i*40,600-(int)(inf.CPU_rate*400/pos[3]),990+i*40,600);
    , v9 H: n. U+ @  J) c4 r0 W' O
    ; J) ]4 W# s0 ~
    }
    $ l6 T3 o- C0 ]: p8 |    outtextxy(100,150,"吞吐量");  G4 D0 W# j( p. j' y& @* j
    outtextxy(350,150,"平均周转时间");# k3 M; y9 m2 w% O& v( R! L
    outtextxy(650,150,"平均等待时间");
    * p3 X: [! g( \outtextxy(950,150,"CPU利用率");
    $ {( p% e8 ~6 P% breturn 0;
    ' q3 W  G- e& }4 j; B) c}. p$ M0 H* E9 c6 Z) F! V6 A
    int MouseListening()4 c+ L2 @" c$ i, N1 a
    {# N! o+ ?( Q1 F$ e5 }
    MOUSEMSG p;
    9 n  {% j& y4 M, H# {; C' Zif(MouseHit())- X; h: C* [7 M8 l8 v
    {& x" D/ V: }9 g3 k% s; Q1 W5 F
    p=GetMouseMsg();1 Q) y& ^: i; n! p7 a
    if(p.mkLButton==true)
    8 ~0 Q" s  b% q1 x  V# @- A{; m1 v% m; V/ T+ {3 Z
    if(p.x>0 && p.y>0 && p.x<400 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)8 R3 I$ P/ m' ^& x
    FLAG_FIFO = 1;
    ; f& j. z& Z9 I! y. lelse if(p.x>400 && p.y>0 && p.x<800 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0): D2 e: y! H3 V; q& b; J
    FLAG_TT = 1;
    9 k( d' k" X# F( T# f* s" V7 pelse if(p.x>800 && p.y>0 && p.x<1200 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)
    ' y! f  c. Z6 |, `5 `FLAG_PF = 1;
    $ K) f7 j* N- t8 Z) Ielse if(p.x>0 && p.y>325 && p.x<400 && p.y<650 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)
    : Z5 _: V; `0 d( m/ b. @7 MFLAG_SJF = 1;: l% b- {/ _; w3 q7 {2 v
    else if(p.x>400 && p.y>325 && p.x<800 && p.y<650 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)
    ! n7 c- h3 `/ c2 w9 t, l" KFLAG_HR=1;1 X! k/ E; k1 |4 I3 l
    else if(FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO >0)
    & P/ t9 f6 n- w% L" C. Q{
    8 n) K' a$ k8 G. jFLAG_HR=FLAG_SJF=FLAG_PF=FLAG_TT=FLAG_FIFO=0;
    " i5 M2 q6 t  ~0 `: f5 Nclearrectangle(800,325,1200,650);7 O0 E3 F) U- R3 [
    }
    . \0 d8 F- Q. q. k7 k1 z2 Kelse if((FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0 && p.x>890 && p.y>455 && p.x<1110 && p.y<510 )
    8 r3 n& ?* \. u5 p* \! C{( f+ ]% n! O( J# u) ^9 t
    FLAG_show=0;$ n6 L$ h  K3 s* g
    cleardevice();
    ) R5 M; T& g" a! Breturn 1;
    / R& Q0 h6 U7 F& ~5 ~}
    # j2 K1 L; ~1 q- l! b, W}- l1 y- G5 y! a
    }  x" c) M( W- Y& [. q7 D. z8 T0 m& d
    return 0;! {) `$ d" v; q/ u
    }% R0 Y) j3 z& n8 [' G9 o/ B# ]
    int MouseListening2(int *flagShow,int * showTime)
    ( C4 ~7 v, B1 p& @8 I{
    $ v+ p1 D- Z% W8 n* oMOUSEMSG p;  H  q5 c0 V6 N
    rectangle(1150,0,1200,50);" z, r- [( j5 J8 P3 L
    outtextxy(1160,10,"X");- [5 v9 @- @/ X8 O3 a# H
    while(1)5 p6 n6 f/ i+ j; ]4 P
    {
    + [* O9 }( j8 d# ?if(MouseHit())3 k% E4 J. G6 g, ?: `& m, m
    {6 L  O- Y* h$ ]+ O# ?' \
    p=GetMouseMsg();
    2 T2 n1 X9 k7 ?/ {: wif(p.mkLButton==true)- M( [, }% O" T6 E7 i6 A1 w
    {
    * Z) k% C9 V6 Z' Q- cif(p.x>1150 && p.y>0 && p.x<1200 && p.y<50 )# E9 }+ t2 h3 D, U% s
    {
    6 }- k; r1 D: p4 n3 U! i# L  N(*flagShow) = 0;
    . y5 W$ P) r4 C5 w& ~; R. Z(*showTime) += (*showTime);
    $ w5 ^/ w5 g: y5 h! ?( JFLAG_show=1;
    % n1 F: q, c% j, ?$ ibreak;
    ( D/ b+ B  h* u- X0 L( ~}
    + g- H$ ^3 E  g3 Q0 |' g" y1 I& H) X6 l6 d0 O' E
    }) q+ r9 i$ g( ^" |& _! M- V0 s$ A
    }
    ( L' |) F1 l4 f5 y# O5 D/ o, |: h0 rSleep(20);% L3 L3 B) g. @6 t
    }( m/ e9 m1 t; Y% j" S' c  u7 F2 n
    cleardevice();  ^& U3 X' X( Q& x& |
    return 0;  ~6 {3 |. e7 o8 m' b
    }2 a/ g% e2 u/ b4 }
    int drawPerformance_FIFO(int x,int y,int memorry,int com,int wai,int cha)' m+ t( w3 L$ _5 B0 H# S
    {
    2 C- v5 }5 W" `2 ^' ~) qstatic int info[11][3],num=0;
    $ y9 _  X. q: R' Qint i=0,j=0,pos[10][3][2];/ g9 m3 ^! D, ]9 i4 y) H
    float temp,t;8 V6 [2 X* J/ M
    //画按钮,不属于FIFO图的范围
    % U) [: ^7 ?0 K3 M* N6 R: B3 pif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0 && FLAG_show==1), l/ y! j; a$ A8 y
    {# ]5 Z5 {3 M. }0 q
    settextstyle(30, 15, _T("楷体"));' Z7 ]$ e' U* V0 {6 r
    rectangle(890,455,1110,510);
    ' K% n1 c& g. t0 E% T, Mrectangle(900,465,1100,500);/ r& \8 B2 C) i; }. D( x2 e: ?
    outtextxy(910,468,"查看运行结果");
    . Q; E' j, R2 p+ T% m# n3 t# L4 Q}
    8 Y$ w2 ?$ K& e6 Y$ v4 P. |//结束画按钮/ x, O3 {9 f7 V9 y/ k  ]  q
    info[num][0] = com;2 j6 h* P$ j6 o$ B# B$ |5 _
    info[num][1] = wai;: _' B- N, b7 E1 L9 Q$ G
    info[num++][2] = cha;
    ! f0 h/ L2 Z: b/ E, ]if(num>10)  //存储10个点( j' q+ G$ e1 f7 O9 w( u/ l
    {
    1 h3 x8 P! p+ jfor(i=0 ;i<10;i++)+ `: `! J% q$ E5 T8 s5 r* y9 R
    {
    , y* E( ?9 |" J( C. W9 B4 e, G0 einfo[0] = info[i+1][0];
    - ]) r, H! q4 Y1 l5 I) y1 k3 sinfo[1] = info[i+1][1];
    4 w3 i+ ]: l) K3 }  D( G3 pinfo[2] = info[i+1][2];
    ' v* d2 y& J3 S1 O}
    5 q/ h+ h' B0 ^2 k/ Nnum--;7 N) A) S. }+ o/ I/ O! u; T
    }  o/ [% w: G1 T" |, h0 F3 t
    if(FLAG_show==0)
    ' @: k  t& c5 i  w+ Wreturn 0;
    , Q4 R0 c. U% k+ A/ ^  q, z4 bfor(i=0; i<num; i++)8 [1 ^- D+ d! @! V8 s; B; h
    {- @' \8 `5 E  x5 o  {4 S) }
    t = (float)info[0];$ h5 [; Z8 S; z/ j2 C
    temp = (t/101)*90;
    ; h3 ^  c% \; T( t, D2 Ppos[0][0] = (10-num+i)*25+x+100;% t# I2 \4 H/ U) s
    pos[0][1] = y+110-(int)temp;9 u5 Y/ ^# Z6 C- y" k
    t = (float)info[1];. V- ~+ G2 ~- f9 k
    temp = (t/101)*90;
    / l2 W9 a+ L3 r) S0 Qpos[1][0] = (10-num+i)*25+x+100;
    3 `/ \6 x" g0 vpos[1][1] = y+210-(int)temp;& e, ?& |; l! D& R3 T# \
    t = (float)info[2];8 d, W9 M) V! X: K6 x3 }, E9 _
    temp = (t/101)*90;
    ( n& z& j% Z3 f+ T4 j$ _; Ypos[2][0] = (10-num+i)*25+x+100;
    ! C" d$ u1 e: Y6 |4 W% upos[2][1] = y+310-(int)temp;* R& ?8 Y7 \+ d
    }
    3 Z+ j* a& x2 G; I: ~' O! G* qif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
      |. L0 B) R  C: I3 p2 s0 e, C: R3 g{
    - y2 G( u1 \! s1 C! M' Zclearrectangle(x,y,x+400,y+315);
    ! A' a* `9 r, l, [4 Wsettextstyle(20, 10, _T("楷体"));# _. f" P& |$ f
    rectangle(x,y,x+400,y+325);
    2 W# u: k# D2 e( Z8 k' K8 Douttextxy(x+40,y+10,"CPU");       //画柱状图
    & v2 o( {# o6 _9 x6 ^outtextxy(x+45,y+10+100,"IO");: ?) a" |; {$ |1 R: U8 e: Y2 k: q2 o  Q
    outtextxy(x+40-15,y+10+200,"change");9 W$ T& ^5 K; J2 d  k4 I, O% X5 ~9 R4 n
    rectangle(x+35,y+30,x+75,y+110);" \% Q) ~. l, \- U4 K
    rectangle(x+35,y+130,x+75,y+210);
    1 W' j# H8 J3 H7 Wrectangle(x+35,y+230,x+75,y+310);
    & v8 }6 o0 ^" Q7 M( _, J; c7 f% houttextxy(x+180,y+310,"FCFS");/ i9 ?. M  \% T
    t = (float)com;
    8 I, G- y" u5 Q+ g  T8 Wtemp=(t/101)*80;
    $ f7 F2 Q' e! f9 yfillrectangle(x+35,y+110-(int)temp,x+75,y+110);
    / m( A; _, v% zt = (float)wai;1 a% ]# P$ u1 D3 m' b
    temp=(t/101)*80;- t6 s# Z1 |4 S* N! ^8 W3 K0 }# z
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    , u' v6 L! U% rt = (float)cha;1 R7 ?% w4 B6 T6 q6 \. }
    temp=(t/101)*80;. c% J7 K8 N1 V( W: F; k/ }5 [
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    % E/ T; Z7 g1 c4 f& v! ]for(i=0; i<3; i++)   //画坐标   high=90,length=250" N: c6 O3 g! q- x9 d6 x  p% ?( Y
    {  }' i7 q4 e1 L( N! h3 b3 t. m
    line(x+100,y+110+100*i,x+350,y+110+100*i);
    9 E# L4 Q/ z6 P2 a" @& u, Oline(x+350,y+110+100*i,x+350-5,y+110-5+100*i);
    - B, I9 Z7 u; o8 N# G3 @; t* ?line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);
    " ?2 P7 l. d9 ?7 I  E+ i" ~% \
    3 E; e. x6 r8 W6 X% z. b6 ]0 v6 v! rline(x+100,y+110+100*i,x+100,y+20+100*i);
    4 I; H% X+ A* g2 m" }* V% Nline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);) R/ M  B/ o6 a4 E& H
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);- K9 B9 @3 t0 z- [0 Z$ \
    for(j=0;j<num-1;j++)
    4 D% c2 U) k6 K/ S) G/ Z8 N6 C/ t) w{
    3 Q& N& \7 w. z$ x0 W0 `7 eline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    7 L$ ?. |* w+ V. F5 N0 Mline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    5 x  ]7 u6 w* E0 ?" ?line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); ' w0 n1 Y; D7 U
    }
    ( k9 ~" Z, y& M4 J; |}# q  q$ a) @. L/ _2 D  l2 }
    }0 K* s: F) t- ^. `" I
    else if(FLAG_FIFO==1)
    * |) C" W9 `' y2 W) e' b$ I{
    . m7 ~. D! e1 K$ y4 a6 _2 Sx=0,y=0;/ y8 J2 [9 ?0 ~* _+ B
    for(i=0; i<num; i++)
    & @; K+ L/ F$ a3 @5 }{" Q% y9 u- Q' [6 E& a6 D, D! N# q- B
    t = (float)info[0];7 P2 _, k8 P: _, C* y% J3 k
    temp = (t/101)*180;
    . o/ J0 B  {4 @8 k+ V0 p' n" Spos[0][0] = (10-num+i)*50+x+650;: _6 J. ]0 z0 ]: d. J9 k' m+ o6 l
    pos[0][1] = y+210-(int)temp;4 O+ s  i1 e. O7 r0 x
    t = (float)info[1];3 T+ \4 o, Q# C" p% y" R
    temp = (t/101)*180;8 B" W8 j# J* C
    pos[1][0] = (10-num+i)*50+x+650;
    / p3 ]+ \( q8 i2 H; K3 m! E. Wpos[1][1] = y+420-(int)temp;. [3 ?) t( P0 b6 @  q; ?8 |
    t = (float)info[2];# A' `, y6 ^7 x6 e: V
    temp = (float)(t/101)*180;0 @: X9 {. G% G: C1 G& W: b0 {
    pos[2][0] = (10-num+i)*50+x+650;8 ?+ n  J! w) r$ T5 p& f
    pos[2][1] = y+630-(int)temp;
    2 e% M2 y- \+ X% S; i- y}- o2 r" {) c; G% ~& w# x
    clearrectangle(x,y,x+1200,y+650);2 l% y& a" y6 H, R# p7 l
    settextstyle(40, 20, _T("楷体"));
    ! k' q' u. h9 X6 l+ [) r5 M$ Routtextxy(x+50,y+50,"FCFS");$ c6 U1 R" i  @7 I
    outtextxy(x+280,y+20,"CPU");       //画柱状图9 |! r- C& ^7 `: e1 \' o
    outtextxy(x+285,y+20+200,"IO");, Y" M% O2 B0 @
    outtextxy(x+250,y+20+400,"change");! {' }; k/ \% w* a1 I4 w$ Q; Z3 H
    rectangle(x+270,y+65,x+330,y+215);7 a! S$ J  w& y8 X
    rectangle(x+270,y+265,x+330,y+415);* i* M; ~  D0 K% U/ e2 U6 k# g
    rectangle(x+270,y+465,x+330,y+615);
    ) ^0 o4 @# b, X% P8 wouttextxy(x+290,y+620,"TT");
      D' b1 o8 _( L  `7 ?$ ^; K1 b( t: e8 tt = (float)com;
      ^/ v+ G/ S+ |8 Y; ctemp=(t/101)*150;# j* T9 c# Z6 q
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);) u  V0 X  w* X
    t = (float)wai;. B, z5 n: N7 B& V
    temp=(t/101)*150;) N, S6 j  j2 e# R, S. \9 W/ p
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);' a7 C" N: E4 n0 ?1 w- u3 |
    t = (float)cha;
    ; M& R, i$ e& U& a, Htemp=(t/101)*150;
    & j. N) `# N% Zfillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    ! |) R. h( i) F1 i: m( wfor(i=0; i<3; i++)   //画坐标   high=90,length=250/ q% |$ H  Q/ t, \3 P  ]4 \
    {  [: ~3 b+ Y0 p1 d/ X, B
    line(x+650,y+210+210*i,x+1150,y+210+210*i);
    . z+ Q2 h$ U; n: Y& oline(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    3 j' K" A# ^! Z1 h! q+ C( e3 w& aline(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);" ^% T7 h! h4 \

    3 }4 V  L' i! H* I9 f9 S: mline(x+650,y+210+210*i,x+650,y+20+210*i);& U( L) }1 T; O/ n4 W4 V$ G1 `# N
    line(x+650,y+20+210*i,x+650-10,y+20+10+210*i);$ R+ V& r9 j8 F) ~: W
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    6 m9 o7 k% R* N  b5 _' Ofor(j=0;j<num-1;j++)4 f3 o# h7 Y2 N& J$ k
    {
    + r+ X  L: }3 ]5 X! W5 k  r; S; _line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    5 k+ h* Q# y4 A1 q. Kline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);( c; q) Q9 P3 ?% }1 a& C
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    % G' |" @6 q0 k. C- L7 I' |) A}
    6 d* k' I; f  X: o) N  J}
    7 _# w9 m5 ^: B! ?# G, ]( J}
    ; P( ~0 |9 u5 F4 z9 X- l# u; @& R9 G. H9 i3 R, h# `' y% Y
    $ T  \0 l7 O8 q. K6 R( p
    return 0;
    1 p  A$ Z/ e8 h. K4 B# S$ y' ~7 c, g}  [  t& A& _0 x* s$ ~5 {
    int drawPerformance_HR(int x,int y,int memorry,int com,int wai,int cha)
    ; L0 o* K& C, Q{
    3 P# c9 ~$ @$ k* ?9 Qstatic int info[11][3],num=0;
    ) W6 G; l+ }0 e5 H2 Zint i=0,j=0,pos[10][3][2];+ {+ D- ^( r6 A" }9 D1 c3 `
    float temp,t;
    # w" @% L9 H" F. M/ Zinfo[num][0] = com;% W1 l+ A+ c# r3 Z4 n5 j& k
    info[num][1] = wai;. a+ e9 N5 L# T& @6 ^+ l' e
    info[num++][2] = cha;) \: D. ?; c/ l" l
    if(num>10)  //存储10个点) ?/ i- S5 M* \" \5 J
    {& [; [3 G3 A' ^! A3 {9 s" h
    for(i=0 ;i<10;i++)1 s5 J3 M2 \0 K! \3 o2 b: n0 p
    {
    ! A! e/ n, a1 M" L7 W4 Linfo[0] = info[i+1][0];
    & }# V: L  N  e) q3 K) tinfo[1] = info[i+1][1];  m8 q! e: i1 K) t  r% N+ n
    info[2] = info[i+1][2];
    1 d- ?6 G0 P! _}5 N  x( C! a  O; l' V! E
    num--;& a: g2 c1 a. F
    }
    ' R& g2 f' `2 nif(FLAG_show==0)
    / X9 c' v- k- L$ Q0 vreturn 0;# K9 X4 {" h0 V' f/ `( W
    for(i=0; i<num; i++)
    8 z4 l; e& H' W8 A3 ]' t% L{
    ) R, f  K# K0 H) V" Lt = (float)info[0];
    ) o- [% a$ \3 u: r) f+ z0 J! q# Htemp = (t/101)*90;. U4 n3 v/ y& g: D; T* m/ |
    pos[0][0] = (10-num+i)*25+x+100;- i4 g: ]2 U7 J* ]
    pos[0][1] = y+110-(int)temp;# b4 F; V  o" [; z
    t = (float)info[1];8 a1 ?' U# \( E8 o! _, w
    temp = (t/101)*90;+ R' h3 g$ l7 C; k  Y
    pos[1][0] = (10-num+i)*25+x+100;
    9 G! T$ K5 V$ S8 Y5 g  Fpos[1][1] = y+210-(int)temp;
    - S& w: \; z. S* y, r6 B7 o' nt = (float)info[2];
    + r; @. b; I! Z, m) X! ctemp = (float)(t/101)*90;
    . }5 K: p3 f2 x5 x) ?6 Opos[2][0] = (10-num+i)*25+x+100;- D( O5 o4 D/ ~6 q7 P
    pos[2][1] = y+310-(int)temp;( f2 }( o; R) Z
    }# M- R5 S/ K( V+ O5 Z
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
    $ K  `, e; H! x( F$ R$ ~3 k6 j) _{6 Q( v: p: ^& [* n# A" H6 ^; J( x
    clearrectangle(x,y,x+400,y+315);
    ) |" N; w$ Y/ M5 \% H( Dsettextstyle(20, 10, _T("楷体"));
      v" t; n6 D2 |+ g8 orectangle(x,y,x+400,y+325);4 H7 W; ]/ M# y  f
    outtextxy(x+40,y+10,"CPU");       //画柱状图6 _/ i: W) o9 \6 H3 n
    outtextxy(x+45,y+10+100,"IO");
    * I! `6 L( v+ [' e8 |) Qouttextxy(x+40-15,y+10+200,"change");
    / x; {2 }- }% @( drectangle(x+35,y+30,x+75,y+110);
    . r8 g9 f) d2 V+ q7 N5 Mrectangle(x+35,y+130,x+75,y+210);
      c9 L" p# @5 R9 c  U5 U: ~rectangle(x+35,y+230,x+75,y+310);
    " B' @4 i7 _. d- Q0 o0 oouttextxy(x+180,y+310,"HR");& [1 }6 f- Q% r; @: ]5 f5 O1 D2 b3 b/ d
    t = (float)com;3 S: p2 B7 ^6 t7 i
    temp=(t/101)*80;, Z% s+ {7 H% S! f, h
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);6 C% X9 X- x/ L1 m
    t = (float)wai;# ?& p0 x7 ^( @/ ]' ]  }1 {' c
    temp=(t/101)*80;. U7 b( K  {! G% b% A1 _$ `5 m
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    4 H4 U3 ^5 B8 b9 ?t = (float)cha;
    - _9 S  n/ l: i; `# r6 ], O6 _temp=(t/101)*80;
    4 Z0 t) Y2 \% d- \, |fillrectangle(x+35,y+310-(int)temp,x+75,y+310);, C# s6 n) S4 D- P* C
    for(i=0; i<3; i++)   //画坐标   high=90,length=2501 f0 Q9 ^( X! y5 D
    {
    ) [# y6 r& B9 k, Fline(x+100,y+110+100*i,x+350,y+110+100*i);
    4 l& W- `5 t0 Y, T" \line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);8 q  r! T7 X2 A1 A& q& k
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);9 T9 B' y* t8 u1 W

    1 d! \" S2 E0 Q5 f0 z* p: Zline(x+100,y+110+100*i,x+100,y+20+100*i);" _. h7 \$ ~7 V# y. z* K+ h: v8 H
    line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);
    ) x/ t% B/ `/ t9 C$ c: bline(x+100,y+20+100*i,x+100+5,y+20+5+100*i);3 n0 K" b& {7 Y- E0 {0 ]* h
    for(j=0;j<num-1;j++). v6 j9 [: D0 r
    {6 h# K1 b3 j; C, ~1 S
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    " z: R3 D# o/ s6 m- e) {line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);3 _2 \! H- i: J
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); 3 U, K7 T. ~2 b& c
    }
    % R+ _1 h0 q. u% i/ o}
    5 r/ `, Q& V: t  c8 `}
    . b, C$ _6 C% |) T' ~, Qelse if(FLAG_HR==1)3 G, w7 H) J. R$ O8 C4 j, d
    {, C* K# x8 V. z& L: j
    x=0,y=0;
    & G; D9 ^! G  Cfor(i=0; i<num; i++)4 T8 R3 e0 R8 Z3 |
    {
    & M9 t) R" o8 ~" \" ~& D8 H; Bt = (float)info[0];
    " n  ?8 h' _2 m4 Y. Q. C* T+ @temp = (t/101)*180;/ }" }+ u& ^5 S# ^
    pos[0][0] = (10-num+i)*50+x+650;
    1 i, i" w& q8 B: ypos[0][1] = y+210-(int)temp;
    1 S( }! l5 n& l" \3 o+ ~t = (float)info[1];
    $ a* w. p& ]- I4 N1 Etemp = (t/101)*180;! w7 @' D% N3 t" J
    pos[1][0] = (10-num+i)*50+x+650;
    / j$ i5 A, I4 c. |pos[1][1] = y+420-(int)temp;4 s6 F6 a; N% P# u% V- F+ E9 w" B
    t = (float)info[2];
    4 _) P1 a; S, }temp = (float)(t/101)*180;3 ]0 Y  s: \; p' {3 d8 g
    pos[2][0] = (10-num+i)*50+x+650;0 F) x" U; c6 x/ S1 T) K& R2 _9 E3 U
    pos[2][1] = y+630-(int)temp;. D! F4 V( n* x8 Q. A
    }# d; K+ Z. |. j( e# S; |# v* D
    clearrectangle(x,y,x+1200,y+650);
    5 z0 r6 Y- z' |settextstyle(40, 20, _T("楷体"));
    : _: d4 t/ x% t2 o, U. Douttextxy(x+50,y+50,"HR");+ o. o3 ~0 E) Z; }! q; u
    outtextxy(x+280,y+20,"CPU");       //画柱状图- d+ l0 O% P0 {
    outtextxy(x+285,y+20+200,"IO");) D, f. w4 O$ `; M0 q( g
    outtextxy(x+250,y+20+400,"change");* D0 o+ }( d- x2 f3 f' t, `8 b
    rectangle(x+270,y+65,x+330,y+215);
    $ n  i& c' Z* V+ X) L* z8 x# y1 Hrectangle(x+270,y+265,x+330,y+415);
    * }& k# p) P9 C) f1 `# t5 \rectangle(x+270,y+465,x+330,y+615);/ N- w, `) q# Y4 d" Y5 U
    outtextxy(x+290,y+620,"TT");
      Z' H; V5 {2 Et = (float)com;6 z) O9 _: R4 U, h6 B0 Y) D
    temp=(t/101)*150;1 O) {, P0 _: R1 S2 d' @' c
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);$ ^3 c$ h: h  W3 T+ A0 n& S
    t = (float)wai;
    0 O0 E7 m$ V# z5 ^- Ztemp=(t/101)*150;
    2 d0 c; ?& N$ i5 m* q, {# ]( Afillrectangle(x+270,y+415-(int)temp,x+330,y+415);& ?8 U' n, s3 l) m6 o+ i0 y* |
    t = (float)cha;
    : H8 b) b/ q( J1 Y6 Y& Q, p; ktemp=(t/101)*150;% r. u5 V/ p" V; N
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);9 k" c3 n; c$ Q2 z
    for(i=0; i<3; i++)   //画坐标   high=90,length=2502 g$ e1 K+ u4 D
    {
    % }, n( Z. q+ w" u6 Tline(x+650,y+210+210*i,x+1150,y+210+210*i);
    " ~& v  c' J! p0 |- F* P# A+ Vline(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    / H7 H+ O  C1 N5 v( Jline(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);
    ( z5 ?' T6 [# J) o7 y/ }( \  t
    / M: ~4 {4 N. J2 Bline(x+650,y+210+210*i,x+650,y+20+210*i);
    % C3 x4 e9 q8 W  G1 Y, c% _' B+ ]; @8 zline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);" [5 S! N* V6 t0 Q* ~# C
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    / k. ^- L( @+ t5 T* u- \) I; afor(j=0;j<num-1;j++)& u" _; [" u& _8 O; _1 j3 J* S: S: @
    {( X( }1 L. i; c/ C
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);7 K$ L$ }% {" I5 c
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);3 ?! D* O0 y& d& |& q: q% O
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    / ?) j+ w; z) l% l}
    9 F/ ]/ d$ L* C, x0 @( s4 F/ ^}& ]8 ?1 M/ j% t$ _; c1 P
    }
    $ Y+ w4 M5 }9 K* y$ {' k* ]! r; p- d& c
    & N# C9 G5 B3 h. L9 d) x0 \
    return 0;. Z5 H8 O/ l2 ^% _
    }
    ; ?/ N  ]4 C0 e4 bint drawPerformance_TT(int x,int y,int memorry,int com,int wai,int cha)% _3 s$ G/ V+ G3 u3 n0 D# _
    {4 c. {% l5 s4 b
    static int info[11][3],num=0;
    9 r' z! B5 T: S4 |' w8 fint i=0,j=0,pos[10][3][2];
    9 v* O8 F6 g4 F, `4 d; _, [) nfloat temp,t;
    1 W  l0 \/ Z2 R  Q$ Sinfo[num][0] = com;
    ; }' X/ [/ Z- ]3 c( p+ qinfo[num][1] = wai;: W+ D1 ?: Q* j. E
    info[num++][2] = cha;1 k0 f: X9 P% B8 B3 H1 m3 o
    if(num>10)  //存储10个点
    9 ?$ D$ T8 J0 Q: w  b* V  j* N{) ^0 c+ C$ S9 }, \( m! n- {' i
    for(i=0 ;i<10;i++)
    ) \- k% Z! z+ ?; t/ f4 r{1 C0 f0 U7 v- ]  k
    info[0] = info[i+1][0];
    % a  X2 t, b3 b) S' y* yinfo[1] = info[i+1][1];5 T9 K7 |; H! Y5 @: r* P
    info[2] = info[i+1][2];
    $ r' E. d# N- D( B1 _}. m! \& F! K2 a1 M0 Z
    num--;8 T' Y! x" `8 E
    }
    9 g9 E$ x/ V& J# J! o5 C5 cif(FLAG_show==0)
    , w7 P/ F" E: i& X5 Kreturn 0;
    / Z  V- k& d9 Gfor(i=0; i<num; i++)
    , {# W7 f7 I: Q; q: y5 v/ q6 s; [{8 o+ a3 p& \2 M) _" o0 F
    t = (float)info[0];
    7 j7 A2 B5 Q" S, d5 m' W8 }$ Ytemp = (t/101)*90;
    0 M6 `' ?5 M' z5 Q2 F1 z  H+ ^pos[0][0] = (10-num+i)*25+x+100;
    # s' ^0 u7 g% s! M+ y: [2 _pos[0][1] = y+110-(int)temp;6 I  Y) Y7 v0 V& P8 }. g- r1 u
    t = (float)info[1];
    + S/ w. y' |+ W2 C- ftemp = (t/101)*90;% Z1 p9 P- V4 @! P
    pos[1][0] = (10-num+i)*25+x+100;
    7 Q+ R% ~5 o; b$ }- spos[1][1] = y+210-(int)temp;& K$ D/ x3 t0 {# C4 x( K9 C! \8 F
    t = (float)info[2];1 I5 e2 ]. F6 r) R, Q8 H
    temp = (float)(t/101)*90;
    9 V( c! P& R& ~' Npos[2][0] = (10-num+i)*25+x+100;4 ]) M# j; F. k# p
    pos[2][1] = y+310-(int)temp;* F# n0 D1 M' S8 m; T: f& F5 B
    }
    3 B: y% c1 e0 qif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)7 Y) y% M( ?0 _$ g3 M# q/ o
    {
    ! S: c/ h  x, r  Z6 V' k, J8 oclearrectangle(x,y,x+400,y+315);
    : P" p! W! r1 i" Y" T4 Jsettextstyle(20, 10, _T("楷体"));
    4 ?& @; b9 t  srectangle(x,y,x+400,y+325);
    ) Y4 n" W1 H6 Qouttextxy(x+40,y+10,"CPU");       //画柱状图
    . |0 N9 Z; u3 R- d* qouttextxy(x+45,y+10+100,"IO");
    5 s, K4 l$ _. Z( Z9 ?' iouttextxy(x+40-15,y+10+200,"change");
    ) Z  L5 i: F) ~1 F2 c! Lrectangle(x+35,y+30,x+75,y+110);
    3 Y8 \6 M2 s. @8 L8 T! D2 urectangle(x+35,y+130,x+75,y+210);: {. f5 I: e% w. h3 `( K& Y6 V
    rectangle(x+35,y+230,x+75,y+310);+ R3 v$ Z$ s8 z7 I+ [) }' x. ]
    outtextxy(x+180,y+310,"TT");
    0 S4 S! X9 a" Jt = (float)com;( S; @5 l  X9 t/ Y3 q2 g
    temp=(t/101)*80;
    1 @! S; h: q3 vfillrectangle(x+35,y+110-(int)temp,x+75,y+110);( r. j6 _1 `. `5 v: ]5 }
    t = (float)wai;
    0 g: I! {8 }3 o5 S! S$ ^4 R6 Gtemp=(t/101)*80;
    4 G! D2 s2 o2 j4 _/ v0 }# m; sfillrectangle(x+35,y+210-(int)temp,x+75,y+210);: p5 e1 X0 S3 @0 ~2 V* G; _: h
    t = (float)cha;
    9 n6 o: p5 S! _& R  n$ mtemp=(t/101)*80;& Q+ R) z1 h% u0 ]5 W
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    9 e. a$ K+ n0 ?4 zfor(i=0; i<3; i++)   //画坐标   high=90,length=250
    * [7 m, i3 P6 b{# ^( Z1 X5 g( t* A: M- {6 ~
    line(x+100,y+110+100*i,x+350,y+110+100*i);0 M# D* f; _+ e6 Y
    line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);: v& H3 W! l% x4 q9 r6 p+ W
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);
    + R+ t, z( q6 V4 N# j# L. F, a: m; y. _6 l2 g- q! _0 z4 q! c, v. A! N
    line(x+100,y+110+100*i,x+100,y+20+100*i);
    ( |' C& R$ k$ kline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);( W2 R* I9 H2 S+ F# D
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
    ! u& c0 Z4 {* G$ Y. d$ ^% Qfor(j=0;j<num-1;j++)
    - f: `. v- i+ i3 e8 C  W$ c! ]* _{3 Z. b5 t6 s) f6 Y& V, B/ x/ r
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    1 d6 [6 M' @; Rline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);7 l" s: q, |1 t
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    ( |; c7 Z% g9 \6 i2 p- M+ e}
    ; K2 \; Y# G4 c  K2 T  L- ^}
    1 e8 n2 B; H9 T6 x8 x) W}! J# R. \. A* I* P
    else if(FLAG_TT==1)
    * R4 u3 o% p# j+ p. w4 H{. T  h9 j+ N+ k9 \
    x=0,y=0;
    ) x" l0 e8 Z; u/ h# g  X- Cfor(i=0; i<num; i++)7 b! a# Z5 {2 z7 O5 t# n* D
    {
    . \2 z* L2 W% R2 ~4 @- r8 Ot = (float)info[0];
    : A7 z% r& d8 H- O" B# p, Qtemp = (t/101)*180;4 w. l1 M4 Y9 {" ]5 _: A% ^
    pos[0][0] = (10-num+i)*50+x+650;% M* h) `5 S$ Y- x7 q
    pos[0][1] = y+210-(int)temp;+ U# W' l7 j; R
    t = (float)info[1];8 M6 y- L. R. E; O3 k
    temp = (t/101)*180;3 l" g, P% T" Y
    pos[1][0] = (10-num+i)*50+x+650;
    9 H, L- L& r9 x1 T: F1 L1 opos[1][1] = y+420-(int)temp;1 H3 X* z% C: S/ u
    t = (float)info[2];2 [4 r" }% B$ J: n9 y1 `. s
    temp = (float)(t/101)*180;
    4 B1 L2 c* }2 B' _: d' j- p  _! dpos[2][0] = (10-num+i)*50+x+650;
    3 O( M! i' [6 }5 Cpos[2][1] = y+630-(int)temp;4 b0 g# g3 x; ]: k6 A6 p
    }4 O% k) J9 L+ D& |+ _3 y8 I+ I8 x
    clearrectangle(x,y,x+1200,y+650);
    5 Y' d* G# Y3 b: K: osettextstyle(40, 20, _T("楷体"));0 B9 P0 j6 M, g& W' H$ g# x
    outtextxy(x+50,y+50,"TT");
    8 D8 X% `5 {5 z# D9 q7 O! nouttextxy(x+280,y+20,"CPU");       //画柱状图
    # |6 P; k: G! xouttextxy(x+285,y+20+200,"IO");
    - M+ Q8 f) _; douttextxy(x+250,y+20+400,"change");0 l' L; W  d9 V3 R( A
    rectangle(x+270,y+65,x+330,y+215);
    . L" u& W2 w$ j* o. orectangle(x+270,y+265,x+330,y+415);. a  D& Y$ M$ E
    rectangle(x+270,y+465,x+330,y+615);" h, \/ H) z: w% ~; R2 x
    outtextxy(x+290,y+620,"TT");
    9 P- x3 q3 s: T" Rt = (float)com;: b( P4 e. ]3 ^7 Y* P: N
    temp=(t/101)*150;2 q4 Q3 k/ |5 H7 |. u- `7 m
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);
    # w, O4 \' s6 P- [- s8 x2 _& Lt = (float)wai;
    0 S# Z) i1 c9 w1 [6 X: Atemp=(t/101)*150;
    ) N" H3 O# L3 L# q% c) k- Nfillrectangle(x+270,y+415-(int)temp,x+330,y+415);+ Z3 b) [1 `$ Y: C
    t = (float)cha;( F$ c+ n4 D7 _! F
    temp=(t/101)*150;* w  J$ ]( F- r6 o1 C1 L9 V
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    0 b& j# Z1 o( w& c6 Zfor(i=0; i<3; i++)   //画坐标   high=90,length=2506 K4 A7 b" `2 q) H+ d2 g; [
    {: Z0 N1 N) M& f( p4 O9 M, M
    line(x+650,y+210+210*i,x+1150,y+210+210*i);! L; B9 s9 g- ?: U
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);& @9 [3 N& r; I0 q1 B
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);% S: e" f" s# j; V& h* N

    5 L0 J' @9 M' V5 G& zline(x+650,y+210+210*i,x+650,y+20+210*i);0 r2 |0 }9 [+ L  N2 O
    line(x+650,y+20+210*i,x+650-10,y+20+10+210*i);7 g0 @7 B+ ?' V- \- @" G- f6 N
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    # P% d+ u& Q, Qfor(j=0;j<num-1;j++)
    3 `( s: Z% j) T) v" H, {# H4 w* `{6 H# i  }5 F: ~; X! U* w- ?1 O
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    * a5 e$ B3 z* `3 ?line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    6 x) `6 R+ ~7 l( rline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    6 J: ^& S' U" H1 I9 d; }) y}9 A: k( c0 P+ s6 P# I
    }8 N2 Y" |- Q+ F7 a/ @; A. n
    }9 }0 y4 Y% Y; Y6 g$ o$ j0 _
    7 Z) |. B9 O3 w
    8 k9 O1 }( h+ M% J
    return 0;
    2 ]5 `2 R. ?2 D0 a& U}! O: {; ~/ ^7 U) n5 t, C; @
    int drawPerformance_PF(int x,int y,int memorry,int com,int wai,int cha)) Q8 W- l& k6 I: l; f+ ?$ N: X
    {! G$ {, o1 D4 q* h" q, h
    static int info[11][3],num=0;; @7 h1 W6 j, ?4 l7 p+ [
    int i=0,j=0,pos[10][3][2];
    " f" Z) E& s% }  z5 |4 @float temp,t;
    ! r4 W9 L1 m* [. ninfo[num][0] = com;
    $ g8 r5 D" B( n" B0 s" l" finfo[num][1] = wai;5 Q* i% A' W0 {( U: X" H
    info[num++][2] = cha;, _) n  w6 s$ e, _& I
    if(num>10)  //存储10个点) b7 T- X4 d, k
    {% Z& r0 J5 u8 s6 G7 U
    for(i=0 ;i<10;i++)) Y& p, `. K$ v
    {
    ; ~* ?' Y8 W5 G% linfo[0] = info[i+1][0];
    5 k% y& N) ]7 [info[1] = info[i+1][1];3 N. N% n! R5 Z8 J/ |6 c, G# k
    info[2] = info[i+1][2];
    * }4 y9 B$ v9 \* ]* W; i}( o- q' E9 Z9 b2 B1 H- M- x
    num--;7 Y& [) K/ \1 u! M# U3 }4 q7 f" t
    }6 S/ D/ U/ S  @! r2 F% @% A& E
    if(FLAG_show==0)
    ! r, W* T3 g! n: Xreturn 0;
    " w# o! T, \( w: E" e1 pfor(i=0; i<num; i++)6 W+ a: M) o- v% T8 `5 s
    {
    , Q" ?' A& B" J& C( ^1 W& O1 M! L% ot = (float)info[0];+ M# A7 G( `2 |, q* r( a7 H
    temp = (t/101)*90;
    / y* |$ X" n/ z: f* v* S1 \pos[0][0] = (10-num+i)*25+x+100;. s8 B. }7 S1 q, m$ E4 D# B
    pos[0][1] = y+110-(int)temp;% t: Q" F3 W3 G- h1 ]5 L" T
    t = (float)info[1];
    $ ?, j' ~" B/ v, h2 w/ @temp = (t/101)*90;5 p+ C! ]4 ~: J- L( U! r
    pos[1][0] = (10-num+i)*25+x+100;( ?+ T- R& |0 |7 S" ~
    pos[1][1] = y+210-(int)temp;! N0 E& A' {) U1 F1 A1 {( @* e" O' g( f9 M( [
    t = (float)info[2];
      r0 w* g' ?$ f( q7 @6 t; Z: S' @temp = (float)(t/101)*90;$ b& L3 z, ]& X4 y0 h! o. ^1 G
    pos[2][0] = (10-num+i)*25+x+100;* D+ ^: O+ w5 K
    pos[2][1] = y+310-(int)temp;% p/ d% w6 x' a* {7 R. t
    }
    1 y% T! G: S; H3 \* ~% jif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)- i$ `1 o5 b7 Z  s2 h7 f- Q" t" ~
    {1 z1 Z5 H) O! B+ k9 u0 n" ~
    clearrectangle(x,y,x+400,y+315);
    4 e. E0 ]: C8 h% xsettextstyle(20, 10, _T("楷体"));
    $ V" t5 m. O0 prectangle(x,y,x+400,y+325);
    4 P, b/ X* @  a; Q* _& b4 F& g. R& `outtextxy(x+40,y+10,"CPU");       //画柱状图
    6 n3 ~  I8 J" u+ W# |6 @, iouttextxy(x+45,y+10+100,"IO");& G1 K3 P1 V. N% O1 P( s" g" @- f
    outtextxy(x+40-15,y+10+200,"change");" P+ h6 g4 A& L
    rectangle(x+35,y+30,x+75,y+110);
    1 {4 M% B: C8 [! R$ g5 brectangle(x+35,y+130,x+75,y+210);
    . p( x) ~* J9 Frectangle(x+35,y+230,x+75,y+310);0 w. o; z$ R, f. ]2 \  y. o
    outtextxy(x+180,y+310,"PF");8 e' Z& k/ p8 _# [5 i
    t = (float)com;6 x6 I) d! c; b; _' U
    temp=(t/101)*80;# @2 m* U, u9 {* j. O; R3 b
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);$ s. a4 K: q( M; s
    t = (float)wai;1 G: \  w4 E" R, u' b" S8 n" v5 m
    temp=(t/101)*80;1 [: t& R, Y- q0 z
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);0 L; L1 v" e$ o% X' W9 s/ j
    t = (float)cha;
      J- e  f4 U  R% mtemp=(t/101)*80;# ]) r% O) c4 B( X8 e/ l
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    - M' [* z3 A6 A/ I7 u1 Dfor(i=0; i<3; i++)   //画坐标   high=90,length=250
    6 R1 U$ U2 U! {{3 M. `1 P5 I% z: J4 Y5 I  l
    line(x+100,y+110+100*i,x+350,y+110+100*i);+ S- L: Q( w% ]' S5 w  |
    line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);% Q4 }- B- X' G4 ]2 X6 p
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);
    ' L3 W; {' H5 O% ^* u
    0 J0 \( }5 [$ {% s& ]0 V, k0 fline(x+100,y+110+100*i,x+100,y+20+100*i);' A6 }: _1 U  N, Q
    line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);7 e( ^+ _0 y$ z: P* R! W7 O$ j
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);: n( U' G) M) _) S7 w$ U0 O5 l  n
    for(j=0;j<num-1;j++)
    8 R: v$ H# C5 k0 T{
    " S. p, A5 H3 c8 k5 \line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);7 Q+ Q1 `+ x/ T% C% T: S0 ^
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);4 e( m- V7 o% {9 b& h6 Q$ C: D7 q7 W
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    ! ~! _2 Q# ?0 B}; ~& L- S, x3 e* J
    }7 V/ ^  d- s' S7 m  s
    }
    ' E+ I. W+ `, X, ^% F, z+ nelse if(FLAG_PF==1)6 X1 y$ f0 A! V8 Z
    {  ^5 ?3 a% v% b. e0 D5 M) ?7 Q
    x=0,y=0;
    9 p/ n5 R) M/ L3 `. f0 @for(i=0; i<num; i++)
    ; g9 L0 m2 J8 n- R6 w" g! d0 N, i{+ l3 H9 M  x! K% a; n
    t = (float)info[0];
    - C- g9 n0 u# ~7 T( ?( P! `9 Ctemp = (t/101)*180;
    ) i3 w0 z( \' p7 Zpos[0][0] = (10-num+i)*50+x+650;5 s. D2 g. _" b4 a+ j5 Q8 H7 q
    pos[0][1] = y+210-(int)temp;/ T2 b8 c. M/ A" C; n
    t = (float)info[1];
    5 ]6 J& p1 N( b9 o, @: stemp = (t/101)*180;
    - z# F( S3 L% Opos[1][0] = (10-num+i)*50+x+650;
    4 k3 B3 P$ L& kpos[1][1] = y+420-(int)temp;
    9 I' p- }- F- Z6 Q& M; [t = (float)info[2];
    7 f6 b! J1 X, W! Ntemp = (float)(t/101)*180;
    " _) |1 Q' P; q! M7 F" Tpos[2][0] = (10-num+i)*50+x+650;0 D0 K3 B$ E1 ^
    pos[2][1] = y+630-(int)temp;9 b$ a* I9 P9 ~
    }+ A& o/ d& v  g* l# @% E
    clearrectangle(x,y,x+1200,y+650);2 @9 G  o* L- \0 }' p  ]
    settextstyle(40, 20, _T("楷体"));
    8 c; W: d" q, y- y4 a& nouttextxy(x+50,y+50,"PF");7 a+ N, T/ ]/ p/ l: N- y7 T# o
    outtextxy(x+280,y+20,"CPU");       //画柱状图7 ~) u7 ~( n2 p
    outtextxy(x+285,y+20+200,"IO");
    1 G9 ?, ?9 ~1 G8 x1 Louttextxy(x+250,y+20+400,"change");
    & h/ m4 r3 _7 ^* J( b. n/ hrectangle(x+270,y+65,x+330,y+215);7 [( E8 ?- w3 _3 j& f! P
    rectangle(x+270,y+265,x+330,y+415);" n9 l1 F- M2 i+ E
    rectangle(x+270,y+465,x+330,y+615);, ~/ e  C2 p# l, Z% h
    outtextxy(x+290,y+620,"TT");
    9 G9 b0 A4 l; ^0 I- y2 Y8 \4 E3 bt = (float)com;: b7 [/ V2 j% z+ h9 D0 y
    temp=(t/101)*150;1 ^! I* c$ h! ~3 ~2 S  I' v
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);5 J. r$ s# e, a7 Y% p  w
    t = (float)wai;
    ) G* {5 \- j# t5 X5 ]. ^& stemp=(t/101)*150;
    / v0 C$ X) }/ f: P( i3 ^9 `fillrectangle(x+270,y+415-(int)temp,x+330,y+415);
    # G4 h( ?- S" q' _t = (float)cha;. h+ b6 [5 d9 C* z
    temp=(t/101)*150;) b% Z! C1 c+ m  Z8 i
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    ; n- D; R5 k# s- _. S& g2 V) `: `for(i=0; i<3; i++)   //画坐标   high=90,length=250
    1 O0 P% R3 x( b8 l* i6 S0 t{
    & I  U# x& Q' kline(x+650,y+210+210*i,x+1150,y+210+210*i);7 C# {) W+ t$ \4 T' d: p" Y
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    / w/ E- Y# |& Y$ J1 V2 tline(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);3 V4 P) K5 T; P7 a' V1 o% ^
    : o3 W, p9 T/ V/ O# x" y
    line(x+650,y+210+210*i,x+650,y+20+210*i);
    1 y3 ~% k# t4 J; o2 Q) zline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
    / n$ @9 u5 ]# }/ M) H4 wline(x+650,y+20+210*i,x+650+10,y+20+10+210*i);6 x% B9 E3 @! \; q. p4 y& c# F
    for(j=0;j<num-1;j++): @3 I# a" H3 m
    {* _" ^- Y; ~; d2 e
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    % X% {% x1 p0 ~line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    - z; e8 g- e4 Wline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    ; a* w' i  i& p7 Y3 J& t% Z) x}1 e6 o/ E2 s& h2 G" l* G
    }9 b  H. r0 D6 M( v
    }
    ( m" w, n6 W% \! P0 Wreturn 0;5 J! x- @) u0 d& F; U
    }: B7 c) @8 m% Y4 C8 C% p
    int drawPerformance_SJF(int x,int y,int memorry,int com,int wai,int cha)
    0 R! v% P* `+ @* X{
    : g- _0 x. `/ R' f# lstatic int info[11][3],num=0;0 B& |# t! U! Q$ |7 C$ b
    int i=0,j=0,pos[10][3][2];3 @% R5 `9 a7 f' T
    float temp,t;! k7 E' S2 G2 ~' {. t; E
    info[num][0] = com;
    2 o7 h+ ]+ `( t% F5 a- p) ?info[num][1] = wai;# A* H7 D- s( {. C% O$ X% p
    info[num++][2] = cha;
    " S' G" [/ c( ?, z: yif(num>10)  //存储10个点
    7 f0 r, }4 N" u9 Y{
    9 v3 [' P/ o* B3 C" _' ^7 h. ~0 {for(i=0 ;i<10;i++): ?& p+ Q4 x% p9 }, W# i/ E
    {
    5 _' I+ ~7 L0 k4 C  K6 Kinfo[0] = info[i+1][0];
    8 q% v. I8 m* w/ K, Ginfo[1] = info[i+1][1];
    1 v1 K( c1 }" d1 h' j2 _( xinfo[2] = info[i+1][2];
    * a/ Q' j8 g% Q* ]! U- V* A# {}1 Z8 ^& i' a) a0 v9 D) r2 n) q, z4 N
    num--;
    ' i, g8 l5 u3 N' ^4 H$ C}
      e% }3 c" f' }3 c9 F6 Hif(FLAG_show==0)
    + |+ I, o9 h. \& [  B  X, @return 0;
    - S, K+ `2 I8 j, R6 vfor(i=0; i<num; i++)
    3 w9 R* ?% c, g{% z9 u  w) h  E5 v" n6 j
    t = (float)info[0];
    & y! O+ D- U& G5 D4 _0 T. U: ?temp = (t/101)*90;" R& |* j( E% b- X# S+ l' I
    pos[0][0] = (10-num+i)*25+x+100;
    9 r) O- k- T- c: H! `9 O% mpos[0][1] = y+110-(int)temp;
    % ^, z9 U/ Q0 [" A2 q) qt = (float)info[1];
    2 @; ?! `4 Y, @5 r0 N" atemp = (t/101)*90;
    : e% F) v) D- u5 }2 ?pos[1][0] = (10-num+i)*25+x+100;* M) ?; _9 t' p+ C2 t
    pos[1][1] = y+210-(int)temp;
    0 u* u6 x0 }+ }9 w* Lt = (float)info[2];
    ; W5 F& n+ p0 _; v1 B0 k& W" }temp = (float)(t/101)*90;. L$ K. h! q: n5 i4 E( g4 h
    pos[2][0] = (10-num+i)*25+x+100;1 l0 R0 L9 n! b4 }% Y5 d+ S/ h
    pos[2][1] = y+310-(int)temp;% A5 Y* X: h3 Z- F
    }1 d' E0 ?/ S* P
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
    ) z& h% K( H9 p2 c& P/ {# \{ - U2 v. B6 B* g
    clearrectangle(x,y,x+400,y+315);
    9 j! ]" g; ?4 a/ xsettextstyle(20, 10, _T("楷体"));
    ) `: u- @6 Z' \! ^+ Qrectangle(x,y,x+400,y+325);
    4 F' h* ]# k9 ^+ Q: Aouttextxy(x+40,y+10,"CPU");       //画柱状图' W3 ~2 \1 c0 G! j5 |3 e6 K! \; }- d
    outtextxy(x+45,y+10+100,"IO");( Z7 O$ k4 f. O/ z0 S- `
    outtextxy(x+40-15,y+10+200,"change");
    * F8 H( H7 J" R& j: arectangle(x+35,y+30,x+75,y+110);
    : Z' q  |$ M/ [9 y' J$ n7 Z" m& Crectangle(x+35,y+130,x+75,y+210);9 R) q# @7 M; D) S) L
    rectangle(x+35,y+230,x+75,y+310);. T& t6 N8 Z/ {5 a
    outtextxy(x+180,y+310,"SJF");' v% ~7 @$ c3 K9 M
    t = (float)com;. ]. H2 S" Z$ p2 f) F) K5 O
    temp=(t/101)*80;
    ; `. `3 H& p/ b# G6 k7 a; O2 Afillrectangle(x+35,y+110-(int)temp,x+75,y+110);
    # m: l( D/ }& ]  b# o) Ut = (float)wai;! X4 x* e- D# o2 e1 G3 Y1 N
    temp=(t/101)*80;- w, r: N! R# g' ^" y# f
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    ( Z9 |% I: B$ T- At = (float)cha;
    " `; U6 h8 M* Ntemp=(t/101)*80;8 m7 u9 [, L. _2 o
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);% c! }  ?2 S2 D
    for(i=0; i<3; i++)   //画坐标   high=90,length=250+ h7 z3 E. G% x. r( L9 O
    {$ ~7 h% Q  g) Y% G8 {8 x# E6 o; @
    line(x+100,y+110+100*i,x+350,y+110+100*i);
    & w+ Z# N/ v/ p( u) b, X6 Wline(x+350,y+110+100*i,x+350-5,y+110-5+100*i);0 |1 G9 t5 q3 U7 i+ ^
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);
      z. T9 Z+ e. T5 S! S: j3 ?, D' v% p/ f/ Q$ r
    line(x+100,y+110+100*i,x+100,y+20+100*i);
    , I) U, X; P( K" B3 Sline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);5 H+ U' p& C3 j. |6 \) j- n7 S1 M
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
    6 X4 f1 T7 Z* c. h% q0 bfor(j=0;j<num-1;j++)
    1 Q. i8 l' V+ A' q. c5 W3 e' k{/ F$ @; C3 c% H  ~2 q- B* I0 `# y
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
      L2 k& X4 F! T6 i8 xline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    1 Z8 V7 }/ C! |8 @  A; K; T" c' Kline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    - V+ z6 N( a9 N/ o: P* I}/ X8 O; y$ j& U% g, j8 u% A
    }! h& f0 ^* H- a. Y7 m; X/ n
    }1 A5 S5 L- T7 x# s
    else if(FLAG_SJF==1)( i9 n: [0 s0 c) l! n7 u$ \5 i; J
    {+ Y7 N1 t3 I: b) @
    x=0,y=0;1 ?# G5 ~. p9 q3 L0 U7 ^7 v# z
    for(i=0; i<num; i++)( y' ?. T& r" P. ^1 G0 Y' Z0 C3 p# {( {
    {
    + Y) j5 Q5 N! }t = (float)info[0];
    & y$ W8 S' X3 }1 W% J- A/ c& Rtemp = (t/101)*180;
    % X; x% i9 Y- o& @: Upos[0][0] = (10-num+i)*50+x+650;
    0 `6 Z% q8 z- O0 t# p1 t( W/ g/ _pos[0][1] = y+210-(int)temp;
    4 H5 U8 A1 B& c% i" x. M& y) s; Yt = (float)info[1];+ {9 c8 J/ P4 M9 K  D+ r' [* L
    temp = (t/101)*180;  v. h5 u, V) T5 m' |
    pos[1][0] = (10-num+i)*50+x+650;6 g8 o2 {- P6 z4 w! T+ ]5 N
    pos[1][1] = y+420-(int)temp;; Y! N( ?/ r0 M2 @
    t = (float)info[2];
    & v3 f  y6 E0 u4 ^6 itemp = (float)(t/101)*180;$ K& G( v# d7 B2 p8 k: z
    pos[2][0] = (10-num+i)*50+x+650;
      t3 A9 J* N( gpos[2][1] = y+630-(int)temp;: N' {/ g+ I1 ^
    }
    ; `; n+ G4 R2 A) hclearrectangle(x,y,x+1200,y+650);. w4 K. Q% l) Q
    settextstyle(40, 20, _T("楷体"));0 {$ l  C: y: g1 \) K. ~4 M/ t4 ^
    outtextxy(x+50,y+50,"SJF");9 u. }$ t; l0 U+ {  ?+ S: F
    outtextxy(x+280,y+20,"CPU");       //画柱状图* J$ [  b8 W5 X$ S; f
    outtextxy(x+285,y+20+200,"IO");
    : H0 H! \7 I. `0 \3 Couttextxy(x+250,y+20+400,"change");. ~" V+ A0 g* n
    rectangle(x+270,y+65,x+330,y+215);
    . m3 B: I/ j& S5 arectangle(x+270,y+265,x+330,y+415);# D; `$ F9 S/ \) _- D
    rectangle(x+270,y+465,x+330,y+615);. p: O$ `* k4 i6 ^' \7 b
    outtextxy(x+290,y+620,"TT");
    6 b5 I+ I( q. S4 Q3 Zt = (float)com;# d. S1 L4 m" `. P2 R; z# o
    temp=(t/101)*150;" n& `+ {! X- L+ N$ o6 I/ ]6 M3 S
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);* q" Q; ?, B5 B* r3 k
    t = (float)wai;
    % V2 u) N. o% G% r: m3 j; ]temp=(t/101)*150;
    9 T) Q/ G4 Z2 r9 Hfillrectangle(x+270,y+415-(int)temp,x+330,y+415);( @' |; ?) g/ b) J/ u
    t = (float)cha;2 a: X& \- d( m0 Q& r1 r( W
    temp=(t/101)*150;! q7 c9 |8 ]0 O& F/ ^
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);7 N6 m6 G# N- S
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    / K" ~$ r+ [. G  n$ D2 }! T{  v' Y: G+ f$ f  B
    line(x+650,y+210+210*i,x+1150,y+210+210*i);
    % S! u; b9 F9 P) sline(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);  ^* `& H% c9 d- h( C0 W% q
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);( u0 @, L6 [8 J  C9 S

    # }7 h! i; V9 d! j5 pline(x+650,y+210+210*i,x+650,y+20+210*i);1 O" R/ t7 q- F2 j; ~9 ~1 k0 ?5 Y7 i9 n
    line(x+650,y+20+210*i,x+650-10,y+20+10+210*i);- w$ K8 c/ W) Z( O) ~- q0 N+ \
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    0 e' X" X# ?# y' H5 v; w8 Bfor(j=0;j<num-1;j++)3 V" o0 q- G/ y4 v+ k0 [
    {9 F( w6 X. N/ W0 r) N- ^  r
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    # M/ K# [$ r6 @6 F7 r6 y% T8 k  pline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);( w" C$ _* ~9 B1 V$ B) c
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    * P( Z# J! o- j+ m7 w}/ E+ q# \7 J! J. d+ s) V: a8 Y
    }$ t% E, q: \% r  }3 Q
    }
    4 z/ Z$ Y, d+ D, [3 ]# Areturn 0;7 U- x, b' k% r' w" Y' ?" c, x
    }0 ~" Z1 ?5 v# z& s: H5 I) y
    int High_response_ratio_dispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw). W# K& i/ g5 i! x# Q7 P( \
    {! r4 m3 q2 D0 f- n& ]
    static int compute=0,waitio=0,change=0;" ^/ |# I8 C3 E% ^, k# g
    static int computeLast=0,waitioLast=0,changeLast=0;
    % d9 i- U% I4 O+ v$ \( I, Kint i=0;
    6 X7 Q. c  Y" m, _& M! p5 E* M) |: g0 N8 Pif(draw==1)  F9 s. j6 \7 f
    {7 r' ^6 c% `9 m
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);" @4 ^$ V$ E$ j7 Z8 r
    drawPerformance_HR(400,325,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);" T( r4 N+ u3 n  d3 E
    computeLast=compute;
    9 b; r; b/ \$ H; X0 @' W9 QwaitioLast=waitio;0 A8 ?8 v6 D' O3 i, _
    changeLast=change;+ o  T. y  I, x5 l! w
    }
    3 N( O: q, @8 p) `/ g, U) @% Oif((* memory).p[0].flag==ready)
    - S9 y8 }/ x3 v; e6 |7 f(* memory).p[0].flag=computing;
    ( q7 u% c1 }! n2 r4 W) \! Qif((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)/ O* u( d* i! r& E. ]6 Q9 d
    {0 y0 i2 a* M2 K4 T  o# ]
    i=(*memory).p[0].computeNum;6 ^& W% q& t% X7 t
    if(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed
    1 {9 H+ P( v; k+ C{
    , Z; D4 ^2 u" h0 h(*memory).p[0].flag=IO_waiting;
    8 D& a* @2 v  |. T$ b3 p$ h# w3 M(*memory).p[0].computeNum--;
    7 S6 @! g6 r1 g3 wchange += exchange_IO_Compute;  Y- o+ V7 E& @# l1 ^$ Y
    compute++;5 T+ I7 L& l- z( ]! w
    }
    6 G) W. C+ t8 B2 _8 Q0 ]else
    / _/ v  I! m; D$ `$ f7 F6 P: }{' f( Q7 y  e3 J& F0 k' Q* r
    compute++;$ m# W+ `; \! E" \% x5 K: j
    }
    ) o4 F, U6 q: @, l) Q3 A}# [& t6 P- P6 U) G
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)
    : Y: s$ l1 ?8 X* C1 s{% s; F2 e2 i" \# q9 e
      l8 Q( N  H- ~2 B* O
    i=(*memory).p[0].ioNum;$ X% b+ e7 a* v, N) L- K& Q& Y( U) ?
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed
    # T1 s  t1 M; k4 o# Y+ X! {* d: ~{
      m" L" _2 V! n5 {0 }  c, q(*memory).p[0].flag=computing;6 T: R: w2 s* U( ^* |
    (*memory).p[0].ioNum--;0 Q2 u/ h7 P. _, I5 h
    change += exchange_IO_Compute;  @) L7 @" l8 l) h, r* Y& s. m
    waitio++;
    5 X' q; c6 g, H# A}  k  _) }& p) ~$ {
    else* m1 c' O' T) h  L
    {5 v9 E& ~. P; L6 M, D* N
    waitio++;5 R, R* e: B9 _; H3 P( j' |/ A2 w
    }
    1 K+ O0 |6 q- c% Q. Z' |4 y}9 n& W2 h( S/ }  ]  g
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)
    ( [( F$ \" S, |' Y6 ?3 K: z{8 u1 K+ r1 s5 u; U4 e; J. ]
    (* memory).p[0].flag=IO_waiting;$ n/ ]' h4 S, I4 \! d& N  J
    change += exchange_IO_Compute;. W: I. s; L' _0 t0 s# B* e
    }5 _- B$ s" h# z* o# t1 H1 c6 S
    else if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)! `3 C- t3 j# T2 E1 D4 j
    {9 P/ o( V! \& Z% a3 E* A9 H
    (* memory).p[0].flag=computing;" x% h" C0 u' P1 Y" W5 D( C
    change += exchange_IO_Compute;
    # X& x, b6 Y2 N: M9 g1 |}/ i/ q6 P" `$ v1 W0 n
    if((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成! t; r" |' T# p
    {5 s3 `, H2 R" w7 L
    (*save) = (PCI*)malloc(sizeof(PCI));
    . @! P6 ~5 d! d4 z; [(*save)->next = NULL;
    1 D' W  Y' k* l8 ?/ v# z* l(*save)->processID = (*memory).p[0].processID;- u# V( l$ ]5 y' r) F" [" M# w
    (*save)->comeingTime = (*memory).p[0].produceTime;
    # d# f. a. I, c  `* P) g  j(*save)->askMemory = (*memory).p[0].askMemory;+ w+ j! a2 y4 ]# {9 s# L9 V8 G3 }5 b+ f
    (*save)->compute = compute;
    : N5 z' P  E: r' ]6 j(*save)->waitio = waitio;
    " I  v  m  f+ Z' h1 Z(*save)->exchange = change;
      r; j  _: Y' ^- l0 X+ m) C(*save)->completedTime = systemClock;% n! e/ L+ L! @/ P) N1 M
    (*save)->runningTime = (*memory).p[0].runningTime;
    0 M1 k. }. s0 T$ m' C6 U- ~1 {% Y& V*spareMemory = MAX_MEMORY;         //*spareMemory + (*memory).p[0].askMemory;
    2 `& J; P; j3 Ocompute=waitio=change=0;
    7 F3 [7 L0 b7 Q3 P, W/ P' v( l$ KcomputeLast=waitioLast=changeLast=0;% I9 p/ @& ~1 ]$ e6 t9 x
    High_response_ratio_s_to_m(&(*storage),&(* memory),&(*spareMemory),1,1);
    ' t% c$ R( |6 J* U, I! xchange += exchange_process;! G, A' E( y7 e" [
    return task_completed;0 t6 u" [6 V1 F0 n* J
    }
    ! x9 q, [0 z  s5 a. @, I0 Belse
    % ]2 j  A# O4 p- J: }return task_not_completed;
    , S# L4 V% N% d, p$ O. F" {6 `}
    3 C( |; `1 r8 a6 |int High_response_ratio_s_to_m(processPool *storage,processPool* memory,int *spareMemory,int flag,int dispatch)" T8 C: D7 |) O
    {7 d5 c: }* e' d) C& K/ k
    static int waitTime[initProcessNum],i=0,j=0;
    . _$ H* \' B4 [3 `& _  B8 bstatic double HR_ratio[initProcessNum];* @* u& D/ z$ ]$ z+ {
    if(flag==0)                    //初始化数组
    / `. V4 @. f! K. ?{7 B: L3 t) D+ w7 p
    for(i=0; i<initProcessNum; i++)
    7 i! l* Z. ?) t1 E! V$ A$ t{6 V4 A, u/ A: B5 q0 I- w
    waitTime=0;* W2 q  n) V' q1 d
    HR_ratio=1;7 G$ v6 r$ Y/ N1 R+ R
    }
    0 Y6 {8 K0 B, c, S# R! L1 t}" B0 b0 c( c8 n: T6 p. @: s/ z
    for(i=0; i<(*storage).proNum; i++)  //等待时间增加,重置响应比! C7 r' _& V' e; s8 \! u
    {
    / }. a& N! B* k% H% D3 c( n: H0 ZwaitTime++;
    3 v1 T; p$ R( l% l7 ~HR_ratio = (waitTime+(*storage).p.computeTime+(*storage).p.ioTime)/((*storage).p.computeTime+(*storage).p.ioTime);* H7 [+ T' S( u! q2 S2 X
    if(HR_ratio > HR_ratio[j])
    0 m9 k# Y+ i6 r! c4 }0 Sj = i;
    0 Q/ ^3 d3 }# ~* Z3 W, ?}
    $ J* }. Z, y; m8 ~5 Kif(dispatch==1)                    //需要调度一个进程到内存中执行# V: h* ~! h& ?+ y# Z
    {, {* K( I! F8 S, o( O! T' J
    if((*storage).p[j].askMemory < *spareMemory)2 {( l  @" n: ~; O+ j  |# H+ X" ~
    {
    - K/ W$ V* z% @(*memory).p[0].askMemory = (*storage).p[j].askMemory;
    5 B$ p9 m$ f- j" r$ f4 }; c(*memory).p[0].comeingTime = (*storage).p[j].comeingTime;- g2 }; m% S, n$ n* X4 i' }& t
    (*memory).p[0].computeNum = (*storage).p[j].computeNum;
    - p, w$ d( n( v* t- E(*memory).p[0].ioNum = (*storage).p[j].ioNum;' s* F' Y+ ^* O' m7 N1 O
    (*memory).p[0].processID = (*storage).p[j].processID;
    ) E8 F8 E" p7 O7 y(*memory).p[0].flag = (*storage).p[j].flag;
    + k' c5 G  \% v$ f  c& n9 p0 ^! o(*memory).p[0].ioTime = (*storage).p[j].ioTime;5 K# w, Z& R# S- D
    (*memory).p[0].computeTime = (*storage).p[j].computeTime;
    # ]) w) `; z2 H' z+ i(*memory).p[0].runningTime = systemClock;
      M4 v6 F6 `6 c( \(*memory).p[0].produceTime = (*storage).p[j].produceTime;5 B. U( r' i2 x4 ?% r& L& l
    for(i=0; i<(*memory).p[0].ioNum; i++)
    5 R+ p: O* h3 K6 F* U& R% k(*memory).p[0].ioClock = (*storage).p[j].ioClock;
    " e0 D, w- }% n6 h  dfor(i=0; i<(*memory).p[0].computeNum; i++)& \# ~: T, u0 X
    (*memory).p[0].computeClock = (*storage).p[j].computeClock;/ P6 u7 K$ ^# M% S2 H1 ~) a; M' }
    (*memory).proNum=1;* G1 O5 T( i. x2 q4 X7 f
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;
    $ V* J% C, h% bproduce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程3 w  }" U4 z9 k
    (*storage).p[j].produceTime = systemClock;( h9 O+ b0 p, j
    MAX_COMING_TIME = (*storage).p[j].comeingTime;9 Y2 S" E* `9 v  M4 |9 w# ^6 l) X4 B, ?
    waitTime[j] = 0;
    % s; M7 G) B9 WHR_ratio[j] = 1;: R: M6 G- o8 c2 s2 b  E
    }
      N7 w# k$ K0 G4 Jelse5 G5 q) _# c5 s2 P. h; L( [
    {' F* Q% f2 \6 M/ N
    printf("A process ask for a memory overed the system capacity\n ");
    " P/ p5 V4 t8 s% m5 x7 C8 U4 p6 Jexit(1);
    1 k/ F/ j# Y' P}2 r$ b6 t: {- Z8 ^
    }0 v$ A) x* [7 }- ^  u: a
    return 0;
    7 _$ r/ f9 w/ D$ s8 c}' F- l; K- L5 L* y+ U) V' q
    int PriorityDispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)( M$ T+ \9 y$ p" q9 ~( N! o7 i
    {
    / t: y" |' \' f6 y+ u  p4 E6 Kstatic int compute=0,waitio=0,change=0;1 v$ z3 G( S; _1 V8 s$ Q  K
    static int computeLast=0,waitioLast=0,changeLast=0;
    ! ^+ p' R) j( W- V/ ]% |; \0 y* eint i=0;; `! H/ Y$ a( Z. p
    if(draw==1): w6 |) q* f. z2 F# c# K" O
    {7 l, Y& H' d0 y- D' K  [
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);2 ~3 s& H/ x5 R: l6 ^0 {
    drawPerformance_PF(800,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    $ a- l. o' b! }
    ' Q2 t: _  S# T/ Y% V( r* Z, H0 z* P% |2 x
    computeLast=compute;+ @: S( P6 X# E0 a( P8 e
    waitioLast=waitio;2 y, P* d$ a0 [! [5 e+ }
    changeLast=change;% G) L: G4 g! p  [! G% M+ ?- \
    }
    . c4 e' |6 m" k1 z# b) h1 Q5 Zif((* memory).p[0].flag==ready)
    5 I: S2 h/ `3 t  e1 u8 @(* memory).p[0].flag=computing;
    / Q$ N$ ^+ O9 @+ f- jif((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)
    ' L8 A- N: o: _+ E2 Y' s{+ o+ u8 d6 z0 j* U  ?
    i=(*memory).p[0].computeNum;  g7 M9 b: v! W( m8 k: D8 d- }2 B
    if(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed
    1 o0 k3 P9 M" o- L" I. h{
    5 T* l, c3 V% ^5 v" `; ~9 Q(*memory).p[0].flag=IO_waiting;; m4 r0 Z- }- E( H1 i! B
    (*memory).p[0].computeNum--;
    7 N4 a/ @8 n; }0 {' Gchange += exchange_IO_Compute;
    5 r. J: H4 A- C0 r. {3 z. ^7 Q5 R, \compute++;
    8 {' v, q$ E5 i* o2 D6 l3 ?, v) p( T, g}
    + k! Z4 B2 [3 ^( h" X" Belse
      y5 z" c# A$ v7 R- ^4 @5 e1 _{
    & H7 N4 C; I- m# I; M7 p; l- vcompute++;
    ' ^; P& \# V+ w# s! l}
    9 j) n7 J: h. T2 E+ K+ H9 f}, G0 y2 u4 F9 G7 k2 p: J
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)
    / f, f! U6 d$ Q& ?% B{; h* z' z4 v$ [: `# e

    : l: d$ H" q) ^$ n( li=(*memory).p[0].ioNum;7 c/ z5 j( x4 [7 m- o* Y* f) t: L
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed3 l$ e( Y, S: f9 w
    {: j; W7 T4 ]# V3 B- X- F2 i
    (*memory).p[0].flag=computing;" R; h/ r7 H7 T5 y
    (*memory).p[0].ioNum--;
    . b2 E4 B8 d2 F9 Z% Vchange += exchange_IO_Compute;" @4 m! i$ I+ g( T/ {- a
    waitio++;- A, K( }! J- p2 Z  Y7 _
    }( T4 H5 _- j% H( u2 y
    else( n( ?6 `: Y# j7 y7 s' N
    {
    $ e! t$ a( k1 h6 T  a# Iwaitio++;' j6 C' m2 |' M& o% x$ E- _# v* j, J
    }; s, k) }" ~% v: Z, A- r
    }
    1 Q& v  Q! G) S2 t; @; Selse if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)7 s) N' y3 }9 p0 Y! d% {0 {
    {
    ) g" }+ g; I2 }5 v(* memory).p[0].flag=IO_waiting;
    : I) M1 t) T8 S5 {% b' E8 zchange += exchange_IO_Compute;5 X8 r8 P% ^/ D  X" f
    }, B; C) y5 L3 h' `
    else if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)& B7 f# Y0 g3 U2 {
    {  O( H1 W% n' K0 ~$ k
    (* memory).p[0].flag=computing;5 J5 ]0 Q) \+ `. N  @3 l
    change += exchange_IO_Compute;
    2 H6 N# `1 i% o& p) }}
    ( p0 v! J$ }! N6 w" ~if((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成: S$ m% D- x& z, j- f
    {3 W$ E$ m# _7 |8 ^$ A1 h
    (*save) = (PCI*)malloc(sizeof(PCI));5 }, H( |8 C2 b: E4 i( y! R8 o
    (*save)->next = NULL;
    & p+ n* ?# _, g6 j5 S2 [/ Z! h(*save)->processID = (*memory).p[0].processID;
    3 R5 k; ^6 N9 ?(*save)->comeingTime = (*memory).p[0].produceTime;' ?7 c! C$ j9 a& u) x- J1 G& s
    (*save)->askMemory = (*memory).p[0].askMemory;
    0 i; T3 C" C1 {$ L, V* Z; y(*save)->compute = compute;- I" ?( O1 Z% Q. I8 m$ Q5 C/ T
    (*save)->waitio = waitio;
    $ G- w- p; L! H' j+ r; C" }(*save)->exchange = change;
    & B! {( h4 H- Q(*save)->completedTime = systemClock;
    " g5 }& w5 z. w8 I" `(*save)->runningTime = (*memory).p[0].runningTime;
      X: n% u1 v1 I; O. q+ W*spareMemory = MAX_MEMORY;      //*spareMemory + (*memory).p[0].askMemory;
    ! L4 c/ ~/ |: _0 t, F2 h  A5 ~compute=waitio=change=0;
    : R6 b3 T1 F' ?( `! Z8 scomputeLast=waitioLast=changeLast=0;0 s5 T6 y0 M& X' b6 s% j
    Priority_storage_to_memory(&(*storage),&(* memory),&(*spareMemory));
    ) R! @+ G! n9 o% nchange += exchange_process;$ y, {9 z) T$ D" H  y
    return task_completed;
    & E5 e6 n. a2 n% a) W# l' t}
    0 Z# Q& |0 p3 M. jelse# T3 |, k( E* X* L6 r5 Q/ B
    return task_not_completed;
    ! ~; G& [6 c; ]5 n4 z}
    / ]2 P+ c% t/ `: Aint Priority_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory)
    ' @# t8 m7 _% V" J2 H{+ u" b; H$ z2 f' @* c+ m/ Y* \
    int priorityNum[initProcessNum],i=0,j=0;( \& [2 q1 }+ q& S& Q: \
    double temp=0;- C  z1 [  n6 Y( {" L' l  R2 L
    for(i=0; i<(*storage).proNum; i++)    // setting priority to each process, T% g5 A. Z0 z# r
    {: y3 u6 q/ s# i2 ]
    temp = (*storage).p.computeTime/(*storage).p.ioTime;& t; C4 d3 n7 i, q4 f- k3 O8 `
    if(temp > 0.8)+ n, x7 A; q- `0 b) V- Y
    priorityNum = 6;# o3 }7 I+ O: W
    else if(temp > 0.7)
    1 O+ k& U. y* w  }0 P, bpriorityNum = 5;1 A2 a& _* f8 j4 ?( |6 x2 S
    else if(temp > 0.6)
    6 M$ G) l8 w+ r* b1 U3 _% opriorityNum = 4;2 F5 R: ^1 W  v  S% X: I0 D
    else if(temp > 0.5)
    " b- L$ x9 m( M# n2 zpriorityNum = 3;6 q+ l8 t% q! y% @
    else if(temp > 0.4)
    ) Z/ J! e. t4 V7 tpriorityNum = 2;
    3 z$ r: Y' w9 S( Oelse
    9 `. Y' K) P+ `( \6 x& QpriorityNum = 1;) j" G9 W8 @; h' {
    if(priorityNum[j] < priorityNum)) u, E* J; t% q' ^, I6 s0 ~
    j = i;! \2 y( [0 v, w. X  Z* E
    }
    % B6 o" S! Y2 K. B" ^- D8 }" n6 Wif((*storage).p[j].askMemory < *spareMemory)
    4 w. J' w/ C9 {. b. a( t3 Y{
    " U; m: ~! q. _# Y(*memory).p[0].askMemory = (*storage).p[j].askMemory;
    & ]1 s, P' p- \" |7 \(*memory).p[0].comeingTime = (*storage).p[j].comeingTime;
    6 D) a. x+ B9 ~  n* D; g# M2 ~(*memory).p[0].computeNum = (*storage).p[j].computeNum;
    - @; Q0 P4 i! H1 h  j$ e(*memory).p[0].ioNum = (*storage).p[j].ioNum;; f. k; Y- r7 }
    (*memory).p[0].processID = (*storage).p[j].processID;
    7 t  n  K3 e5 o' @- {4 Y& U0 f' u(*memory).p[0].flag = (*storage).p[j].flag;
    2 K; t7 P( F6 T# X8 n0 h(*memory).p[0].ioTime = (*storage).p[j].ioTime;  M) N" L, D9 s) A' h/ p
    (*memory).p[0].computeTime = (*storage).p[j].computeTime;9 O4 q  g, l0 l
    (*memory).p[0].runningTime = systemClock;
    + K# k) }. ~% _* t1 o$ G3 C(*memory).p[0].produceTime = (*storage).p[j].produceTime;  f6 f5 K! H8 p/ V  L2 X* ~$ `3 Q
    for(i=0; i<(*memory).p[0].ioNum; i++)' l, r# h1 ~3 _# i/ V2 o+ ~0 I
    (*memory).p[0].ioClock = (*storage).p[j].ioClock;' B) R8 {, ?- X' F
    for(i=0; i<(*memory).p[0].computeNum; i++), S0 [1 e4 h( V" A! u5 j6 c" y
    (*memory).p[0].computeClock = (*storage).p[j].computeClock;/ z8 e# m$ E) z" f/ S4 y
    (*memory).proNum=1;
    : x0 I/ U! t# N( S# a& c*spareMemory = *spareMemory - (*memory).p[j].askMemory;
    3 y& f, l% X9 l5 L# P4 [" l, Hproduce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程5 I& j0 N! R+ H1 r5 x7 E$ k# p
    MAX_COMING_TIME = (*storage).p[j].comeingTime;
    5 L& N+ R6 T7 e. {. M) V* e}
    ; i( O; A2 s5 `$ \! Jelse
    7 ]. U" b- B, Z" J4 B7 i4 r{
    1 k" y8 G* S+ l8 z3 i' C* h/ sprintf("A process ask for a memory overed the system capacity\n ");' o9 G9 B* V" a# ~1 s
    exit(1);
    4 P" @" [+ C: w8 ^& m  Y4 S}
    8 y8 d& c" p; \+ r- areturn 0;3 v3 W. i  x6 R+ Z
    }5 n. U4 I. R( I6 _: C$ ^
    int ShortJobFirst(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)
    / P$ Z0 @1 H  A* Q0 \* `" U{5 Y' _5 N5 h0 B3 N  j# `4 [0 L1 v
    static int compute=0,waitio=0,change=0;
    8 e4 H* X& z( E- y4 Pstatic int computeLast=0,waitioLast=0,changeLast=0;# {; V' M; E, f' M
    int i=0;
      R. f( H4 E9 bif(draw==1), E5 D+ \! w8 J9 D1 y' `" }
    {
    3 W% D! E9 A/ E  C) U0 e//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);+ c( d9 M' c8 K; N" S& k2 D
    drawPerformance_SJF(0,325,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    6 X- P! }; O4 n7 u" Q- _1 w3 E& L# v: b1 z' Q
    ! `% k2 q# f: i3 ^& ?0 L$ O; s
    computeLast=compute;( A5 B- J2 k& W: M8 E7 b
    waitioLast=waitio;# n# |: s+ S4 }' x1 |% L- B  f8 l
    changeLast=change;7 N$ k$ n  y, x) f2 ?0 @
    }7 I+ D3 q* X$ y. d2 Y( S8 i# \. U
    if((* memory).p[0].flag==ready)! ?. B- G: I  F& ~3 @8 Y! x
    (* memory).p[0].flag=computing;
    6 f# L4 ~2 V1 M; h1 L9 \0 @8 j) Pif((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)
    & B+ w; D! q  x{6 Z- `2 a6 h6 h5 ~/ H) z
    i=(*memory).p[0].computeNum;
    - h5 O' E$ p7 e% Y0 H4 a3 T; Lif(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed
    0 H3 O& e" S! S1 N2 y! p{
    0 M$ U! I8 I# Y# i+ X' ^0 K; e(*memory).p[0].flag=IO_waiting;
    6 Y/ M7 C- t- x(*memory).p[0].computeNum--;
    , L( ^2 q. T2 {0 x6 L& n; L# B! _/ cchange += exchange_IO_Compute;( b, a+ f. C1 M' M+ B
    compute++;
    4 Y3 |: T/ C" \6 u}
    . r" _3 l8 H+ t- relse7 h% k- r* W9 E  u9 g
    {7 {+ x* `$ W+ s+ K
    compute++;  g/ ~; o' |9 e; `  z) Y
    }
    & F+ t$ ~+ d7 f# r7 ^% y- H& L9 z; k}7 G; O5 d, Y- Z( {0 y
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)2 v/ D# J: o7 v- k0 V) ]
    {3 [/ g+ N, Z# w

    * q# [9 W. l% {$ D- l2 D! Oi=(*memory).p[0].ioNum;% \% q- w: x/ L  C2 o7 C6 p
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed
    % [8 W! G# q' I4 s) Q& C' w2 m2 }* V{8 S8 t, C1 V. k
    (*memory).p[0].flag=computing;/ h/ E$ A6 n- E
    (*memory).p[0].ioNum--;
    $ U6 n; T: u0 K* ^change += exchange_IO_Compute;
    , K% W5 \) R% V9 t6 d! a: twaitio++;" D* O3 g8 X3 m
    }
    ' ~' r* N: V2 U* t( ?else) N) X8 y( a8 N3 w" e' O5 B
    {: R% `* {- Q& Q; ?4 j
    waitio++;& C: {1 b8 }. _( g6 Z5 V  d
    }( P1 j7 s1 ~) n1 ^
    }- k4 ]! ?, Z9 ~: f* q8 H- U! R
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)( J1 o# V! |2 l- B, e! Y
    {4 x( F5 v  F" _. i3 ~, g+ w
    (* memory).p[0].flag=IO_waiting;
    - \; l" K! h+ xchange += exchange_IO_Compute;
    , z+ R$ Z% ~, Z2 r7 Q& B* F}6 b$ U! o0 \  k# }
    else if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)6 F" m3 b4 Z4 W" C9 I, f; ]' l
    {3 [+ ?' }2 Y# ^) f6 }# s
    (* memory).p[0].flag=computing;
    & M# i! a5 U/ g+ [7 G4 ]8 X% rchange += exchange_IO_Compute;
    5 U& G5 V& K- g0 C$ d' H}
    % m; e& [6 d  ~& O% V; i; U- M, rif((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成: o4 v$ j2 M- [6 @. {6 r1 V
    {
    + W' V" E3 k/ z" m& y: Y( n, o+ q(*save) = (PCI*)malloc(sizeof(PCI));% q0 T& B- K+ _- Q
    (*save)->next = NULL;% P/ E0 u% A$ \* o4 r6 g/ F. _
    (*save)->processID = (*memory).p[0].processID;
    , ^1 _0 x% v* U6 @& `(*save)->comeingTime = (*memory).p[0].produceTime;" P) [0 H5 W+ |9 D$ j' z8 l! W
    (*save)->askMemory = (*memory).p[0].askMemory;
    $ ?0 ?- g, s6 S6 ]( R1 o% C/ O(*save)->compute = compute;+ {! Q1 m4 [: m; z8 x! i
    (*save)->waitio = waitio;% Z, A4 t: p8 h( Q
    (*save)->exchange = change;
    8 d& }7 h, d6 s: _, w(*save)->completedTime = systemClock;- r4 I) g7 Z# h
    (*save)->runningTime = (*memory).p[0].runningTime;
    4 a) Z' j. M$ i# w3 B*spareMemory = MAX_MEMORY;//*spareMemory + (*memory).p[0].askMemory;
    / P! H+ w; V; e0 Xcompute=waitio=change=0;
    3 Y1 t% I* v; {, {computeLast=waitioLast=changeLast=0;
    : X( d& j9 N5 _  J* }SJF_storage_to_memory(&(*storage),&(* memory),&(*spareMemory));
    ' S4 B; Z# l; a5 tchange += exchange_process;
    / s2 P9 {5 V2 b% b% Qreturn task_completed;; ]. n% }) p* e6 Q3 M
    }
    : [" x5 V* }& S: H/ e( qelse
    - c( t# Q& Y" S: j" }) Dreturn task_not_completed;" y0 d8 @6 P. S- |
    }
    4 W6 }: X; z1 C8 @int SJF_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory)
    ) F; Z- k) c' W{% I8 R9 P, R: i; x. V* y$ D: Q0 O+ j
    int i=0,j=0;
    ! F% C% }% O' h3 }% nfor(i=1; i<(*storage).proNum; i++): t# V$ `5 i8 q$ M& M
    {
    1 Y/ X9 N# `* I  J% Wif(((*storage).p.computeTime+(*storage).p.ioTime)<((*storage).p[j].computeTime+(*storage).p[j].ioTime))
    % x$ y; }9 d' o+ Q) v; xj=i;" i) {6 E9 [& l( F' \. g4 c
    }
    4 q+ O2 @2 {. j! P7 {. r1 u- vif((*storage).p[j].askMemory > *spareMemory)
    ; U% r/ C. X& c2 a4 l{6 t) b0 Y( }/ l& R3 ^3 y0 p
    printf("The memory asked is overflowed than the system memory.\n");' x% O1 D& z% `" A0 Q
    exit(0);
    8 s$ A- J- K  V( g}
    , C; O" w/ F0 R. x! w, {6 x3 k' ^else" ^  c5 N1 L% q" R4 i% I9 W
    {
      d& R6 f8 k7 A+ q- D( e(*memory).p[0].askMemory = (*storage).p[j].askMemory;
    & P. s+ r  K% {(*memory).p[0].comeingTime = (*storage).p[j].comeingTime;3 x! o2 G8 Q# N
    (*memory).p[0].computeNum = (*storage).p[j].computeNum;
    * n& l. f$ f1 Q0 M, b8 a(*memory).p[0].ioNum = (*storage).p[j].ioNum;
    7 M( p0 s% b% }2 w, L5 ?( ?/ p(*memory).p[0].processID = (*storage).p[j].processID;/ M/ g- M) j4 J$ V; b$ |0 o. e: i
    (*memory).p[0].flag = (*storage).p[j].flag;8 [- w) S8 z& `. N5 m' S' T" {
    (*memory).p[0].ioTime = (*storage).p[j].ioTime;! @8 ]  ]* y2 A- d$ y( D! G
    (*memory).p[0].computeTime = (*storage).p[j].computeTime;
    ; {6 r* }5 R; N: O(*memory).p[0].runningTime = systemClock;0 v$ A! }" N; l# E* }
    (*memory).p[0].produceTime = (*storage).p[j].produceTime;+ I4 P! ^1 u9 P: E
    for(i=0; i<(*memory).p[0].ioNum; i++)' O- S' h: j$ O0 @
    (*memory).p[0].ioClock = (*storage).p[j].ioClock;
    8 b# K, I) b$ j0 Ffor(i=0; i<(*memory).p[0].computeNum; i++)7 B. y) u% V+ ^) y, U+ I
    (*memory).p[0].computeClock = (*storage).p[j].computeClock;
    5 B2 z  I3 \1 V+ Y+ |( X  P(*memory).proNum=1;
    9 y- {  C/ w3 t" p) k" K*spareMemory = *spareMemory - (*memory).p[j].askMemory;$ q  G2 t3 T2 K2 D
    produce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程1 _1 [8 C$ v( k) l( L$ X& }
    MAX_COMING_TIME = (*storage).p[j].comeingTime;6 O% L& n6 g1 E6 P" y
    }- v8 m  Y$ ?0 w; u: n4 _
    return 0;
    # I2 I9 }7 J5 L# s' N) E+ c( d}
    # R# t8 S: r3 a* R3 ~int TimeTurning(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)1 f+ H$ r, P; z6 T9 h- _2 ^
    {( _6 H  ?) A% i( n
    static int compute=0,waitio=0,change=0,clockSegment=100,poi=0;3 T7 S3 }4 V5 L3 @; l
    static int computeLast=0,waitioLast=0,changeLast=0;
    " B9 [! s/ C( H$ [( kint i=0,j=0,k=0;& E1 }" K8 j: ?
    if((*memory).proNum<=0)  m1 F; T6 U. l
    TimeTurining_storage_to_memory(&(*storage),&(*memory),&(*spareMemory),-1);+ ]9 V* a) G  T3 y9 S  |, r) U- ^
    if(draw==1)
    ; n) f: c. ^) W6 V{
    4 g2 M0 x7 ^8 C0 B% T, v//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    7 @9 r1 c+ D) ?7 EdrawPerformance_TT(400,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);6 g4 k8 W* v* D/ a' E+ ]* V! G+ ]& F

    / o9 A7 ^+ d- r, _! J' G4 Z" Q, e4 N( T; t0 R
    computeLast=compute;7 W' b) o7 M4 i# T% \0 |# u
    waitioLast=waitio;
    % W4 [" B& k$ P- q" f4 echangeLast=change;
    , X' i3 H7 W; s; c2 U+ z! o' n}
    + J% ~) c: `! i6 _if(poi>=(* memory).proNum). J6 x- c( P, P* E: a$ S) y
    poi = 0;1 o; d+ J1 T+ E! H6 q" }0 N
    if((* memory).p[poi].flag==ready)6 E- g/ B) h' u/ Z' x
    (* memory).p[poi].flag=computing;3 |. T0 V3 l" n# g! V
    if((* memory).p[poi].computeNum>0&&(* memory).p[poi].flag==computing)" L, c% }; |$ D( P( t6 |8 U7 c9 A( E
    {5 f0 _* V' g3 p& w
    i=(*memory).p[poi].computeNum;
    ' a- u+ k. U0 Z0 a$ Q1 u6 jif(--((*memory).p[poi].computeClock[i-1])<=0)// one compute tase is completed
    * U$ Q" b1 h% [{
    ' z% T9 e, z/ X" W(*memory).p[poi].flag=IO_waiting;2 x# l1 L% Z% P* T: d* C" @5 E/ m
    (*memory).p[poi].computeNum--;7 Z) @8 @3 g- Z" p  V
    change += exchange_IO_Compute;
    ) b2 x0 T- t1 [" p9 ?compute++;5 z2 k( V. K* A# ?1 h
    }
    1 U6 c" K  p$ Y; o; r) pelse; _  G& ~  e' n0 a3 I0 W: R
    {  ?2 ^  @" x; L# [" H3 r. O, ]
    compute++;
    ! _/ O1 F1 i0 q  }6 t+ A# o! e}& [- j7 B' ?- [" F" i
    }
    ) m  z$ v3 |" o! @3 S! ~, lelse if((* memory).p[poi].ioNum>0&&(* memory).p[poi].flag==IO_waiting)
    * n% W; a. O" ?{- D; Z) ]8 j) O- z) u# a$ J/ Q
    % P' H9 c- o5 {6 u; i# U
    i=(*memory).p[poi].ioNum;
    $ J) `- W, Q  j" X/ q9 }if(--((*memory).p[poi].ioClock[i-1])<=0)// one io tase is completed' g9 j/ @! g0 ^+ h
    {! \7 z9 y) [, U- B2 c3 H5 G
    (*memory).p[poi].flag=computing;9 L  w0 }, V3 y! D, E* w$ @
    (*memory).p[poi].ioNum--;" _3 o. T( H) x; o/ I. B* @4 ^9 O
    change += exchange_IO_Compute;
    " `4 f$ |! `! L; n; ^5 fwaitio++;
    0 U: O! H: R4 ]: _6 E1 N% j* Q3 k}
    $ e4 P, _/ c( [! q+ @else+ u- V# J$ |" Q% A
    {
    # v5 P6 e% l. Z0 D. p: M5 Mwaitio++;* Z+ r$ o# h) t+ u! o
    }
    ( k3 F( L) I) l2 z$ b}1 A! p2 a7 p; r' d
    else if((* memory).p[poi].ioNum>0&&(* memory).p[poi].flag==computing)
    $ q: q, E$ q7 k2 x9 e{
    # z. g9 m" E( C% e' e1 L8 e* f(* memory).p[poi].flag=IO_waiting;2 Z0 v: u+ ~0 G% s) t
    change += exchange_IO_Compute;7 C5 W4 y7 R! y/ H
    }
    / e( ~; u% D! E# Q) O, _5 telse if((* memory).p[poi].computeNum>0&&(* memory).p[poi].flag==IO_waiting)
    $ b5 V6 e* W1 x: ]5 a8 [{
    : o8 [+ ?6 ^0 ^" ~- x, o" i* I(* memory).p[poi].flag=computing;8 X/ j5 }0 n8 X" d& _6 C$ M- s. ~
    change += exchange_IO_Compute;
    * C. H2 W" w3 o, d! A& A}* D  ~3 R5 p) N" J6 s9 a
    for(i=0; i<(*memory).proNum; i++)  //其他等待io的进程可以并行推进
    1 C: t* J  n: [" M2 o2 ?0 b% @3 F{
    , L1 `5 p7 ]5 S* @- I- r" Lif(i!=poi && (*memory).p.flag==IO_waiting), P7 l0 j2 E- A' L
    {. M; Z7 q; V; J  D1 ~; t6 a3 R" K
    j=(*memory).p.ioNum;, l  H! P9 c/ c" g; d2 T& X7 |5 O
    if(j>0)1 ]( J3 T2 o7 Z2 k$ L4 j
    {
    . t" h; a% z5 P1 M# K8 Zif(--((*memory).p.computeClock[j-1])<=0)// one compute tase is completed
    ' a$ ]* i. |( _3 a% E{
    0 T6 r; w( U+ @+ u(*memory).p.flag=computing;
    ) _% m: S+ U0 D, g(*memory).p.ioNum--;
    & P: l* R. I6 l. l5 m/ Qchange += exchange_IO_Compute;+ \! N, a3 x. o' e5 o
    }
    / ~: h" e# o0 r* m$ |, i& I}
    " g1 ]& c- v: z8 v# s: ]3 t}
    5 T2 P, J! o+ j. Z$ r# X+ N% V' K}
    - p+ w$ Q1 X! I$ O$ efor(i=0; i<(*memory).proNum; i++)  //处理已经运行完毕的进程
      c8 K8 ]: O, D{1 e. r6 P: x3 W) Z
    if((*memory).p.ioNum <= 0 && (*memory).p.computeNum <= 0) // a task is completed
    9 q% O, Z9 X( J2 s) |* E0 N{
    8 V; M- `6 O$ N; O; ~4 y(*save) = (PCI*)malloc(sizeof(PCI));/ M4 G1 X" J4 b
    (*save)->next = NULL;
    ( N  ?# p0 {  _       (*save)->processID = (*memory).p.processID;6 r' Z, F  R; \2 Q8 k, g- E
    (*save)->comeingTime = (*memory).p.produceTime;. B$ h$ J( m' N  b
    (*save)->askMemory = (*memory).p.askMemory;/ N# r$ g3 |' J6 T+ H- A
    (*save)->compute = compute;
    - {0 Q2 V# p( l8 `4 [(*save)->waitio = waitio;
    / S2 b0 q2 Q# ]% [3 _$ d(*save)->exchange = change;
    ; H" E3 q) x- ?, w4 w(*save)->completedTime = systemClock-(*save)->comeingTime;
    3 v5 ]) |5 c, L9 |(*save)->runningTime = (*memory).p.runningTime;/ w0 x8 k' [4 ?6 u* H
    (*save)->completedTime = systemClock;
      G( _, V9 x$ J- X5 _) |" U# e*spareMemory = *spareMemory + (*memory).p.askMemory;6 ]: d. l5 @" ]$ d' k% o. }1 I: X
    compute=waitio=change=0;
    + |9 R9 M* Z6 U# a7 I, S1 OcomputeLast=waitioLast=changeLast=0;
    7 U4 A# z# `% W" y# Wif(TimeTurining_storage_to_memory(&(*storage),&(*memory),&(*spareMemory),i)==1) // 调入一个新进程进入2 L( D% x" z! o( s/ o
    {
    2 T! J' k/ W3 t/ @2 P. ^6 Fif(i==poi) //占用CPU的进程已经运行完,将时间片分给其他进程) l# u# ^# j* L3 d9 A
    {) a% y5 o) s9 e' }$ d* D  f
    poi++;8 W' L  M+ `9 O  N$ I* c
       clockSegment=2000;  d8 Q. c( m/ F" l
    }
    2 I) [% k3 l  h* \7 D. Y) O: ^! T}
    6 P% N3 Q( S! k1 Yelse  //没有足够内存调入新进程
    4 L0 r' C  ~! N" a% b# J0 j' I{
    " B( y6 r+ ]; {3 n( c( Lif(i < (*memory).proNum-1)0 o# b8 K" C4 `) l4 w  ]: Y
    {
    & w$ j) Z$ h- ^& tfor(j=i; j+1<(*memory).proNum; j++)
    7 ]: L' z$ q, G* S% l% C3 ~6 ?{  R& a: f2 O5 e# C" |* H
    (*memory).p[j].askMemory = (*memory).p[j+1].askMemory;
    0 B1 [+ b' x8 W" w" J, j(*memory).p[j].comeingTime = (*memory).p[j+1].comeingTime;; E6 V. f9 a8 ?& e) d
    (*memory).p[j].computeNum = (*memory).p[j+1].computeNum;
    - \8 X, ?8 B, _0 f0 V(*memory).p[j].ioNum = (*memory).p[j+1].ioNum;: b/ a6 s8 t+ \/ y. h: Y
    (*memory).p[j].processID = (*memory).p[j+1].processID;% V. U4 Q/ I8 v# g9 Y  C; T7 _6 w" j
    (*memory).p[j].flag = (*memory).p[j+1].flag;
    6 x( x$ A# N$ \3 Q; m/ O/ k(*memory).p[j].ioTime = (*memory).p[j+1].ioTime;  L0 v% ]% j. k4 s6 F; W% `0 K3 ^
    (*memory).p[j].computeTime = (*memory).p[j+1].computeTime;" [& T- w3 d* D' a' z: g$ H
    (*memory).p[j].runningTime = (*memory).p[j+1].runningTime;9 M. W; L0 {# T& V4 ^
    (*memory).p[j].produceTime = (*memory).p[j+1].produceTime;7 m4 D5 P+ Q# ?  u9 a
    (*memory).p[j].completedTime = (*memory).p[j+1].completedTime;
    1 p/ S. p: ]* ]+ Z; Y% Q# tfor(k=0; k<(*memory).p[j].computeNum; k++)! F7 ^# z+ h2 e" H. x
    (*memory).p[j].computeClock[k] = (*memory).p[j+1].computeClock[k];
    2 d9 }- |% ]6 U7 l- C. Pfor(k=0; k<(*memory).p[j].ioNum; k++)! x/ @2 B3 q& i8 e2 f2 \! E
    (*memory).p[j].ioClock[k] = (*memory).p[j+1].ioClock[k];, `* S9 q' Y$ R. Z
    }+ y- S' Z3 M: I
    if(i<poi)
    0 |7 `- d! o- b; Y: H# Y3 H2 dpoi--;
    : \. {: m! }' Lelse if(i==poi)
    4 x' m3 T) q8 A; d* j  eclockSegment=2000;
    8 u% B$ `1 P4 F+ d}
    2 f6 T8 \* p8 |# t) Q( c5 Ji--;% ?# w; P+ T- O# Z
    (*memory).proNum--;
      g( a" ]5 ]. C& ?( [! w}( p7 Z4 g* h8 S# K$ _  |
    return task_completed;
    ; ]  ~& }% Y0 I8 l! m# K8 I- y& x7 P% ^}: R# c1 O7 t7 a" s" n( v" h, R
    }
    # v. @9 y2 x- s7 o% ]--clockSegment;
    7 n# U, C9 G) ^& rif(clockSegment<=0)
    9 c' T: k+ W; }; }{
    3 D2 Q4 U7 ?8 B- X7 ]+ B+ Kpoi=poi+1;
    3 c7 Y* F# n2 q* |2 ?if(poi>=(*memory).proNum)1 |3 o6 N$ w$ ]1 k& y
    poi=0;+ U+ x$ V. q; x; l  S
    clockSegment=100;) B# M2 d9 ~8 G5 z" r, ~
    }7 Z' z( }) g7 W+ f* W& ~
    return task_not_completed;! c; ^! F1 d' j! s3 d9 q0 L) T
    }
    ( W- V- N+ _7 L% b5 \. B$ V! N# hint TimeTurining_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory,int pos)8 h9 r2 n/ k' X) K' {( z
    {- W7 p' L7 e# x" q6 K  W
    int i=0,j=0,k=0,flag=0,translation=0;
    5 l5 l8 P. }6 x8 `: b2 G% Dfor(i=0; i<(*storage).proNum; i++), b3 |; q7 @; ^. y9 C1 Y
    {8 h# `7 j3 S& @  G. P; Y+ Y
    if((*storage).p.comeingTime>MAX_COMING_TIME)* B# {+ r, v$ I
    MAX_COMING_TIME = (*storage).p.comeingTime;
    " `8 h3 l; @8 u0 Y}
    3 @/ H5 _4 E; j0 Mif(pos>=0)
    3 f7 T/ q3 y2 Y{% X' \* t$ t! ^+ E7 [1 b
    for(i=0; i<(*storage).proNum; i++)1 n- i- S# `; A  N; b" \; W
    {
    7 R/ e( G" y/ u2 q4 Y! [3 M1 Hif((*storage).p.askMemory <= *spareMemory)3 W, j3 m# W, g0 \
    {
    . ~: g- T+ \% Gj=pos;
    ( ]! W5 `5 `+ Q(*memory).p[j].askMemory = (*storage).p.askMemory;
    0 g# _( |: p# F4 n4 Z6 ](*memory).p[j].comeingTime = (*storage).p.comeingTime;
    6 M& c" c& J: t(*memory).p[j].computeNum = (*storage).p.computeNum;
    + y( e1 [5 v6 i) q' A7 {- c; d(*memory).p[j].ioNum = (*storage).p.ioNum;% F6 `3 ?- A+ |* `. A) l
    (*memory).p[j].processID = (*storage).p.processID;+ |3 b9 N/ N1 E9 @7 U. s0 M( {( w
    (*memory).p[j].flag = (*storage).p.flag;- o+ Q2 \. P% J. U" ~8 B  f
    (*memory).p[j].ioTime = (*storage).p.ioTime;
    4 ]( g0 Y$ b8 C, ~(*memory).p[j].computeTime = (*storage).p.computeTime;* Q/ [5 d! l! \3 Q* \1 \" z% E
    (*memory).p[j].runningTime = systemClock;5 i; [6 H. S7 w7 p
    (*memory).p[j].produceTime = (*storage).p.produceTime;6 b7 P1 g) o( [, I* f
    for(k=0; k<(*memory).p[j].ioNum; k++)
    8 \1 W" h- p  R. F8 I* H(*memory).p[j].ioClock[k] = (*storage).p.ioClock[k];
    / |1 |( T" B& z6 p+ nfor(k=0; k<(*memory).p[j].computeNum; k++)% _. D# o: s5 W7 E* i  X) h8 u
    (*memory).p[j].computeClock[k] = (*storage).p.computeClock[k];
    * o" B6 d& [) z; s*spareMemory = *spareMemory - (*memory).p[j].askMemory;; c- T3 k% W8 _" m6 c  Y7 i
    produce_one_task(storage,i,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程6 h  g+ C9 J& r8 \
    MAX_COMING_TIME = (*storage).p.comeingTime;
    8 g9 [, s  |- H* u) {  Rtranslation=1;
      @6 o$ {1 I2 H( Z2 F; Ybreak;& `9 j0 L* Y/ ~
    }4 j: G' D& S6 s4 r
    }" |  `' C* |6 D( a" U
    }; a. h& j, w5 b9 ~; H, ~- a# F
    else% h) h. q3 W7 W. K, g
    {
    $ C  E7 V5 [/ v0 A. S( X- mwhile(1)( q2 C; q) R3 U, B
    {. e7 T0 L6 T' `
    flag=0;
    4 j2 j" k/ `* O* _6 e, {7 h8 nfor(i=0; i<(*storage).proNum; i++)
    . b  m( _1 h( M+ A9 M{
    $ |1 A8 k5 }7 `& pif((*storage).p.askMemory <= *spareMemory)# a" e3 `: _2 D$ O( J% u' L8 W
    {2 x0 W" l  s# i& r% B' f1 A2 U  M
    j=(*memory).proNum;+ ~) D' F0 C; v! H0 i3 v
    (*memory).p[j].askMemory = (*storage).p.askMemory;' f) U. d8 j: W& z
    (*memory).p[j].comeingTime = (*storage).p.comeingTime;
    4 C1 n1 S3 l# M4 r(*memory).p[j].computeNum = (*storage).p.computeNum;
    / f2 p, v. G6 Q( F2 h8 ?(*memory).p[j].ioNum = (*storage).p.ioNum;
    1 L* k' o' b4 m7 m1 j4 A9 i- _(*memory).p[j].processID = (*storage).p.processID;
    " F1 d- |  g7 V2 z(*memory).p[j].flag = (*storage).p.flag;! Y! O: ~; q' a+ [0 s3 o6 ]5 I% z
    (*memory).p[j].ioTime = (*storage).p.ioTime;6 w0 @% J& P; b. z& Q3 l' Z3 h5 y
    (*memory).p[j].computeTime = (*storage).p.computeTime;1 U, c* F4 `8 J  f: E( K9 B% y
    (*memory).p[j].runningTime = systemClock;
    9 K! t% ~' E4 {( V% Y(*memory).p[j].produceTime = (*storage).p.produceTime;
    : H& ^+ G$ d6 F! Dfor(k=0; k<(*memory).p[j].ioNum; k++)2 w5 a3 A9 L1 e$ f" u% L
    (*memory).p[j].ioClock[k] = (*storage).p.ioClock[k];2 \* m1 X4 c' V( ]; p8 n
    for(k=0; k<(*memory).p[j].computeNum; k++)' m$ P/ Y3 A* t4 v) u
    (*memory).p[j].computeClock[k] = (*storage).p.computeClock[k];; d( F* t: W/ e/ B5 Z& o
    (*memory).proNum++;2 F3 k, z6 c, l" z' ]# u$ |
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;
    % ?" q/ i4 c4 Qproduce_one_task(&(*storage),i,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程+ j7 A  B$ v2 d; ]" N
    MAX_COMING_TIME = (*storage).p.comeingTime;
    & l5 h! u4 }' e1 A9 G2 l; qflag=1;1 n6 U8 @* [/ L0 k- r7 B$ J  v
    translation=1;
    - r7 {7 q2 ~, J3 v4 y; W/ Z  M}
    2 E% Y1 o  p& g/ g6 a0 P( ^( y}
    0 d9 H, k; \& O9 [8 j( ^7 B3 sif(flag == 0)- [5 C4 p* f- ]; v* {- Q- U
    break;' w; E$ V5 A* D& ?% q
    }7 O+ I2 l* y; g1 g- H  H! [
    }
    ; T3 |+ s7 C% G2 areturn translation;
    . |$ b/ b  {& |}4 D! f& T  j7 q
    int FIFO(processPool *storage,processPool* memory,int * spareMemory,PCI ** save,int draw); E, T; i, I# `0 E
    {! A. i0 g$ k0 R
    static int compute=0,waitio=0,change=0,flag=0,flagiocpt=0;
    * h! w4 R* f: w9 T: u/ |static int computeLast=0,waitioLast=0,changeLast=0;+ ~6 a2 \8 e1 n& l7 S2 Y( b
    int i=0;
    # G5 q. @5 }6 H. t3 Iif(draw==1)
    & i  I1 |7 f/ q' v{& C" X% |7 w$ Y( v* j
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);% k3 Q% ^( Q+ {* d
    drawPerformance_FIFO(0,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    ! `+ y. `/ j8 b
    % T- ~! \. F+ W' j/ z3 a, e9 q% |( L1 R1 _& h0 F
    computeLast=compute;# ^5 C% {5 Z# k
    waitioLast=waitio;
    7 o4 O8 ^& s$ I1 @6 OchangeLast=change;/ M2 f# f% y3 h9 B
    }
    . p# n+ [" G1 O+ z, M  }if(flag==1)  
    ( L* y% p! @8 n% c/ Y+ i{6 u8 }6 V7 N. L9 V* R
    if((*memory).p[0].ioNum>0||(*memory).p[0].computeNum>0)  //task is not completed
    3 M! H2 H6 ], w; |, J' n" S0 w2 x{
    " q. `+ p* T& t: V) B+ m6 uif(flagiocpt==0)   // implement compute
    # Z/ j! Z% |0 V+ |. @' \5 _0 j{
    4 L, n3 z* F6 [8 hi=(*memory).p[0].computeNum;
    ( d5 b9 r- k" h5 d  Wif(i>0 && (*memory).p[0].computeClock[i-1]>0)+ m9 O( p' Q! n' U9 v
    {1 ?# ?& F8 _- f2 T4 W- i) O) O
    if(--((*memory).p[0].computeClock[i-1])<=0)// ome compute tase is completed
    , e) V' e3 c( `& |, L; w. k{
    # G' O4 A4 [5 U- y; @' _7 n& q- hflagiocpt = 1;
    " _" }. A/ k# Z! j) J& z(*memory).p[0].computeNum--;
    - ]; l6 a9 L, e, Y: O- [) Cchange += exchange_IO_Compute;8 B& g* |6 z: z
    compute++;  N8 y) ^" s0 F6 Y+ A  v+ L& [
    }
    & r$ ]! |1 d( F5 `3 O0 V) ?4 H+ gelse
    2 x" n2 D" G: vcompute++;
    ! d. v3 a( ]. L! e/ E! ~
    9 [* @9 h7 g# d2 c}2 n. A& D0 L* s$ D1 _; R' r* l
    else
    , ?, G+ n1 |* z- u" l, Gflagiocpt = 1;( v9 x. S7 s8 N* C! \
    }
    " ]4 j! J' r0 P  x( i: i7 {' Nelse  //wait io, f1 ^2 V* r$ _  Q8 ?3 q; ]" Q
    {6 h6 N7 M$ F+ k3 c* r, d/ M
    i=(*memory).p[0].ioNum;
    ! C9 k/ H( o4 h. Y& Sif(i>0 && (*memory).p[0].ioClock[i-1]>0)0 r2 o1 A7 g8 ~/ j1 _
    {" R( ?+ h1 x& J' u* T
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed. R/ }; k+ n6 P
    {
    - d" }+ x5 @* W* Pflagiocpt = 0;0 \" b! u: p- Z# k
    (*memory).p[0].ioNum--;, n, e" R" z2 V1 x4 k5 G1 J
    change += exchange_IO_Compute;$ g6 G$ q( T" G5 ]
    waitio++;5 X2 g2 J! j# i$ W4 g
    }8 G  o  j9 z( y: U8 I9 K
    else
    & g& S2 q# t0 m# \' qwaitio++;
    & {* V6 n& C* ~# C1 j$ v7 d8 L
    : {0 C, r. v$ d8 y1 o}
    * u1 z) g7 ]- E' a* B' `else
    7 h: D: @7 V. V% C' `flagiocpt = 0;( q8 z- [6 Q* m- ?& D5 \$ [1 e6 t
    }
    6 e' c$ w! \7 x  D5 q# r}, k/ N) ~8 L; C0 N# c
    else  //task is completed& Y  ?6 H; r. G. d% I
    {
    ! H9 D: z/ k, T5 K(*save) = (PCI*)malloc(sizeof(PCI));& k2 b% r/ Q4 g0 D0 K7 Z
    (*save)->next = NULL;9 Y/ ?( q4 b- m$ ^2 b
           (*save)->processID = (*memory).p[0].processID;
    0 w, e/ R! E! ~7 n(*save)->comeingTime = (*memory).p[0].produceTime;
    8 S) t) z9 d# [3 u$ R(*save)->askMemory = (*memory).p[0].askMemory;8 l+ k9 j9 ^+ ~% }' j
    (*save)->compute = compute;1 k4 s% ]6 [( H! `9 N; ~, M" O  l, _
    (*save)->waitio = waitio;
    9 k5 g+ ?, O5 g(*save)->exchange = change;9 ?2 O( ]) |/ x: r8 U- z* f4 o
    (*save)->completedTime = systemClock-(*save)->comeingTime;3 J& l8 i) J" {. V
    (*save)->runningTime = (*memory).p[0].runningTime;+ ]' c4 |; V0 I$ z4 v
    (*save)->completedTime = systemClock;5 `6 x+ G( s( |& s; Z! Y5 d$ r
    //*spareMemory = MAX_MEMORY;( i. D. B: i) ]
    free((*memory).p[0].ioClock);
    & O8 t3 Y6 E7 w* Q7 m7 L: [% mfree((*memory).p[0].computeClock);* Y& Z. }, p' Y0 ~2 R% v4 Q
    free((*memory).p);
    " C2 Q" |- v6 Q9 K; f5 L+ Pflag=0;( n" T- k0 G+ K( H8 g5 H
    compute=waitio=change=0;  B; j. B0 ~" v+ I
    computeLast=waitioLast=changeLast=0;
    " w: ?, c* L" ^0 D- F1 {& Dreturn task_completed;
      `, z3 w% }: h/ T7 d+ k( D}
    : E) O8 g1 Y/ p+ a: X9 P; |}
    & U( Q$ ~# B5 G0 w6 }( U# kelse         4 r/ A) M7 p+ C- }
    {
    " w" N$ H- V9 H( I. IFIFO_storage_to_memory(&(*storage),&(*memory),&(*spareMemory));- w8 Y7 Y4 k/ O
    change += exchange_process;
    ' u1 x$ k2 D9 S4 I7 B* o//*spareMemory -= (*memory).p[0].askMemory;5 M# ]; h# }% M8 t. O3 c1 E
    flag=1;9 e0 m0 y' i! [! F# A6 E
    //showProcessInf(*memory);/ Q1 p1 ^" ]0 C# T
    return task_not_completed;1 x7 _% Z5 K* }! p# ~
    }8 ?8 A+ \$ h1 B1 Q2 S6 s* N9 c
    return task_not_completed;
    8 D, Y9 s9 R& e) y7 Y- [- Q7 P& g# W}2 `1 k% i4 d7 q3 j- u& S5 R% `1 e
    int FIFO_storage_to_memory(processPool *storage,processPool* memory,int * spareMemory)! s7 m# L. f! k  J% L
    {/ P$ d5 k, L" N/ t6 S$ d
    int i=0,j=0,k=0;! G5 w# q+ S1 A4 E1 W# w5 U% f- O
    MAX_COMING_TIME = (*storage).p[initProcessNum-1].comeingTime;
    0 X' f+ F) @4 B9 Y+ h(*memory).p = (process*)malloc(initProcessNum*sizeof(process));0 z3 }  Z( @6 R$ Q
    memory->proNum = 1;. H& o  Z# m1 ~: ~4 o$ i/ J
    for(i=0; i<initProcessNum; i++)
    % C5 p7 F/ d7 h{
    8 U4 O4 B. V5 D' |9 F  _) oif((*storage).p.askMemory <= *spareMemory)
    ( S" q% |$ E, M1 a' C% ^# R7 \{7 ?" X, S7 n4 A; z$ P
    (*memory).p[0].askMemory = (*storage).p.askMemory;
    4 Z* l1 n/ p7 S9 ]( r(*memory).p[0].comeingTime = (*storage).p.comeingTime;3 }! N- g9 }" y6 ?! @6 g+ w  g
    (*memory).p[0].computeNum = (*storage).p.computeNum;
    & K: o; E3 D. g1 A+ F7 t(*memory).p[0].ioNum = (*storage).p.ioNum;/ ?. A: G4 b0 w- Y0 D0 ]
    (*memory).p[0].processID = (*storage).p.processID;
    . t9 h- y& U, w3 p* Y$ ~0 ]8 M(*memory).p[0].flag = (*storage).p.flag;( m/ L" H& u4 O
    (*memory).p[0].ioTime = (*storage).p.ioTime;
    ; }6 y2 j9 p/ d' ~+ U(*memory).p[0].computeTime = (*storage).p.computeTime;: S" f) t$ R2 c
    (*memory).p[0].produceTime = (*storage).p.produceTime;4 Q' t5 V% q8 ]# c& l+ K
    (*memory).p[0].runningTime = systemClock;- G7 u* L+ o3 g$ n5 l
    (*memory).p[0].computeClock = (int*)malloc((*memory).p[0].computeNum*sizeof(int));2 a. P* W3 ?/ H1 `
    (*memory).p[0].ioClock = (int*)malloc((*memory).p[0].ioNum*sizeof(int));0 i1 H( t1 r! L/ v; I8 a
    for(k=0; k<(*memory).p[0].ioNum; k++)5 t" N: U6 i4 C) B6 Y9 P/ b" K
    (*memory).p[0].ioClock[k] = (*storage).p.ioClock[k];. _) l2 c# I; z
    for(k=0; k<(*memory).p[0].computeNum; k++)
    + t9 W2 g1 x1 j; G1 C$ U4 o(*memory).p[0].computeClock[k] = (*storage).p.computeClock[k];
    7 O+ c3 K+ G/ G: Sbreak;) Q$ o9 d& F* q4 l0 h
    }
    1 O" N! h- O  T  F2 D+ F}
    + O# k* Q* N& f# a0 ~if(i<initProcessNum)  //调用一个作业进入内存后,并再生成一个作业等待调入+ y- y: ^2 @! D* q6 N! I7 F
    {
    : M4 q% y6 ]$ S: V  g' fproduce_one_task(storage,i,ID_FIFO++);
    ! `  N) d$ W$ M% p. {2 vMAX_COMING_TIME = (*storage).p.comeingTime;
    ' u& j  N/ q  S% Zsort_by_comingtime(storage,i);
    $ O5 n: d: Z& o' `2 l7 d}( Y) S8 c2 X- m+ F, b% [
    return 0;
    3 f% q, J) q$ G: R}
    9 t# i( e( F* e3 j$ gint sort_by_comingtime(processPool * p,int pos)
    / \& \- Y" M+ X% ]/ C( }. @/ l{5 V; R/ t2 ^4 W2 R  \
    int i=0,j=0;
    4 @; p  D) U# ^/ p2 n- mprocess temp;
    6 u( Y+ {. _0 z4 ~if(pos<0)
    ; t+ ~. f2 t. E' M* L. R{
    - s- {' B2 l# qfor(i=0; i<initProcessNum; i++)0 r6 k- [3 I# g/ p' ^& _
    for(j=0; j+1<initProcessNum-i; j++)1 H- @. u5 j! |1 r
    {
    - L& y+ N2 `2 p, }- sif((*p).p[j].comeingTime>(*p).p[j+1].comeingTime): \4 M0 K3 O. r0 J  d) K- V
    {
    ' ]+ r# G0 @( w# Ztemp = (*p).p[j];5 m% V' j1 @/ F, p8 s. w8 D
    (*p).p[j] = (*p).p[j+1];# U. A& Q; C) ^8 p' R: h# ?
    (*p).p[j+1] = temp;
    " V( E4 H- g8 d( b1 H}
    0 V5 O  I: a9 J: ]7 N# o5 @}
    2 Z2 R% k: a& a9 J: n6 c}' n$ F1 F$ v. [& Q' K& f
    else if(pos<initProcessNum)* i6 q, l: G# D& [2 {% Y2 r
    {& r. K. X2 y- @$ y9 p) r' Z! H
    for(i=pos-1; i>=0 && (*p).p.comeingTime > (*p).p[i+1].comeingTime; i--)
    8 G) A! z+ h8 c% G0 A+ g& }6 A{
    ! b& N; E1 n( `% e; k* ctemp = (*p).p;
    3 ?) [# e& t1 c0 n8 ^3 r7 a( P(*p).p = (*p).p[i+1];- A1 a- G3 ?7 S4 I
    (*p).p[i+1] = temp;
    * Q: C0 V" y0 _+ k) m}! M% z; U; i) a$ y
    for(i=pos+1; i<initProcessNum && (*p).p[i-1].comeingTime > (*p).p.comeingTime; i++)
    " l; x! L/ G; h. O0 x8 S{3 {* B. ?7 |/ H( H
    temp = (*p).p[i-1];) {/ N- _! \% K- D# B# Y& B/ A
    (*p).p[i-1] = (*p).p;5 X4 K# A# V' I$ K( X; A
    (*p).p = temp;
    ) X! x) w/ F1 ~3 K+ m* T4 P' K/ y}
    2 i+ v0 e0 z/ U}
    + l5 f9 P; z3 T4 ]; telse
    + y; `1 ?) s& G" W3 u. gprintf("position eror\n");' ?  m: Z% Z7 k. Z5 l) s! C
    return 0;
    - I% A6 ]6 Q3 V  f# ]}
    4 U. ~6 Z# e$ h& o: z: O4 kint InitPool(processPool * p)( r! W* @! k: q7 i7 J0 V! ^, e7 }
    {! S2 u2 T$ h0 ~0 D. W+ g1 p
    int i=0;
    0 }0 a% s( ~' \' D$ H(*p).proNum = initProcessNum;
    & e& T- |! d- a& s. N(*p).p = (process*)malloc(initProcessNum*sizeof(process));
    & x2 _- {! |% Ufor(i=0; i<initProcessNum; i++)                                        //init process information
    ' N- L" U! D; L+ |9 i; a, k: _{# ^" s1 |2 x' o& L# e
    (*p).p.computeClock = (int*)malloc(initclocknum*sizeof(int));+ ?  W( F, W. C8 A( v
    (*p).p.ioClock = (int*)malloc(initclocknum*sizeof(int));+ z3 a- C! i  D( O, e, B4 j" q5 X
    produce_one_task(&(*p),i,ID_FIFO++);2 D% Q1 b  b/ v( v: L2 N! `7 C
    }% f2 I3 U- S+ Y0 e) `" s4 m1 T+ Y
    return 0;
    : K8 R4 `3 V: Y1 |% B, Q3 M}
    . y) h0 Z* U  E' Z  O' @: `' Rint produce_one_task(processPool * p,int i,int id)
    % U9 z3 @& P/ g* V9 W3 d{
    * i) @' x- ]. o5 i5 p! k) `int time=MAX_COMING_TIME,j=0,totallTime=0;
    ) q+ y; U; D  Z(*p).p.processID = initProcessID+id;           
    & J* d" q( L, g(*p).p.comeingTime = time+rand()%(MAXProcessRunTime/5);
    1 @9 q  l+ i* W& |" @+ P7 y(*p).p.produceTime = systemClock;  a: @, m( b! z1 J( J. F: [
    (*p).p.ioNum = rand()%4+20;                                        //IO number setting to 2--5;, F0 y, z; t0 ]5 V3 v7 y" @1 ^9 y
    (*p).p.computeNum = rand()%4+30;                                   //computNum setting to 3--6;
    # m( W8 t9 I! Y' v) i2 QtotallTime = (*p).p.computeNum  + (*p).p.ioNum;
    8 ~+ r+ S5 H  Z3 i+ ]5 g/ ]0 n9 J- I(*p).p.computeTime=0;
    2 `# o6 A& I& b5 A9 v! ofor(j=0; j<(*p).p.computeNum; j++)
    # C& K* }' W8 d. w+ K{0 L% \/ E# w/ _! K2 {9 o
    (*p).p.computeClock[j]=rand()%(MAXProcessRunTime/totallTime)+1;5 K1 V5 i+ F  `9 m
    (*p).p.computeTime += (*p).p.computeClock[j];' @) ?: J" }0 d; Y+ D/ h) ]
    }
    . X0 z/ |: _' J; t- E& J(*p).p.ioTime=0;
    " _* J  Y$ }6 e( X, d% Lfor(j=0; j<(*p).p.ioNum; j++)
    ; t. w5 W$ ]6 o3 v2 k: s{
    * U% w3 w6 ^, }. e' Q(*p).p.ioClock[j]=rand()%(MAXProcessRunTime/totallTime)+1;
    " }+ F8 U% W6 d0 H' @2 ~(*p).p.ioTime += (*p).p.ioClock[j];
    $ \+ R0 _5 E# V- L2 @7 t}$ U5 j: T1 t1 T* @* B% v
    (*p).p.askMemory = rand()%(MAX_MEMORY/4);, }3 n" M+ s4 Y7 L2 @  P
    (*p).p.flag = ready;
    3 N% K6 v8 T, a9 B7 B: B9 `return 0;$ ^! M" m3 G, \6 z$ e& V' Y2 R$ @
    }
      j+ G, R% B$ g4 e2 S( \int showProcessInf(processPool p), H1 {5 }/ W" Y& k
    {
    : J2 B  Y2 u' L2 w4 {5 F0 gint i=0,j=0;; W7 d/ \2 c. S4 t" b" |; q
    for(i=0;i<p.proNum;i++)
    + y" @/ j5 m2 t" D8 b{
    3 S6 M( U; V* x' B: Yprintf("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
    / C0 i- N. n  v,p.p.askMemory);
    # B! b& _* Q0 c  ifor(j=0;j<p.p.ioNum;j++)! ~/ B. m* U5 }, ~* X- J
    {6 K7 D3 t8 }/ e4 O6 C! w
    printf("%d ",p.p.ioClock[j]);# S  Z4 V! |! V; P* s- s7 J! a
    }
    ' Y( |7 P5 k7 h9 ^6 i6 j" xprintf("\n");
    - {; r7 t7 d% D9 W; V1 S/ Dfor( j=0;j<p.p.computeNum;j++)' Y% V$ N8 M" [
    {( k# p6 y8 C8 L
    printf("%d ",p.p.computeClock[j]);
    7 y6 k/ E" w: X' K* g5 P5 N8 `2 G& G}
    - o5 d6 v% t0 `% fprintf("\n");% [5 u$ z2 S0 {, z  N
    }
    9 R, w. ~7 b1 U3 P, }8 x4 c9 u- Sreturn 0;. _0 ?! O; p# Z0 M- l+ S. j5 F2 d
    }8 k8 J! `- K5 B" w
    ————————————————, i) b( m, k* d2 d+ G
    版权声明:本文为CSDN博主「wang_dong001」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。: Q- O3 N: d( w- ?# k9 D
    原文链接:https://blog.csdn.net/wang_dong001/article/details/47843519
    0 x. f( B( Y0 G$ ]8 f
    5 {, s; E' j6 G. w( X- l
      C! a% v7 S2 r# n! H
    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-15 12:21 , Processed in 0.495219 second(s), 50 queries .

    回顶部