QQ登录

只需要一步,快速开始

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

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

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

5273

主题

82

听众

17万

积分

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

    [LV.4]偶尔看看III

    网络挑战赛参赛者

    网络挑战赛参赛者

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

    群组2018美赛大象算法课程

    群组2018美赛护航培训课程

    群组2019年 数学中国站长建

    群组2019年数据分析师课程

    群组2018年大象老师国赛优

    跳转到指定楼层
    1#
    发表于 2021-4-9 15:15 |只看该作者 |倒序浏览
    |招呼Ta 关注Ta
    ' K. y0 T- ?/ u5 ?) ?- k
    经典任务调度算法的模拟程序) r8 S, x1 V4 K4 S
    本科毕业设计写了一个经典任务调度算法的模拟仿真程序,测试了五种调度算法的运行性能。在程序中虚拟了任务的进程,按照不同调度算法策略从进程池中选取任务执行,在任务执行过程中,保存相关的统计参数,最后对这些参数进行处理,反映各个调度算法的实际运行性能,程序中可以通过修改任务的相关参数改变任务特点,测试不同任务环境情况下,调度算法的性能适应性。程序是通过C语言编写的,为了对运行结果图像化,采用了EasyX的图形库。由于计算机中实的任务调度过程比较复杂,在实验中为了简化程序的实现,在某些方面进行了特殊处理。
      r! E0 C2 }$ c4 T- \  j1 g. E8 @! r0 T5 I- m) R
    编程平台:VC6.0+EasyX图形库环境。
    ( [; I$ a) B4 H  b# x
    7 Q. ?0 R+ X, c6 ?以下截取部分程序运行图::, O8 o2 {! L. z2 p" n1 ~

    . Z" f; V' l. o2 S源代码:
    4 q* N- o1 ?+ n: b% s2 F) U4 \8 ~9 ^/ Z
    #include<stdio.h>) P- M$ F9 R2 o* B) {+ l* }2 d1 y
    #include<stdlib.h>. v/ H7 M* J$ b
    #include<easyx.h>
    $ I" d. H: L; ]#include<time.h>
    + s6 }* J: `2 Q#include<conio.h>
    ! B6 v- ?7 m$ l#include<graphics.h>
    4 K# C# I5 ^# \6 W$ }& ?#define initProcessNum 10
    * Y- y: @8 P, ^! e2 e9 s#define initProcessID 1000
    0 a$ h" Z" Q3 m  r#define MAXProcessRunTime 10000
    ( _8 c/ X* Y3 q' }#define MAX_MEMORY  4000
    * @& t" \+ K2 f6 X+ r4 I3 ]#define exchange_IO_Compute 10; s" A+ |3 K6 Q/ D
    #define exchange_process 25
    . x$ B9 y5 M+ s6 i* e#define task_completed 1
    : x9 f9 w4 ~) I* K$ `& R1 [* P#define task_not_completed 09 B  G, L: R! \# e& j$ Q8 x$ s" N
    #define initclocknum 1007 ^1 D1 v: f4 @0 X/ V' v7 `. R
    enum condition1 {2 T& ?9 h4 v, e4 W/ t+ G
    {
    5 Y: O% G( u/ [dead,computing,IO_waiting,ready& P9 y  m8 K* J
    };- u8 C$ s. o7 k0 i
    struct process2 `4 r, |1 o. g; F
    {
    - h$ W: |9 Q( s7 S4 Uint processID;- ]- A# C! V2 j9 s
    int comeingTime;
    " t+ l7 y1 [- o) @! k5 Sint ioNum;! t9 z2 i& x- D& ~- [
    int computeNum;# h% S8 [" h: T) l4 D
    int * ioClock;
    " B; Y0 j, w+ Xint * computeClock;1 }4 Q5 Q$ R) c3 T
    int ioTime;
    ! W- K( w# Y. e6 R! Uint computeTime;
    * u; C( O" ?4 |int askMemory;- i5 _* `( j' N$ U# k4 Z. L& i
    condition flag;
    : Z8 z# _  ?; R% s" X7 lint produceTime;  //生成时间,以下三个数据成员用以计算相关性能
    2 ~9 S+ ]; S6 s' N/ ^  gint runningTime;  //第一次占用CPU的时间
    2 L: x" J5 b9 X/ T& vint completedTime; //进程完成时的时间
    4 H/ C6 I% Y$ @" o% r};
    : r& r( {: B" h" O2 V9 ttypedef struct processCmpletedInfo  //保存完成一个作业的相关信息
    & y1 y. T0 a* l' z  u. C{/ Q5 J1 R$ k# I* U0 l
    int processID,comeingTime,askMemory;
    * E# W8 _( Z/ r: }' y6 |+ Q8 T4 ]6 w* [int compute,waitio,exchange,completedTime,runningTime;5 n! q( @/ p  _  q& o# n1 ]
    processCmpletedInfo * next;5 d4 A9 N% |) F+ F5 n6 t* ~
    }PCI;
    2 E  ]! Q) P. ]8 ~struct processPool" n8 R% T7 T# K
    {# c( _! H& C: J
    process * p;
    $ D& D+ @2 G9 ^: Wint proNum;
    ; T& G8 q5 \. n/ [( n4 ^+ F" `};5 L: V* O5 Q( n  Y6 i
    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;  [4 }% X& M4 w% W: ^% |
    int InitPool(processPool * p);
    % S- C, ?+ ]: rint produce_one_task(processPool * p,int i,int id);
    9 ?7 X# C4 V8 q# A1 ^9 Kint FIFO(processPool *storage,processPool* memory,int * spareMemory,PCI ** save,int draw);; S# x$ J. o4 B7 [7 z( @' V, s9 ?
    int TimeTurning(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    3 t) h2 z* `- ?! V6 a9 M# E- F3 ]int TimeTurining_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory,int pos);
    & H* e! g/ F7 ^  k" T+ |int FIFO_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);
    * g& Y/ R! H, R0 Q1 c' w9 F) aint ShortJobFirst(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    1 J8 F* N- J2 y' p* f# S( cint SJF_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);
    ! ~5 F: J+ }/ `& R2 s+ Rint PriorityDispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    + ^1 }" k- H' |! g6 r! O$ pint Priority_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);: L3 @# }4 Y& J, U! U0 ]) E
    int High_response_ratio_s_to_m(processPool *storage,processPool* memory,int *spareMemory,int flag,int disatch);
    0 K# s- R% e+ U- q+ y: Hint High_response_ratio_dispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    4 Z; L1 ?/ H4 F: t( w  w( I$ Q% k8 H+ {% E: p& J# p, t
    0 f9 N' N1 ]; T
    int sort_by_comingtime(processPool * p,int pos);
    8 P( s+ M! {. ]' N' p; V, U- f- cint showProcessInf(processPool p);
    ) N0 D2 n! R7 `, `- V  d0 W, L. r7 aint drawPerformance_FIFO(int x,int y,int memorry);
    ) B8 n* c+ E0 G% M/ T4 `6 Dint drawPerformance_HR(int x,int y,int memorry);
    + \; z+ `; v% N* g0 c# jint drawPerformance_PF(int x,int y,int memorry);
    1 ~& t2 ~& b. |8 X  B9 Xint drawPerformance_TT(int x,int y,int memorry);# I" F1 k, e5 y2 _' X- v
    int drawPerformance_SJF(int x,int y,int memorry);' Q4 N! ^6 ?2 @1 Z0 g) {! F" i4 A; c
    int MouseListening();- l! Y" ?' \- l) n8 J1 s
    int MouseListening2(int *flagShow,int * showTime);) w4 b! Q& p) ?
    int showRunningResult(PCI* FIFO,PCI * timet,PCI * SJF,PCI* PR,PCI* HR);5 M' M; t* B' P  t! M3 _; M
    * }5 }3 |5 ~. u9 F" s6 @
    ' o7 v+ u& j6 o9 D9 i; i- p9 K
    void main()' k) Y( B5 f3 ]! _7 P+ D3 H" O
    {
    6 }9 q8 [9 D2 S% G1 DPCI* FIFO_save_head=NULL,** FIFO_pri=NULL,* Timet_save_head=NULL,** Timet_pri=NULL,* SJF_save_head=NULL,** SJF_pri=NULL,1 ?% w" E- r: u: X3 V0 ]2 h0 ~! z
    *Priority_save_head=NULL,** Priority_pri=NULL,*HR_save_head=NULL,** HR_pri=NULL,* p;
    2 }/ p$ R* W3 o3 Tint i=0,FIFO_memory=MAX_MEMORY,count=0,Timet_memory=MAX_MEMORY,SJF_memory=MAX_MEMORY,Priority_memory=MAX_MEMORY,HR_memory=MAX_MEMORY,3 n- [' L( d8 j0 z, i; e/ N3 I
    flagDraw=0,showTime=100000;( W3 h# K6 G6 k7 y0 n( A% n
    processPool FIFO_p, FIFO_mmy,Timeturn_p,Timeturn_mmy,SJF_p,SJF_mmy,Priority_p,Priority_mmy,HR_p,HR_mmy;8 z; ~" u3 b  S+ ^
    FILE *fp=NULL;4 _/ \# T' K5 l) {
    //processPool HR_p,HR_mmy;! _$ X  e9 m& x/ P) _% u- V, J9 d
    9 j/ a2 U$ D; U7 w) }: A
    ' p! D0 x$ _/ T0 E: g
    srand((unsigned)time(0));
    * X; ?% i& A& M- @systemClock=0;4 T2 Y4 J( v" N/ `' J' h
    initgraph( 1200,650,SHOWCONSOLE );
    0 `4 L* `- ?2 @, _- x* P: l+ e7 Rsettextcolor(GREEN);  f" s9 B/ h7 F9 P
    setlinecolor(GREEN);3 Q5 e6 |; j$ Y# _) d
    setfillcolor(GREEN);( w9 r" H; T! m& r3 i; ?2 E
    InitPool(&FIFO_p);
    4 l$ j! L5 ?% ]& _/ E1 t7 \sort_by_comingtime(&FIFO_p,-1);
    - f1 h( t4 Y7 S! p' ~6 _InitPool(&Timeturn_p);
    " T+ H) i' o- {% ]InitPool(&SJF_p);
    ) X: h0 S+ r5 Y+ A! ]InitPool(&Priority_p);+ V3 u% i) J) f, {/ d
    InitPool(&HR_p);+ ^% o: p3 z0 j* ?2 R0 q
    //showRunningResult(FIFO_save_head,Timet_save_head,SJF_save_head,Priority_save_head,HR_save_head);
    7 G: u6 n% \( f& X) M+ k' C0 m6 _) |//Sleep(10000);
    3 j: F  p# k9 U  D; i( R* R  U1 [1 m! s7 p+ q) v% @5 B$ S
    / D/ G5 g, a+ C) j0 k
    Timeturn_mmy.p = (process*)malloc(initProcessNum*sizeof(process));  W4 h( d/ P' T0 s# \! P# D. U# A
    SJF_mmy.p = (process*)malloc(initProcessNum*sizeof(process));
    ( o. i4 f, d" G. W: QPriority_mmy.p = (process*)malloc(initProcessNum*sizeof(process));
    ) Y' M- `4 q4 L# X, {; H7 a% M5 rHR_mmy.p = (process*)malloc(initProcessNum*sizeof(process));
    3 o5 t4 R/ S; g4 W; w( Q2 hfor(i=0; i<initProcessNum ;i++)5 ^, B4 m; x/ Q% Z1 N/ A% G! P& y( S
    {
    + y' L2 _0 w, t) ]Timeturn_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));9 G- f) u. l# m$ F/ x! S" I' c, b
    Timeturn_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));
    % S: K" Q6 V9 }& g6 k7 {& uSJF_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));
    4 P( ?  R/ ^1 a7 MSJF_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));* s& z$ N6 |) d0 u
    Priority_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));
    & g+ L4 {: K5 s* s) fPriority_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));
    ; R# A9 I- k  Z0 N# I. \* y1 SHR_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));9 W- Y3 {) V6 \# r1 v
    HR_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));2 ]! E9 {" |2 Q
    }* p& v! r! l7 T! f
    Timeturn_mmy.proNum = 0;1 O2 u$ s8 B5 }# J
    TimeTurining_storage_to_memory(&Timeturn_p,&Timeturn_mmy,&Timet_memory,-1);
    : H% T, l% `$ V, W0 v9 a* b1 LSJF_storage_to_memory(&SJF_p,&SJF_mmy,&SJF_memory);
    ! Z7 w% [1 F# V3 s/ {! V# w& ePriority_storage_to_memory(&Priority_p,&Priority_mmy,&Priority_memory);
    8 c9 ^. @7 K( s" kHigh_response_ratio_s_to_m(&HR_p,&HR_mmy,&HR_memory,0,1);
    / x  {, \# ^1 R//showProcessInf(Timeturn_mmy);  w) C3 p, q, e
    FIFO_pri = &FIFO_save_head;& S' n5 `. m4 X8 o5 n4 i" Y
    Timet_pri = &Timet_save_head;9 A8 l; o, N) _5 \% \! o9 [7 {9 S
    SJF_pri = &SJF_save_head;
    # [; V7 L4 G  L8 ]1 A. TPriority_pri = &Priority_save_head;. m' c0 t( `' v0 ?$ Z
        HR_pri = &HR_save_head;2 H. A! ^  b( k: ^7 r# I8 g! x3 i' t
    setbkcolor(WHITE);' X; s# a1 i7 i1 S
    while(1); V! ^+ v0 m; \! p# U
    {
    2 g) u# `8 f, }3 U# k7 |3 v; J' lif(MouseListening()==1)7 p3 I& s" p( y' D: }3 o$ }! C" n
    flagDraw=1;
    7 W8 x/ c. k0 H+ t2 E  j- Iif(count==100)  X' I* M/ ]% Y; ?0 i, S& q& g
    {$ N9 C  m2 C$ [( V. i
    if(FIFO(&FIFO_p,&FIFO_mmy,&FIFO_memory,FIFO_pri,1)==task_completed)
    2 [& k% W  B) E" K4 y2 B, w{# h: \. }7 ]; P; y8 [( s& L  r
    FIFO_pri = &((*FIFO_pri)->next);3 p  y5 i) P' P  l; r0 _7 B" A

    2 e2 r1 U" ^1 X: b# [1 W9 Y//printf("hello");5 Y. Y- @3 T/ X% e1 s
    }$ A/ a* y* w3 n
    if(TimeTurning(&Timeturn_p,&Timeturn_mmy,&Timet_memory,Timet_pri,1)==task_completed)
    2 w: t$ s3 x* ]5 |/ z{+ m7 x) S/ z" s4 J+ m, x6 k# [
        Timet_pri = &((*Timet_pri)->next);
    5 H+ P1 Q* G  M6 k4 U//printf("hello");
    . c, f$ o( f2 b$ ?) o}% Y! c7 U2 q$ j; `
    if(ShortJobFirst(&SJF_p,&SJF_mmy,&SJF_memory,SJF_pri,1)==task_completed)3 N% R: c' g4 N  g, [
    {4 O- S" f  n& M0 Z
    SJF_pri = &((*SJF_pri)->next);
    * j5 t( ^+ X6 S; v- |; p: [2 o//printf("hello\n");8 r) J- L  e/ ?" B3 G6 m
    }+ F/ O$ ~% k% d
    if(PriorityDispatch(&Priority_p,&Priority_mmy,&Priority_memory,Priority_pri,1)==task_completed)  @0 o5 f! j) v2 w/ d: J1 _2 q' j
    {3 W' Y. _% A, K  _0 w3 S
    Priority_pri = &((*Priority_pri)->next);% G* v4 w5 T: j! L
    //printf("hello\n");% h. B. i6 M, ]: G! z5 d
    }
    ) R) `# t' Z- E  T: K3 {if(High_response_ratio_dispatch(&HR_p,&HR_mmy,&HR_memory,HR_pri,1)==task_completed)8 g* r! W9 \+ A# v
    {' S, {6 d1 c) l# G' y! T5 J
    HR_pri = &((*HR_pri)->next);
    2 k4 I& K: l5 W- V* m' [//printf("hello");
    $ b; w, H( S3 P( l' {; h}* D, D+ `+ w0 F" b, D) u. [  S
    count=0;# \: L7 k# N8 p% i$ u7 ]
    }4 z9 ~' L6 l- j8 g9 m8 x( V  G8 E
    else
    % y$ y  g% M) M# g2 K3 l' |{$ G' k% V6 c3 A8 n; r3 E5 W
    if(FIFO(&FIFO_p,&FIFO_mmy,&FIFO_memory,FIFO_pri,0)==task_completed)
    3 i' }- a9 m1 A) S8 y{# ~0 V; v1 ^, m0 j
    FIFO_pri = &((*FIFO_pri)->next);8 Q* A# `* B- U, C
    // printf("hello");4 x( G4 w# d- e( b6 {
    }) W7 C% C9 @) i; \* t5 T% U9 y, N
    if(TimeTurning(&Timeturn_p,&Timeturn_mmy,&Timet_memory,Timet_pri,0)==task_completed)
    * Z7 v, L! |" G. g  B1 I" s{0 X4 K; L  d$ ]
    Timet_pri = &((*Timet_pri)->next);
      g$ x( Y/ U6 f; z* A# P// printf("hello");
    * R% d7 g' E7 Y% q+ v8 u}
    % k3 z1 I! a& u/ B+ z) Zif(ShortJobFirst(&SJF_p,&SJF_mmy,&SJF_memory,SJF_pri,0)==task_completed)7 C5 z3 |+ u5 {: ]' E0 w! D
    {& X1 l& D( g) A3 \0 ]5 z
       SJF_pri = &((*SJF_pri)->next);
    - x& B! `4 c& b5 s5 p1 o// printf("hello\n");
    4 y0 @6 z5 B5 u: y! i! z}& {  N; ^  i/ q7 W; B3 D1 a
    if(PriorityDispatch(&Priority_p,&Priority_mmy,&Priority_memory,Priority_pri,0)==task_completed)
    - o5 Z3 A  N& _6 d& J{" s5 {! F+ H' x. D+ ~# ?& n; \; X( W
    Priority_pri = &((*Priority_pri)->next);) A- B% [2 \4 R" ~
    //printf("hello\n");. ^, R9 X- G  W
    }8 g0 M9 X1 M7 y6 A. v
    if(High_response_ratio_dispatch(&HR_p,&HR_mmy,&HR_memory,HR_pri,0)==task_completed)3 B9 K  f2 T! |$ y6 N$ L7 ?2 A
    {
    . C6 q' ?- j9 i) i: ^0 `0 YHR_pri = &((*HR_pri)->next);! ]' F2 Q+ {! R# C" [4 {
    //printf("hello");
    2 s* m% o& u; W# I! X/ p! j//Sleep(1000);
    # y, K9 y) s! W2 a}3 O5 t, W8 R" S- i) A5 e! y1 L
    count++;' D" G- \1 T8 W% Y$ \8 ?3 f/ W7 _" }
    }) B" W( c" d, z
    if(systemClock==showTime)
    6 G) S* T- d, p7 q5 `# l{
    / A2 \/ O% c' O/ a; f/*PCI * p=FIFO_save_head;4 F  O. U7 x% Y: O1 M
    int i=0;/ {/ l* f0 r* N- S3 c" ]* R
    for( ;p!=NULL;p=p->next)3 R7 [: s# I3 U' z
    {
    8 L) M5 i7 r7 z! m1 Z7 D: H" v" R7 mprintf("Id %d\n",p->processID);
    8 W9 [. u% D( n# V. R$ Sprintf("comeingtime %d\n",p->comeingTime);
    / r$ Y1 U" X$ U5 L+ G1 B9 d$ h- q6 E+ Qprintf("runningtime %d\n",p->runningTime);
    ; k+ `; _+ I. \/ u$ x4 X0 v/ Dprintf("asdmemory %d\n",p->askMemory);- M, y2 A( O2 \6 K
    printf("completedtime %d\n",p->completedTime);. g6 {# `" A0 n4 I& `5 L& _
    printf("compute %d\n",p->compute);
    2 S, D3 h6 H+ Q  {) Dprintf("exchange %d\n",p->exchange);" O' N6 c% J& C3 S; j
    printf("waitio %d\n",p->waitio);4 U4 f1 ^: o; H3 w
    i++;2 r* @- e. I  d. x8 J" j& g

    # A9 k4 S1 h* E+ a2 o1 X5 h8 ~0 P1 V: ~% |" u
    }0 @4 Z, p: X! P
    printf("%d\n",i);*/& ]0 N% i( }0 r  V1 U! [4 _6 [
    if( (fp  = fopen( "data.txt", "a" )) == NULL )8 \6 k1 u. I  S: j# Y
    {; I$ Y; X3 k$ Z
    printf( "The file 'data.txt' was not opened\n" );
    + n+ u- Z) z  U) t; g& l. p//return 1;* M6 f9 _6 }7 M2 C8 H: C
    }
    + f* \# D! M% o- Oelse/ i/ _: T1 ?. T/ b' E
    {9 W8 v( T4 M/ M  J3 k
    fprintf(fp,"FCFS \n");
    ! J5 p5 D$ y% b% zfor(p=FIFO_save_head;p!=NULL;p=p->next). b8 E7 p$ f! ~. i$ g. q# P0 w
    fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    7 q) W3 k0 k, m% h3 c0 cp->exchange,p->waitio,p->runningTime);
    / y7 i$ L0 z3 |2 G1 e) i4 Cfprintf(fp,"\nTime turn \n");
    % _; U& F+ w  |6 l% ~1 cfor(p=Timet_save_head;p!=NULL;p=p->next)
    " h$ d7 e+ r( o( P( }; Pfprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,4 @6 r; Z$ z! H; {; U- j
    p->exchange,p->waitio,p->runningTime);0 B7 k  Q+ Z6 Z$ |) ^' r
    fprintf(fp,"\nShort Job First \n");/ |4 r; T0 w5 p2 r! R
    for(p=SJF_save_head;p!=NULL;p=p->next): x0 ]- N! H2 g# S& D) v* B
    fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,8 n; R  G' D+ z8 d  M: D+ O
    p->exchange,p->waitio,p->runningTime);
    $ X+ S* a2 X0 W7 Ifprintf(fp,"\nPriority  \n");
    : x" f! L+ g+ j, V8 @- {- Nfor(p=Priority_save_head;p!=NULL;p=p->next)
    1 j5 w1 I; l8 S' [. w: j# O- Kfprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,0 u8 e* k7 n7 {; N- H' V8 T
    p->exchange,p->waitio,p->runningTime);, v( o8 O+ J% a& V) ?0 v: @
    fprintf(fp,"\nHigh response \n");
    5 r* F  Y5 F( ~5 l4 K% E4 Q% Qfor(p=HR_save_head;p!=NULL;p=p->next)
    $ [9 H1 ^  z/ Lfprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,' H, j' j$ Q4 A8 {
    p->exchange,p->waitio,p->runningTime);
    / X! O+ D! B9 C+ ~fclose(fp);% ^2 M; ^+ a3 c! l, G
    }8 A& K0 {3 `7 J5 M; R
    showRunningResult(FIFO_save_head,Timet_save_head,SJF_save_head,Priority_save_head,HR_save_head);4 u- e8 V$ ]5 @- f
    MouseListening2(&flagDraw,&showTime);: v. z* ]* ]: N3 a' d2 o
    }
      d/ x3 w' L/ T3 F$ `* tsystemClock++;
    5 a5 e4 O, c6 Y6 i" w! hif(flagDraw==0)
    : @, K5 H- [& y+ y  Sleep(10);/ o" q1 S  F( `
    }" a. ^! Z) X2 ^4 j3 \
    ' v/ x+ R' K/ e/ c8 J0 ^

    , Q% y" ]8 \  E4 I/ y; O* `}
    6 h9 h" L+ t' ], Iint showRunningResult(PCI* FIFO,PCI * timet,PCI * SJF,PCI* PR,PCI* HR)
    . r! q% x2 B; \; C7 o9 [' L- }{; V* S. z! @' `& V) Z+ Z6 c
    PCI * p=NULL,* name[5];
    ) k; q% x; k1 }; ^; pint count=0,i=0;
    + p. S  O+ `2 ]& Z% Bchar ch[5][10]={"FCFS","timet","SJF","PR","HR"};. G2 R& G3 m( a* m! M" m/ G
    double turnover=0,wait=0,c=0,w=0,change=0,pos[4]={0,0,0,0};
    ( z3 X0 K! u6 k- S0 k5 Astruct info
    1 y0 L1 H* d% F3 A# j! r{8 G% L' o) F7 b( c9 J7 o! h2 `
    char name[10];- r$ r" u5 w& S
    double throughput,turnover,wait,CPU_rate;! i* w3 E; q2 Y/ j" V; b1 [
    }inf[5];# G. ?0 B8 X+ K  K' [7 X
    name[0]=FIFO,name[1]=timet,name[2]=SJF,name[3]=PR,name[4]=HR;
    ( u  K3 D/ I9 d) [; J& ?printf("调度算法..........A\n");
    3 e; g- H0 k1 v1 j+ kprintf("吞吐量............B\n");$ k& j9 Q& f- K/ I# l# D* H
    printf("平均周转时间......C\n");% w1 |7 i1 C  d( l/ H+ }: A1 u
    printf("等待时间..........D\n");
    , G" x( ~- k( V9 d# Sprintf("CPU利用率.........E\n");
    $ A* Y/ K* Q& a$ }+ F* Eprintf("A\tB\tC\t\tD\t\tE\n");) u2 j+ n% f: U# T
    for(i=0;i<5;i++)
    8 S( w* @8 S. p( _4 \{. ^: o  a# T+ @. N8 [, f! G, H' }
    count=0,turnover=0,wait=0,c=0,w=0,change=0;' W0 }( `( Y5 K  |% P. h0 J
    for(p=name; p!=NULL; p=p->next)) ?4 i6 Q, ?3 S
    {
    " H5 h, J2 @: Xcount++;
    ! K) a6 b. e( ?: Y* r  jturnover += p->completedTime - p->comeingTime;# C) e: x/ ^6 a
    wait += p->runningTime - p->comeingTime;" C  r& s# V& a& @& N! m+ [
    c += p->compute;
    7 ?; m8 q, R7 p, x" Qw += p->waitio;; e8 D7 k& `1 F6 r$ O$ w
    change += p->exchange;& g$ N$ n3 x) T
    }
    . l2 N2 R9 a* s, r) j+ eturnover = turnover/count;
    9 e* }# \' Z0 y8 ]- ?printf("%s\t%d\t%.2f\t\t%.2f\t\t%.2f\n",ch,count,turnover,wait,c/(c+w+change));
    5 E& D( }0 v+ x5 Nstrcpy(inf.name,ch);
    ) a* i1 k% a1 E2 F5 x6 tinf.throughput=count;7 D/ M. v/ T9 N2 o: ?! D  V3 ^
    inf.turnover=turnover;
    4 h( r& }) T/ G9 f2 ]inf.wait=wait;
    $ |* t. Q( r- k5 ginf.CPU_rate=c/(c+w+change);
    6 R/ k2 y3 ^4 I7 ~: x) }}
    7 j' F# ]  H  N2 [* h+ d//画图- e  L4 ^/ t( L- b! k) {# Q! x
    //cleardevice();
    * L8 J- q' R7 j% w! x$ x4 Eline(0,600,1200,600);) }) M' Z8 ~2 H
    line(10,600,10,200);2 _5 g& H2 Q+ v* l& K7 @
    line(10,200,5,205);* O% Q1 g' n, ^9 x' ]9 d
    line(10,200,15,205);
    % w7 ~# v/ s5 v1 fline(310,600,310,200);6 M' b7 X3 o& W. K+ q& z
    line(310,200,305,205);+ c2 ]) I# @; z* }7 p+ j
    line(310,200,315,205);) v+ B4 i/ P8 Z1 B8 @0 a# B5 r
    line(610,600,610,200);
    3 W" z4 W0 d+ S; u  x5 wline(610,200,605,205);
    ; ^! x8 n9 y4 Zline(610,200,615,205);' l( e1 D- S- M% O
    line(910,600,910,200);
    ' p0 j: X8 m! b5 z# tline(910,200,905,205);; B" j+ Z- g$ |. B  h' k9 {: _
    line(910,200,915,205);//最高的长度400,宽度均为40
    ! m5 K/ V0 {& G; u3 e5 Kfor(i=0;i<5;i++)" T; Y6 S; y4 d( W
    {& I( v# f; X( [6 |" v- z
    if(inf.throughput>pos[0])
    1 b* v' i$ X3 D  S% Cpos[0]=inf.throughput;
    + ?1 T$ v2 h2 ~3 F3 _) dif(inf.turnover>pos[1])
    % Y; Q5 S+ p: N! N3 [# rpos[1]=inf.turnover;
    + s7 p2 b- U3 {- m2 v" ^if(inf.wait>pos[2])
    + f, B+ r  E' Qpos[2]=inf.wait;5 z+ @0 T" a* f) Z2 J, O& E
    if(inf.CPU_rate>pos[3])* a" F+ U' l2 c, |1 I9 @$ r* c1 }# j
    pos[3]=inf.CPU_rate;1 x1 w: N, |4 U8 h9 `  A1 Q
    }  P- I5 G) e9 D9 l8 m) ^; z
    settextstyle(30, 15, _T("楷体"));& p. i/ L; P# j9 g* g8 Z' b- b
    for(i=0;i<5;i++)
    * S$ z( Z/ ?, m: f( ^9 k& ?, A{7 F8 x  w- z2 Q, ^
    switch (i)- N& G  h+ ]* T6 u5 @% G
    {
    + V" g6 Q! [  i( z8 ycase 0:' `. J0 i$ a: A2 u3 B7 |9 ?* e
    setfillcolor(BLUE);
      k) l7 D# y. b7 s7 kfillrectangle(100,50,150,100);
    ; k/ M/ a' V$ S( X" r% `* ?( Mouttextxy(160,50,"FCFS");' R1 a6 B7 G$ z
    break;
    $ k$ Z; B! l) f& o4 F+ ccase 1:
    % F- s0 q3 H8 _7 Bsetfillcolor(RED);
    ; ?, @  f( b7 |9 U0 W1 x3 ~fillrectangle(250,50,300,100);
    7 B% n4 G9 @0 a$ ?: u6 Houttextxy(310,50,"timeTurn");; I+ W5 ~" x  k9 r! F$ y6 M
    break;
    # e! J3 e' W5 Y: E6 L7 rcase 2:
    ' C: _' R8 k$ V: ^! hsetfillcolor(YELLOW);
    . e# k1 Z; z- q6 Zfillrectangle(450,50,500,100);
    , E- k. r4 W2 y& V0 ~: uouttextxy(510,50,"SJf");
    - C! g# n( P1 q: I8 obreak;
    ' D. S+ }9 U7 U2 }+ V* D, L' |case 3:9 x7 `  C. N+ w/ N; w; G
    setfillcolor(BROWN);$ {$ N- z3 L+ z0 h  n3 J
    fillrectangle(580,50,630,100);
    : V2 x8 X9 w1 i9 ~* P5 F% N9 Uouttextxy(640,50,"PR");. X8 g9 t2 {3 \7 z6 f- `0 c+ Q
    break;& {8 c/ e$ H- J* i, ?/ y! |' v+ y
    case 4:0 Y0 Z% M% n) U7 n
    setfillcolor(GREEN);5 n; n( Y5 f7 P( x
    fillrectangle(690,50,740,100);
    : @6 L+ n& k) i- B. Xouttextxy(750,50,"HR");
    + q  [) ~+ ]2 _$ `4 a0 u4 Q# ubreak;
    . [" ]' G6 r) H; b}1 o. y3 I2 x; z7 c  j
    fillrectangle(50+i*40,600-(int)(inf.throughput*400/pos[0]),90+i*40,600);2 o- j$ M6 f6 ]7 L5 M- J3 M
    fillrectangle(350+i*40,600-(int)(inf.turnover*400/pos[1]),390+i*40,600);2 ]+ w( @$ E9 ~  k/ [
    fillrectangle(650+i*40,600-(int)(inf.wait*400/pos[2]),690+i*40,600);! f% I1 \2 Q1 @: c* E1 B# ?; P6 B
    fillrectangle(950+i*40,600-(int)(inf.CPU_rate*400/pos[3]),990+i*40,600);
    + X! e/ S" U4 H; |/ ?6 t2 M) A7 w5 Q; f0 U* g  E" L+ H- g
    2 Q0 k' e. O" b( @, p7 T
    }, v5 x; s1 T2 e) Q! a
        outtextxy(100,150,"吞吐量");
    7 {) O/ F% V/ D4 M8 d0 l7 Uouttextxy(350,150,"平均周转时间");
    8 o' @" l2 |0 Z! j$ Mouttextxy(650,150,"平均等待时间");. _! \( ^0 l3 O2 h/ A4 {8 g
    outtextxy(950,150,"CPU利用率");
    / P4 r1 u% `/ \6 H  [8 c# g5 N5 \  `return 0;" [! j) }- l5 U) u( `. _# ^! \
    }* i% n4 G7 m! [1 ^4 E& F0 ]6 r
    int MouseListening()
    & f: v! T) r9 z{7 z2 @0 L8 V* Y& _8 r" w) k
    MOUSEMSG p;% v3 |( V0 S" m) W+ ^
    if(MouseHit()), a4 e) U' Z: P1 e
    {/ c. h  a8 t( R5 q. g- N
    p=GetMouseMsg();
    " B" M9 F/ G% d" \if(p.mkLButton==true)+ x* Q, e; l" Z4 A; c/ C* g% v' [
    {
    - ~2 o4 n9 o, i1 [4 Qif(p.x>0 && p.y>0 && p.x<400 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)5 k* o. ?6 d) I3 f$ r/ }+ q. ?& T
    FLAG_FIFO = 1;6 c7 x) S5 `0 i
    else if(p.x>400 && p.y>0 && p.x<800 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)) U4 {% N+ i5 d: i* [# K
    FLAG_TT = 1;2 S9 I- G9 o( ^/ m
    else if(p.x>800 && p.y>0 && p.x<1200 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)9 L$ Z7 ?& X9 s$ Q/ H- ~3 _
    FLAG_PF = 1;6 R' r; c4 T4 a' y( ^: C7 }! @
    else if(p.x>0 && p.y>325 && p.x<400 && p.y<650 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)
    + J) r, c5 }, x5 ]# nFLAG_SJF = 1;5 Y5 [2 y; |7 r6 f& C
    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)
    2 k3 s. v( f( z7 h; AFLAG_HR=1;
    + `) t" [1 ^' ielse if(FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO >0)
    1 r2 D  g+ n- }6 p5 X- Y{
    7 T5 |6 y! X& }8 xFLAG_HR=FLAG_SJF=FLAG_PF=FLAG_TT=FLAG_FIFO=0;
    $ J1 R1 v$ \$ g. X( Eclearrectangle(800,325,1200,650);. z7 ?; @, @5 C1 q6 I
    }9 Z( g+ p" H! ]$ ?0 ~$ T' l1 {, |
    else if((FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0 && p.x>890 && p.y>455 && p.x<1110 && p.y<510 )
      v4 R( B( s& L: k{5 X( h; w! R1 b+ z
    FLAG_show=0;
    ) [8 K  l' ?) F) r* H/ }cleardevice();- j/ V8 a: D& ]; j
    return 1;' C: J2 J) M* v" Q
    }- O' y/ B0 O6 m9 D/ e; F
    }
    ( n# m" z1 t+ s- S}
    3 G4 _8 ^7 x( S8 S' L9 oreturn 0;
    ' x: {( v# B, Q7 C0 z}
    * w" b& J( h9 X0 iint MouseListening2(int *flagShow,int * showTime)) S5 M, q* T1 s9 d
    {
    8 b6 @( M: ?4 M4 }: m5 ^" aMOUSEMSG p;5 A& m& q8 w; |: z# A/ I
    rectangle(1150,0,1200,50);
    - h, `& ~0 X, H# `/ w8 M; z9 A7 pouttextxy(1160,10,"X");
    $ x2 c3 ^/ y9 k$ Q  F/ B( Zwhile(1)
    " _. S# G! j3 S/ \. T, m6 J) c{
      S1 J6 B6 L6 X& e' w0 Eif(MouseHit())) e: Q7 s( i4 V* @' b9 s
    {9 I4 P) ]; E$ }- Y" J: Y
    p=GetMouseMsg();
    + `0 W9 _( L. j/ m! I9 C) F$ `if(p.mkLButton==true)! ?' i7 N7 p2 |4 O+ l, {
    {3 S& y4 ~( J" \. S
    if(p.x>1150 && p.y>0 && p.x<1200 && p.y<50 )
    2 @! F, A8 P% K! ]{
    8 u; [. N2 X3 d( ~# L(*flagShow) = 0;
    7 O" Q+ L/ b- p$ Y7 J6 K& U(*showTime) += (*showTime);
    ; _; ?% u- [* pFLAG_show=1;
    4 n2 |2 F; e) f& ~7 l1 o, e( _break;- Y: F% A) R  B# Q' R! s
    }
    : p4 ]* q# s# C9 g5 N' Q
    3 B! i7 l" `- e}
    1 u; l' ^  {- G9 r, N/ r}! V+ A2 k2 n5 g! A9 s
    Sleep(20);* d. ]7 K- Y+ w+ w3 Y& Q) t- F
    }
    $ l2 w6 J6 X2 V$ T8 U' b6 }cleardevice();
    ( R! l6 P* b4 E8 i4 p% e; kreturn 0;
    8 ^6 q1 H: @* }) n9 W}$ `( ^7 r( }- f& Q; O
    int drawPerformance_FIFO(int x,int y,int memorry,int com,int wai,int cha)
    7 T" {3 j: P. h+ V+ M{' K1 B5 K. y, D3 x; ?( h
    static int info[11][3],num=0;
    1 @; M# T' V9 |! h4 yint i=0,j=0,pos[10][3][2];. a5 b" t! w% I5 z; A$ V9 c7 o, l
    float temp,t;
    , ~+ T( `$ d- T/ \2 w//画按钮,不属于FIFO图的范围. Q$ P# ]* k/ _6 L% w+ C
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0 && FLAG_show==1): l$ `" R- _7 I# }0 f) l
    {
    $ f9 o$ T3 @# a" `( j* ~settextstyle(30, 15, _T("楷体"));* H9 ]% e! E* r7 a8 I
    rectangle(890,455,1110,510);
    & d  K7 V, S% ~& Y+ v7 R! n: orectangle(900,465,1100,500);
    * n2 H( D; _. j# U0 [( N, Bouttextxy(910,468,"查看运行结果");# F! n: |! u3 v% i' |. ~
    }
    ) H& m+ l$ |0 W) d//结束画按钮
    , C; U) A) R3 @/ w' Pinfo[num][0] = com;
    ; J6 E4 d  C$ W% zinfo[num][1] = wai;: o" Z3 f$ d0 z, M
    info[num++][2] = cha;
    8 Z6 D, H: g5 dif(num>10)  //存储10个点* B/ n  v- _2 p& V5 Y3 a4 A
    {
    6 T/ N* W, t' |3 w3 pfor(i=0 ;i<10;i++)) @  `: R7 |9 v# F5 r% h! H
    {9 r' I/ y: K4 {! C8 l; e
    info[0] = info[i+1][0];
    ' K0 y9 n( C1 C! Ninfo[1] = info[i+1][1];" O( G  A$ c2 O. d' V2 R: C7 h
    info[2] = info[i+1][2];  m3 C' e: Q+ \% D: ]. K, M
    }
    ; R  _  _  j! e9 ?- T. \num--;6 V' d, z2 r7 @4 P& G: f1 E
    }
    ( I) }6 C* n4 d. \' s, Jif(FLAG_show==0). `# N7 J& @( c& N1 r$ `: G
    return 0;, q7 Y' y9 s* l) f5 h- G6 ?
    for(i=0; i<num; i++)3 h& J+ z5 O! f- q2 n/ ]& a8 w9 \
    {1 d2 [6 ]! H4 A5 o
    t = (float)info[0];
    3 p6 J: l' i1 b( J) e7 b! xtemp = (t/101)*90;/ f: b0 w  o( [$ A7 L& U
    pos[0][0] = (10-num+i)*25+x+100;
    9 s% v$ Z6 z, {0 A2 |- D0 k. N# g0 Upos[0][1] = y+110-(int)temp;. ^0 i# a& R2 M# K! C
    t = (float)info[1];
    : e& v2 S# o& K) F5 ~6 V8 V# rtemp = (t/101)*90;
    : L; o( L, f2 y" dpos[1][0] = (10-num+i)*25+x+100;: V: ?+ |' v; ~/ O
    pos[1][1] = y+210-(int)temp;8 d$ o' _- n; o- ?1 Z+ Y" G
    t = (float)info[2];* s; |! R0 N. x! E" V5 A& W
    temp = (t/101)*90;
    ) ~5 u8 \7 o9 z6 d4 J6 Y  p+ \8 f. Fpos[2][0] = (10-num+i)*25+x+100;
    $ P& a+ x. g! @, W' C) ppos[2][1] = y+310-(int)temp;0 I* i" q8 t# a0 S$ [4 P
    }
    ) j0 Z, o1 A/ o9 M, a2 pif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
    $ ]4 V2 T5 S0 [  M/ ?2 x{7 a4 v& M0 a/ E7 O4 u5 S
    clearrectangle(x,y,x+400,y+315);
    ! M  F) H3 `- O) z( Dsettextstyle(20, 10, _T("楷体"));
    * r5 P1 I* a- L5 Q/ a- ^6 Z+ Drectangle(x,y,x+400,y+325);/ g% M4 h' p) n% `! D7 Q
    outtextxy(x+40,y+10,"CPU");       //画柱状图
    2 S- i/ w/ g4 Eouttextxy(x+45,y+10+100,"IO");
    " q$ X4 W' r$ [+ y8 E6 a" Kouttextxy(x+40-15,y+10+200,"change");. O- D+ Z' o4 f' o; k" P  O# _
    rectangle(x+35,y+30,x+75,y+110);, b1 m, X. O" }$ L4 X& X
    rectangle(x+35,y+130,x+75,y+210);7 g, c( d7 U( W* M* Q: D/ o$ Z" t
    rectangle(x+35,y+230,x+75,y+310);4 L; f, \' p, C3 b" k8 q! V
    outtextxy(x+180,y+310,"FCFS");; ^" g6 ^0 h  b. a; S; Y
    t = (float)com;
    " p. d8 J( P) ]& s1 `1 Wtemp=(t/101)*80;8 m: N9 w8 v" e
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);8 s+ t2 s+ ]+ E- A: f! G
    t = (float)wai;$ J, O+ C* M+ Z" h; D
    temp=(t/101)*80;0 Z2 `; S/ h; q$ V
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);5 l$ C4 R0 z9 z! b* R; I
    t = (float)cha;
      ]7 r, a" @& r5 G* y- R% Ptemp=(t/101)*80;
    . q: w4 l7 D" [fillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    4 x1 q9 }! Z: xfor(i=0; i<3; i++)   //画坐标   high=90,length=250) V" H  e# V- ?2 i' b
    {
    & b( Q% C' a2 y, t6 i8 }+ wline(x+100,y+110+100*i,x+350,y+110+100*i);( U# \/ s2 L& V/ _# C
    line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);
    . i- v% z$ Z2 h! Aline(x+350,y+110+100*i,x+350-5,y+110+5+100*i);
    * `* c4 U8 ?% g8 t* [
    5 s6 F5 V/ }9 X# y4 _line(x+100,y+110+100*i,x+100,y+20+100*i);
    + _, x: h/ C% H% W9 Q4 hline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);
    , r# ^4 y9 z7 w0 C$ xline(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
    + G3 P- |5 B# r7 g& Dfor(j=0;j<num-1;j++)' D6 K4 m/ H2 n8 _8 m
    {! ~* Y! ?: z) y1 ^# X( e% K/ a
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    ( K% ^7 s, I7 s! ?line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);5 O, m! h3 L& @
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    + v' n) O: T4 u2 y6 f  \" g}" o7 K) f1 L- [, ^6 W( F; Y6 D
    }9 Z( R" e* z6 H/ W
    }
    1 _2 ^7 y: Y& a6 belse if(FLAG_FIFO==1)( D0 K  s, ?6 }6 I% Z0 O+ x
    {" ?# E+ Z) A$ k4 W
    x=0,y=0;) i5 _' x: G6 u( L4 ~$ j1 B
    for(i=0; i<num; i++)( [2 E& n$ n! q
    {0 m& ~; F( }  z( ~5 K4 a
    t = (float)info[0];
    * F0 n. ?! |9 L0 ytemp = (t/101)*180;
      b) @6 p  e0 M, [& cpos[0][0] = (10-num+i)*50+x+650;
    1 Q6 h" X& s7 w# i! _/ hpos[0][1] = y+210-(int)temp;
    6 E2 C( h! V% q4 `3 Y  l5 t. gt = (float)info[1];
    ' X7 l6 z9 ]$ C+ _4 ?' ?- ltemp = (t/101)*180;% G3 r' q" `7 Q9 k
    pos[1][0] = (10-num+i)*50+x+650;
    1 A" |9 L; Z% E* @$ T' R/ bpos[1][1] = y+420-(int)temp;
    ( M' x* p; J- D. K, Dt = (float)info[2];
    ' g0 k! V- |& Xtemp = (float)(t/101)*180;
    ' n) o( j: A5 L1 C/ x: r2 lpos[2][0] = (10-num+i)*50+x+650;2 {; o& y. e( `4 a* B
    pos[2][1] = y+630-(int)temp;; [! I4 {# n5 B! S- E! v; h
    }1 B: f7 [) Q/ r+ Y# z
    clearrectangle(x,y,x+1200,y+650);+ m' u3 {5 }( Q
    settextstyle(40, 20, _T("楷体"));0 M& L/ y; ~0 c- Z+ y& M
    outtextxy(x+50,y+50,"FCFS");
    6 {. D$ C6 f# P3 U6 ?6 Youttextxy(x+280,y+20,"CPU");       //画柱状图
    4 j/ ~; S: m5 \  B( j" |1 Vouttextxy(x+285,y+20+200,"IO");. u& _" |4 T$ e: `$ S& c2 R; U
    outtextxy(x+250,y+20+400,"change");6 T8 m3 g& w* X
    rectangle(x+270,y+65,x+330,y+215);
    & m# M4 y, h" W, Hrectangle(x+270,y+265,x+330,y+415);  Y- G8 `% `. S3 ^1 \
    rectangle(x+270,y+465,x+330,y+615);
    7 k( G0 Q3 F3 B& F3 m. \outtextxy(x+290,y+620,"TT");, A- ^" I' o1 i/ l. o- ?6 u( I2 Z
    t = (float)com;' g' p) E/ Z, q6 B" s
    temp=(t/101)*150;, k/ E9 {$ n- Y1 J& _
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);) O! B3 p" k( H9 _5 q
    t = (float)wai;4 R2 i( `+ i$ n! y0 i9 {& x1 h( ]' e/ y
    temp=(t/101)*150;' \7 r4 B/ c  a# H1 {, p
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);8 E7 B* f* X0 p
    t = (float)cha;1 n- Z0 ~: M: R/ v2 b( \, \
    temp=(t/101)*150;8 ?" o8 a! M5 [7 T/ u
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    ; J1 q, {1 Z9 W% m0 `( a6 b- z$ `for(i=0; i<3; i++)   //画坐标   high=90,length=250# b# w# W) ~5 g* o
    {
    . ^6 r* I7 a2 D' Xline(x+650,y+210+210*i,x+1150,y+210+210*i);0 ~: X0 p# \, ~0 ]) n; n% u4 t  R
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);& R! S; M! w1 |! }+ |1 q* T
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);! _( M2 `4 E, b2 S6 B

    + e' p, H/ z/ bline(x+650,y+210+210*i,x+650,y+20+210*i);
    ( \( W! @" A( Y3 P6 ]/ W6 oline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
    3 f% I( L" y4 B6 F; Fline(x+650,y+20+210*i,x+650+10,y+20+10+210*i);3 X( {% b/ X6 @; ~+ z
    for(j=0;j<num-1;j++)1 _- c8 m* e" p3 K
    {  @" V; i, U& m  j' s4 {
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    ) r! J; ?% k( R. N" u' E7 T' L# Bline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    6 ]) Y+ F# J* z1 nline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); ; @" U- P+ D. l( J9 N7 f
    }
    9 w4 B* ~  k6 m* j}6 n7 H  M( A% V$ w- m- E/ t4 }' w
    }
    - b* a4 K" F+ u* I8 f8 r
    % [) x* p, O( {  m8 S1 v: c6 X
    - ^. v  ]+ e4 j' k8 g8 C8 Xreturn 0;
    7 R6 J) `9 g: z% N& P. N# L+ \$ g}
    1 I) `& V, x" e. ]int drawPerformance_HR(int x,int y,int memorry,int com,int wai,int cha)
    * T* G4 y) a5 y6 Y$ C{
    6 ~0 r/ @7 y; z1 Ystatic int info[11][3],num=0;( z' G1 Y" A% T3 g! v& w
    int i=0,j=0,pos[10][3][2];
    6 S3 G) Z4 R/ _- L+ rfloat temp,t;
    9 f) t) K5 `3 Z: {( Y0 U  c: Uinfo[num][0] = com;2 ?6 V/ _' ]% C3 w
    info[num][1] = wai;
    ; D" k: }+ V$ B1 b8 d8 y, Qinfo[num++][2] = cha;
    0 _5 K$ N6 p# s. t* N" x5 Iif(num>10)  //存储10个点
    9 |* I& E% Z* w" _* z9 d{; W* U8 [. u$ Q2 `6 f3 @# m% w, O
    for(i=0 ;i<10;i++)
    ) ?5 [8 n$ O* F( d{
    & S* T* X, f) O! c" m& Pinfo[0] = info[i+1][0];: w/ h4 M# D. f6 b* {7 s$ H
    info[1] = info[i+1][1];+ a7 I/ B) i8 B" J3 }& v5 Q
    info[2] = info[i+1][2];
    ) y9 @' n& y3 S( Y4 @- d0 m}
    9 w2 J- O% n6 {6 d2 _: A/ h+ m1 `num--;
    : \, e) A5 l& f}
    ! l/ E! d; D7 W& y+ ~, X1 ]' M. Nif(FLAG_show==0)
    # r9 _4 r2 I) n& I$ [return 0;$ D; S3 x1 y8 }( L
    for(i=0; i<num; i++)  c; [" X# X0 U1 J
    {
    5 W  J3 n3 c8 R. W2 et = (float)info[0];6 w7 L, k) x. ^8 T8 y2 z* q
    temp = (t/101)*90;: {6 e, ]/ e6 H+ ^9 N  C1 Z
    pos[0][0] = (10-num+i)*25+x+100;: J' U% K- |  ^6 X
    pos[0][1] = y+110-(int)temp;' Z2 x/ \* M- z# c
    t = (float)info[1];
    : T+ q1 W, G6 Jtemp = (t/101)*90;* F: [. R5 n7 i! x
    pos[1][0] = (10-num+i)*25+x+100;
    , A, Z; X1 F" _/ D* jpos[1][1] = y+210-(int)temp;
    6 V& X7 h# o* X' j& S/ kt = (float)info[2];5 H) m2 |# A' |: |! Z  a
    temp = (float)(t/101)*90;- j( f5 g4 E0 `! m6 q3 A3 s9 Y0 d
    pos[2][0] = (10-num+i)*25+x+100;
    " Q) R6 P6 A; ?+ Y( U/ ppos[2][1] = y+310-(int)temp;
    % `6 r8 E+ w* A, E& y6 f}
    3 C. _5 v5 I: `" l% E4 Lif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)& b; A" g) |- W$ N* P* n) a
    {
    0 \. d' E+ U! g# d! l; y5 ^clearrectangle(x,y,x+400,y+315);' b5 J5 }& y8 ?* y& S  ~
    settextstyle(20, 10, _T("楷体"));& N: N/ l$ C4 ^2 z2 K
    rectangle(x,y,x+400,y+325);
    / i# y7 \$ p; V! O& C% B. T9 T, U/ oouttextxy(x+40,y+10,"CPU");       //画柱状图. D9 [- N* w9 R+ z3 {
    outtextxy(x+45,y+10+100,"IO");
    : H$ w" O6 r% G0 Couttextxy(x+40-15,y+10+200,"change");
    7 ^+ P. `9 A7 K- _: b# k; Grectangle(x+35,y+30,x+75,y+110);- d: \, l0 d5 K6 R( \- m9 a
    rectangle(x+35,y+130,x+75,y+210);8 w4 U( C, V# u4 G4 k
    rectangle(x+35,y+230,x+75,y+310);& M$ J5 P7 J) l1 ^
    outtextxy(x+180,y+310,"HR");
    & U! _: z: g2 s0 |6 Zt = (float)com;& t7 h2 [2 n4 u
    temp=(t/101)*80;& Q1 i* S9 ^& r! M* q
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);/ D. l+ U+ {; B! g& k) y+ ?' J$ M
    t = (float)wai;
    ) X. @2 [3 d& ptemp=(t/101)*80;
    ; ]  U4 `  b% m4 z# Ifillrectangle(x+35,y+210-(int)temp,x+75,y+210);8 M, `; U0 x6 Y8 l, X
    t = (float)cha;
    2 J7 C3 _# p- T7 Stemp=(t/101)*80;+ z$ z6 s- s  t7 T# w
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);. s, {& k; Q) R1 d6 z. R$ H
    for(i=0; i<3; i++)   //画坐标   high=90,length=2508 b) T" p; k9 B1 R' F7 ?
    {1 B% l/ b8 \7 L& ~
    line(x+100,y+110+100*i,x+350,y+110+100*i);! j6 f$ p0 u7 x' Q2 n/ g
    line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);6 {) |! @" c  \+ v2 c
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);
    / k! d5 Y5 W1 O  R3 m& @- A5 R
    $ A5 u$ a, M: |. p; Q/ @line(x+100,y+110+100*i,x+100,y+20+100*i);" g' q: d, o6 c
    line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);' S7 c+ X& m% v3 p# G" h, S
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);2 }2 X6 c8 R: i" A8 a
    for(j=0;j<num-1;j++)
    ; @- Z/ ~: Q& J4 m{
    9 Y& E" J9 M$ c) c9 S9 aline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);2 a( Z: g+ m  ?& v' y
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);: q! I& R0 S3 a9 x  n
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); 8 \& q5 o$ v& o# ]/ O
    }0 V& |4 x5 O; u
    }
    $ d* F( T9 l4 M) T$ X}
    # E1 J$ c5 J$ N% U/ Z# Y8 qelse if(FLAG_HR==1)# W6 }$ h% k% s6 \
    {
    0 ~, P  B0 h) u$ ~x=0,y=0;
    ; H/ H2 F2 E+ P- e+ pfor(i=0; i<num; i++)
    . S% z; V8 y; ^7 |/ c{
    / e; c6 _9 Z) t0 r3 P/ U! x( ct = (float)info[0];
    , N0 Y6 @  M6 Q% L# Stemp = (t/101)*180;+ K4 i6 q/ a; _% g
    pos[0][0] = (10-num+i)*50+x+650;
    ! W" G1 N$ D- ^) z' Y* Bpos[0][1] = y+210-(int)temp;
      X& |+ W' S4 L; c! |$ Ht = (float)info[1];
    & n+ K# ~! f' x8 B% ]$ p& i9 j; utemp = (t/101)*180;: C) u; A1 W' O8 T
    pos[1][0] = (10-num+i)*50+x+650;
    4 J% N4 m9 o: m" Q* N! T. Gpos[1][1] = y+420-(int)temp;( F7 V4 w6 ?  g! Q/ f" t8 g
    t = (float)info[2];
    : B: D3 p0 c7 ^) }3 e- otemp = (float)(t/101)*180;
    * ?1 `: l) k# H% I' V7 epos[2][0] = (10-num+i)*50+x+650;5 G- ~7 @+ w/ D6 c; U' `: t6 O
    pos[2][1] = y+630-(int)temp;
    2 S( V5 j2 t8 h9 U; @7 h4 Y}
    $ ?2 u; H( y  c5 _% w2 _/ @clearrectangle(x,y,x+1200,y+650);. d' v1 ^1 S0 h
    settextstyle(40, 20, _T("楷体"));
    & ^+ W: l- x, p% y# fouttextxy(x+50,y+50,"HR");  h: Y# q! d5 I/ L* w8 c+ z
    outtextxy(x+280,y+20,"CPU");       //画柱状图  p$ f$ A4 Y4 S; S8 d2 r! D! W
    outtextxy(x+285,y+20+200,"IO");) J+ i4 y; q1 ]- v4 Y1 j& r
    outtextxy(x+250,y+20+400,"change");
    + G3 Y: ~- m- r4 c" u9 xrectangle(x+270,y+65,x+330,y+215);' ~! y" }6 I9 H- e8 }
    rectangle(x+270,y+265,x+330,y+415);
    4 ]( v4 w! s0 u5 q6 w7 yrectangle(x+270,y+465,x+330,y+615);
    8 }/ o: ]% v' i7 @outtextxy(x+290,y+620,"TT");$ C4 [8 B0 F5 X3 J+ X. A- P
    t = (float)com;( N8 j, m; L& _! |6 W9 k
    temp=(t/101)*150;' S0 v" y# v1 i- f& J
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);
    2 m, I( d' N8 R$ w" \t = (float)wai;8 ~# j' n: _0 a
    temp=(t/101)*150;3 i/ `7 w3 _! ~
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);
    * A6 L, N* L$ m" r/ Q: lt = (float)cha;
    6 B8 V, C& W& n* r* ctemp=(t/101)*150;* l# w; n1 F1 [
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);" C4 \% D( a7 S& U" o
    for(i=0; i<3; i++)   //画坐标   high=90,length=2506 t3 j4 O% L/ p$ z
    {3 |! f! ?% [& W" I5 Z0 Q
    line(x+650,y+210+210*i,x+1150,y+210+210*i);
    $ \, Y+ E+ }% [! }- g) oline(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);7 h& t: z- h1 z$ `, X9 S4 z/ R. ^
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);# J& s8 A. l0 q7 {; b6 A) ^

    2 Y( U# v9 D) c+ ?* [  Y6 ]( n2 Fline(x+650,y+210+210*i,x+650,y+20+210*i);+ \' P1 E) g! L3 p4 B% F3 A$ X" l
    line(x+650,y+20+210*i,x+650-10,y+20+10+210*i);, D% o  p0 K9 m; r" ?( y
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    % W5 c. R+ M. [9 v; V  S$ G6 L' Gfor(j=0;j<num-1;j++)
    , \& _0 f/ b3 r; A{* W. C9 i- L2 S, \2 h- _4 l
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);9 ]# `( b5 P1 S) B
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);  {1 K; p- j: \% {' h' U
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    4 \' l& e/ ^; P1 G# a3 g( y}
    1 q3 f2 m1 q- [' b}
    # G1 @8 ]2 K" U& T/ S}
    - W& r( U5 e' _7 `+ ]$ [. q8 n
    * K& @# f( h  M! F: z# A/ A, v* B% p) [3 g
    return 0;! p. D8 S5 L* N; o
    }
    * @2 h! e3 E/ B& j# ^6 h" h+ ~% _int drawPerformance_TT(int x,int y,int memorry,int com,int wai,int cha)
    / _6 X" P* A" f2 P2 d  Q4 b{
    # u3 k# p" l% `3 n7 Ostatic int info[11][3],num=0;# K: A0 H- K  J4 A6 g$ ?& o% q8 A' _/ l% C
    int i=0,j=0,pos[10][3][2];
    - V" Q# V0 U3 w- M# s# f& lfloat temp,t;
    1 W! H+ q; w! l% Einfo[num][0] = com;
    ) J' [; Q+ G# t) W; o6 [0 L7 rinfo[num][1] = wai;
    $ V7 o* F' @* n4 Ginfo[num++][2] = cha;
    & [0 Y* F* T: R- s) E  Fif(num>10)  //存储10个点
    , ]- q* o6 A' b2 q3 O{1 }0 |+ [6 l! u4 \
    for(i=0 ;i<10;i++): a+ x5 W) ^1 S7 k
    {$ d; J' J2 W3 J8 A6 D" c" H0 ?
    info[0] = info[i+1][0];1 S8 {- x/ _! C' l
    info[1] = info[i+1][1];0 @3 `: h# H9 x- Z! }4 P# W; `4 e
    info[2] = info[i+1][2];) b! ~4 c( I# S. G$ }; R" H/ S
    }
    * u4 h  t& g* K9 i! Vnum--;
    ; }4 U( q6 _/ g8 L( @}
    1 ~* p" K# r8 {. U, d% L' |: V3 wif(FLAG_show==0)1 b8 j/ M" \# N
    return 0;
    9 D5 v/ D0 H/ J  I9 @8 w8 @. f2 p% ofor(i=0; i<num; i++)9 M6 n# Y1 M' l0 k+ P
    {
    + }4 ^$ k% w. P/ p2 ]. N9 i2 s0 Ot = (float)info[0];
    3 b9 l3 q  I# w0 z8 x# etemp = (t/101)*90;8 L( P% H/ S  H
    pos[0][0] = (10-num+i)*25+x+100;
    9 p4 q, |, j  D3 |! D2 \- k/ jpos[0][1] = y+110-(int)temp;
    ! d& J0 P3 C2 D* [& Y+ q+ wt = (float)info[1];
    - V% z. x5 e; m: {2 m  \* i- n" Jtemp = (t/101)*90;
    0 ?# ~& i# ]8 i/ {pos[1][0] = (10-num+i)*25+x+100;
    $ D' W, {2 [* C" a  \pos[1][1] = y+210-(int)temp;! n$ q" d4 ?% n9 H
    t = (float)info[2];
    & m( N& h, Z$ p: M+ Etemp = (float)(t/101)*90;- E) _/ C% m8 q4 L; M7 i' Y
    pos[2][0] = (10-num+i)*25+x+100;0 l# O# g; c. C1 z- N9 m# h+ p
    pos[2][1] = y+310-(int)temp;4 ?* A2 {" H3 }7 F% V  B3 F8 N+ I
    }
    ; i# w" Y7 I; q+ c2 l" M! S9 nif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)" j* j" i( m$ B. R5 v
    {
    ) h9 o* r' _0 m( T; X! d' o. N: Dclearrectangle(x,y,x+400,y+315);' ]* l! }  H' A
    settextstyle(20, 10, _T("楷体"));
    3 x; d8 Z: P! d1 Lrectangle(x,y,x+400,y+325);
    : {4 S1 A+ H1 `outtextxy(x+40,y+10,"CPU");       //画柱状图6 C# [/ b$ @6 v( T1 S
    outtextxy(x+45,y+10+100,"IO");
    " J2 s# G# n0 douttextxy(x+40-15,y+10+200,"change");6 \2 L7 N$ l, e% g7 r
    rectangle(x+35,y+30,x+75,y+110);
    3 k+ V/ b3 c7 @/ a* }  q) f' Zrectangle(x+35,y+130,x+75,y+210);
    * j, K2 p4 A* @% grectangle(x+35,y+230,x+75,y+310);- Y# D0 o+ z- I8 a- V
    outtextxy(x+180,y+310,"TT");# M8 m- L' P' L4 C( ~- W, {
    t = (float)com;+ b4 W& H! j# [  X1 Y
    temp=(t/101)*80;
    ! J3 f" g9 m5 w0 P0 }: u( e; o  yfillrectangle(x+35,y+110-(int)temp,x+75,y+110);
    2 A1 \$ b* E1 r9 P1 t; j, q/ bt = (float)wai;- u' m# ^' J4 A- f, I, t3 B$ S( E
    temp=(t/101)*80;
    ! }' v0 B$ F& _6 }5 R; h* jfillrectangle(x+35,y+210-(int)temp,x+75,y+210);% J9 J" O& L8 y
    t = (float)cha;8 C& u0 j! G1 ^
    temp=(t/101)*80;
    2 Y2 Z* K# l2 l2 ~fillrectangle(x+35,y+310-(int)temp,x+75,y+310);$ Y4 g& L  O0 W/ {
    for(i=0; i<3; i++)   //画坐标   high=90,length=250) h- P5 i4 r  a% u/ e* e
    {
    ; c5 A+ J& S: M9 ^( A' {line(x+100,y+110+100*i,x+350,y+110+100*i);
    0 D+ ^* E7 v% x* A8 kline(x+350,y+110+100*i,x+350-5,y+110-5+100*i);
    # m, g* |- E3 F- R6 nline(x+350,y+110+100*i,x+350-5,y+110+5+100*i);. Y1 U6 C3 @- T+ l2 }. e

    ; H+ M  S# ?+ d6 Q+ gline(x+100,y+110+100*i,x+100,y+20+100*i);
    4 P. U0 J+ C( e' Y0 ~% Xline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);
    , U+ ]" z6 k4 K" j) p7 G. N5 nline(x+100,y+20+100*i,x+100+5,y+20+5+100*i);; x9 t6 `$ r7 m5 q( g5 F/ W
    for(j=0;j<num-1;j++)
    2 _* f' H' J% g; N( l{
    % @6 d" I3 V& b( T" ~# zline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    " [, O% K# K0 ]0 Iline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    % O4 P# p( I4 T+ E  Tline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    , T; M. R) z$ M+ W}3 c4 L3 Y8 W+ s) r: N3 S4 b/ T' g
    }4 U4 }6 S3 X% j6 e9 @% _
    }
    3 q4 ~+ c! {+ ~& V3 w% ielse if(FLAG_TT==1)
    ! v. w# v" I- z' ~6 e$ M$ }{
    ' N$ A$ C, B- nx=0,y=0;
    6 t1 b  q+ ~' q# @' ]* h0 C9 Afor(i=0; i<num; i++)0 c6 {5 R1 _6 O5 F8 }# P
    {
    ! v# E# e, h: l0 u: D  J9 Q  }t = (float)info[0];
    ! I2 \/ j& j9 ]+ y0 F% @' p( Ttemp = (t/101)*180;8 X$ ~0 ?  x: `
    pos[0][0] = (10-num+i)*50+x+650;
    , |5 H8 s2 g; o# F6 t- m0 n4 \8 `pos[0][1] = y+210-(int)temp;
    / }9 h0 i% H) Q0 N4 ]. f0 ot = (float)info[1];
    ; L6 R& k* s" {temp = (t/101)*180;
    : ?0 T/ i! {! Y) r$ U3 }) i. spos[1][0] = (10-num+i)*50+x+650;
      r% H' p5 S/ i2 epos[1][1] = y+420-(int)temp;
    9 G  _+ H9 N. `! u& t3 |* w. \t = (float)info[2];: S0 p  n3 w) n
    temp = (float)(t/101)*180;
    5 }+ B4 ^7 j6 k+ B$ X* _pos[2][0] = (10-num+i)*50+x+650;
    ) l: c; a3 o0 g" w# K8 ^* Lpos[2][1] = y+630-(int)temp;  P1 u) ?! y  S7 A
    }* m6 A0 C/ u* Y$ A. y  r0 o+ k0 a/ g; f
    clearrectangle(x,y,x+1200,y+650);
    ) s! |" c0 b/ [8 ssettextstyle(40, 20, _T("楷体"));
    $ s& l9 C) o$ e0 }: O6 Z% e1 ^outtextxy(x+50,y+50,"TT");
    - L7 Z4 _. H7 n+ ^% aouttextxy(x+280,y+20,"CPU");       //画柱状图8 [' h4 w4 s0 i& p4 [5 n* k
    outtextxy(x+285,y+20+200,"IO");$ y/ t2 Q. M/ \. Y3 o; R/ A& W9 T; N
    outtextxy(x+250,y+20+400,"change");
    5 b' m+ g  L6 f$ j3 Wrectangle(x+270,y+65,x+330,y+215);$ d6 a" }7 ]" x, C9 g0 ^
    rectangle(x+270,y+265,x+330,y+415);$ l0 f9 z' P$ N( }* p' M5 _0 B; |$ c+ d) u
    rectangle(x+270,y+465,x+330,y+615);
    % s7 o- @6 L) z) W2 nouttextxy(x+290,y+620,"TT");2 W" l8 \" C& P/ v5 x# X6 S0 Y  Z- G
    t = (float)com;+ n% i  n4 V$ A
    temp=(t/101)*150;
    - K# [& e, _0 wfillrectangle(x+270,y+215-(int)temp,x+330,y+215);7 }0 z7 }' l5 d% a
    t = (float)wai;
    7 X7 V$ a" U& m7 Mtemp=(t/101)*150;9 o6 I# N/ Z3 [$ u
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);2 N; Q: T7 `+ \2 Q1 Y
    t = (float)cha;
    ( _0 \) d7 w. l& d" V9 p8 |3 j0 Ntemp=(t/101)*150;
    % q$ N+ _' z# B# @fillrectangle(x+270,y+615-(int)temp,x+330,y+615);- j; R2 o' C* c& t0 d4 F
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    $ \5 m3 {9 Z- {; e' F" j{
    0 m# n4 P' S; v, c4 Jline(x+650,y+210+210*i,x+1150,y+210+210*i);
    3 @+ r7 f8 r  t1 X8 i/ Aline(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    ' s, k* u9 M8 n/ Q% `line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);! x- l8 d! L- N2 O1 C
    . {# M3 X5 c; O% K1 _) z5 f( t
    line(x+650,y+210+210*i,x+650,y+20+210*i);/ K) L" Z% O% y# ?& f% Z
    line(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
    + X; I/ M8 m7 R1 J8 Wline(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    6 m( o, I% u* _& O2 F: I! X+ [for(j=0;j<num-1;j++)
    1 p" U. ]! W3 C/ c{6 H) o; J7 e2 i; M! g' h3 {+ P
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    ' f4 f9 y( Q2 V$ ?  a* pline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);: v/ k" v8 e( k
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    6 ]" @8 Y3 u$ v: j! M9 Z}  G& D3 b8 D. f! E. L+ {1 t. B
    }3 a5 p% n3 w$ F% g5 z
    }  w, K7 Z5 O  D3 d+ h$ }
    / t6 i* z. _7 Z7 A6 t

    $ L3 H0 K* o) l% B0 X* H8 hreturn 0;; `" p) K$ p( A6 @& Q0 i
    }
      Q- y: j  d$ P0 J4 C* Z# S$ Cint drawPerformance_PF(int x,int y,int memorry,int com,int wai,int cha)
    6 t  u3 f! n3 \! q{
    + P" [6 S+ d- J) [static int info[11][3],num=0;* S' E+ k/ s6 q6 m6 d
    int i=0,j=0,pos[10][3][2];
    6 A* b, c+ J% b+ O2 _float temp,t;
    3 |0 O  O8 N" Einfo[num][0] = com;
    9 @* x* p7 @8 B" A1 I1 j5 C5 Z+ }info[num][1] = wai;% L' ]) T$ a5 v0 s& m
    info[num++][2] = cha;% N4 }8 {7 I# t& H1 t+ f" u
    if(num>10)  //存储10个点0 g0 w7 S% e2 U, e7 z) J' K  F% b/ P
    {# ]: ]$ K  A! r! I, K. @
    for(i=0 ;i<10;i++)
    , G1 {. |9 _' X{
    " A  K7 Y7 Z: A. y) tinfo[0] = info[i+1][0];, [8 T/ I6 R9 Y' A2 I) E
    info[1] = info[i+1][1];
    3 V. g$ `( l# _2 y  x# T+ h" s4 ~3 ~info[2] = info[i+1][2];
    9 x' W, n8 l- @1 H( z}7 U5 @, a: u& S
    num--;
    9 ?) J+ i7 m# U& \& p/ _, t. k% k! e}
    ) R7 ?9 s8 }* L- ]4 X: a/ hif(FLAG_show==0)5 c4 a9 l6 @' m
    return 0;4 \& j* r0 `/ A5 h
    for(i=0; i<num; i++)) z+ q! I) |" f1 J
    {, c- k+ \/ H2 i9 S9 c7 ^4 y* d
    t = (float)info[0];
    0 g' Z  d, R' F/ g# ]  Stemp = (t/101)*90;
    4 f, m2 @% X% spos[0][0] = (10-num+i)*25+x+100;
    ! P" m" i; B: B& `pos[0][1] = y+110-(int)temp;
    & Q% ]3 W6 R7 z, |% S; At = (float)info[1];- Q" H0 N& _3 N
    temp = (t/101)*90;
    * d0 U! G& o  K$ \) e/ ^pos[1][0] = (10-num+i)*25+x+100;/ C& g2 V: e  c5 q. y- V
    pos[1][1] = y+210-(int)temp;
    * f) u0 f' Y5 V& d& C4 it = (float)info[2];, n# y' E0 I3 B6 O& G& n4 |
    temp = (float)(t/101)*90;+ Y  T0 Q, r( R& r2 f  r0 H
    pos[2][0] = (10-num+i)*25+x+100;
    + r7 S, e4 i" M# `# Spos[2][1] = y+310-(int)temp;
    0 j% e% u. r9 d. a1 I}
    ) t; p& m; G' [& c& |, mif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)- J5 m* n$ u& z8 m0 ?0 ?8 v; j; S
    {! K% f7 q. T) I/ Q! q! E  r, {
    clearrectangle(x,y,x+400,y+315);
    8 v9 K5 h7 V& T- usettextstyle(20, 10, _T("楷体"));
    & V: j( b) d$ @- grectangle(x,y,x+400,y+325);# C) k  _2 {# e. l$ s2 a. Z
    outtextxy(x+40,y+10,"CPU");       //画柱状图$ y: C0 k1 M% v
    outtextxy(x+45,y+10+100,"IO");( Y9 v8 y) C# r% U# ]
    outtextxy(x+40-15,y+10+200,"change");& i3 V6 h! D7 X' p
    rectangle(x+35,y+30,x+75,y+110);3 w3 C6 X+ x& r
    rectangle(x+35,y+130,x+75,y+210);
    & j. @6 A1 i  q( k! Drectangle(x+35,y+230,x+75,y+310);
    & @- s+ T; h; v8 g  [" ^" nouttextxy(x+180,y+310,"PF");
      S  k% z0 b! E, l; w1 zt = (float)com;& u2 P2 ]) {% S1 ]) i1 t6 B2 X
    temp=(t/101)*80;
    ; J! Z$ D+ j3 \. Q4 C/ vfillrectangle(x+35,y+110-(int)temp,x+75,y+110);
    ; s  a7 s4 V, X3 F2 c. m- J, L4 _t = (float)wai;2 [+ g( ~$ B7 R" o/ V/ p$ \: \8 q$ Q
    temp=(t/101)*80;
    7 o6 }6 w2 n* [) |fillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    9 H( f% U( {1 z7 {9 y  |' {* Gt = (float)cha;
    ( e$ f- a, j# v% m3 b6 Htemp=(t/101)*80;
    8 e' q: z3 j: {fillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    9 A4 M0 J  F' h" Ofor(i=0; i<3; i++)   //画坐标   high=90,length=250& k1 `8 s/ f, m" t6 @4 k/ A
    {
    ; n$ q5 B4 c) t7 Z" H) Z; a" fline(x+100,y+110+100*i,x+350,y+110+100*i);
    ) h: u1 j" g) v  _line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);2 R' p7 w7 E& o  H! G
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);8 `9 z) `3 q# u9 K, M$ o+ [: \
    & ^1 [( [. m. c# b8 m
    line(x+100,y+110+100*i,x+100,y+20+100*i);$ D& F4 t8 g' \" a2 m; O
    line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);4 U8 ~4 L% ?5 N5 s2 ?# \, C! |, W
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);% y! B9 i  L* c* ], F
    for(j=0;j<num-1;j++)
    4 g! @9 O1 Q0 u4 _$ o7 c+ _{! Z) [. _# X+ Q5 z2 T8 p
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    . x3 A. R( x/ V0 l6 k. ]7 _6 kline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    % h' Y* z8 u% |! d; a% D8 Aline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); . u5 q( r" b$ a. i5 G# }
    }, b. S2 S; u" L$ d
    }* {  t$ o+ ~' Q8 X: l
    }
    $ H1 x6 f, g7 l0 d- ]else if(FLAG_PF==1)( s- E$ L2 p' L, V
    {
    % u/ G! e1 s; N- l' U/ `x=0,y=0;' b) G; D8 P7 }( P; D# ?
    for(i=0; i<num; i++)
    + C7 v9 _3 _' R; V: ]{" q5 e* B' E& C+ R0 O9 M+ e: N
    t = (float)info[0];" Z4 d2 g% Y: G& {( X
    temp = (t/101)*180;( x6 G3 Q4 [  u' B5 {: g
    pos[0][0] = (10-num+i)*50+x+650;, M9 x7 k; e  p- u( ]
    pos[0][1] = y+210-(int)temp;5 x( x- F& H7 V" M$ u/ L4 r9 T
    t = (float)info[1];
    , ^2 ^( S' U. e7 S4 C8 `temp = (t/101)*180;
    " t2 _7 C9 y+ c5 |3 @  P7 bpos[1][0] = (10-num+i)*50+x+650;7 o  J; D- `2 s) `* c, K
    pos[1][1] = y+420-(int)temp;! }. c3 P2 z  N
    t = (float)info[2];
    8 W4 @, T: N; ctemp = (float)(t/101)*180;, e) t7 r$ j$ `6 v9 H
    pos[2][0] = (10-num+i)*50+x+650;
    3 J/ E% Z; \2 L8 a; ^% kpos[2][1] = y+630-(int)temp;! H; p. L0 Y" h7 a! E0 L; T8 n
    }* |, C; G/ U3 B7 ~( b) h( U' v1 }) N
    clearrectangle(x,y,x+1200,y+650);$ _' H5 `9 `3 {+ d! M" M
    settextstyle(40, 20, _T("楷体"));5 v' R. Y, m/ W+ x4 O" O, }- K. f4 E
    outtextxy(x+50,y+50,"PF");
    4 i- y) ~, h3 Zouttextxy(x+280,y+20,"CPU");       //画柱状图
    7 ~) j& I. a! I& Louttextxy(x+285,y+20+200,"IO");7 o$ M7 V7 {( {  Y% e8 J+ ?
    outtextxy(x+250,y+20+400,"change");1 W3 {7 N  F4 m4 g/ o. A: o3 S2 {
    rectangle(x+270,y+65,x+330,y+215);- H/ ]: g6 X* }$ o% V
    rectangle(x+270,y+265,x+330,y+415);
    8 w7 d$ C! e1 T& m2 Lrectangle(x+270,y+465,x+330,y+615);" s0 d, N* j% r; A5 d! G0 ?. d& ^
    outtextxy(x+290,y+620,"TT");
    5 G5 d7 V) d$ {# S) Mt = (float)com;
    : q6 V4 I) T  [& z2 V) c0 [* Btemp=(t/101)*150;
    3 E& w/ C4 c3 A& x, _/ D# Y0 C8 v/ [fillrectangle(x+270,y+215-(int)temp,x+330,y+215);' v5 E! k: X8 W% O( j2 N
    t = (float)wai;
      f! y( `  D# J' Y7 l+ [temp=(t/101)*150;: j+ b- ]& x9 p6 }
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);+ f; `- @/ c5 G3 n( p- N* t0 R8 m; t
    t = (float)cha;
    & ?7 r) o0 T/ b. U" itemp=(t/101)*150;
    . @6 b( \3 x; j" f. f4 `& Ifillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    / S* O# V+ y) G3 v9 N) O2 e" @for(i=0; i<3; i++)   //画坐标   high=90,length=250
    ! ^4 K  F/ x4 o# \8 X" [( m{
    ! g  J3 i% @/ ]0 k. Zline(x+650,y+210+210*i,x+1150,y+210+210*i);: Q( J" l2 d( G& b. h
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    1 s* G9 G. ?7 w2 kline(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);
    " ^% g2 J; Z) c) f7 _" _- J
    + X& c7 f, A$ J& E3 a- m$ q  n+ bline(x+650,y+210+210*i,x+650,y+20+210*i);3 [/ `: l2 i5 c8 I0 ?
    line(x+650,y+20+210*i,x+650-10,y+20+10+210*i);) [9 P. h. k1 f0 }1 k& D
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    5 H! D& t' |: y. y9 W8 bfor(j=0;j<num-1;j++)
    % X5 ?: g2 W) M, g! H' ]1 K6 e{% p! O2 ?4 F6 G) S
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);) b: Z/ K/ V$ f' U& H
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    - k  S4 i- G8 Jline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); " t4 }3 {+ ]( K- E+ ?1 ?. D
    }2 V/ U6 J8 h$ v  v! k& `. y
    }2 n7 c5 i+ n$ D
    }
    2 R& D( b& @  q# a0 N* Rreturn 0;
    * E, W; t2 a' l' y- L% T2 X}! S+ g7 ~, h' E' I. \
    int drawPerformance_SJF(int x,int y,int memorry,int com,int wai,int cha)
    7 _! b7 v* I' t  i6 ?) ?{2 J1 M' A2 s) R! {) f" \8 Z; [( ~
    static int info[11][3],num=0;
    6 s8 _/ X6 k+ r, j; Pint i=0,j=0,pos[10][3][2];, e$ N4 l5 ?3 S$ F5 X3 E
    float temp,t;
      R) m5 ?1 h/ `info[num][0] = com;% W+ j: L, [; y8 r0 S
    info[num][1] = wai;! D  I5 r+ ]5 p4 e5 x
    info[num++][2] = cha;& y( Z: R9 a- o. L: e( M5 W
    if(num>10)  //存储10个点
    . u% x# J9 l4 x5 v" Y( y% J9 p{
    & l" h8 ?, G  y$ S- ^1 e" A+ x' Ifor(i=0 ;i<10;i++)
    ( `+ \1 J6 z- z" ?1 f{
      m+ t) A# `& t1 L- n& xinfo[0] = info[i+1][0];
    4 Y5 R2 v5 r. C3 V# g$ Tinfo[1] = info[i+1][1];
    - J4 q: G( ^+ I5 {5 F8 `5 v, D1 c6 Tinfo[2] = info[i+1][2];
    : y) h* w' |8 C1 S  N. r5 S/ w& Z}: G3 |" z" b$ ?0 S
    num--;" w7 R+ b% D6 F* B. {6 t
    }8 n+ `4 W# m, ^% O/ j8 {
    if(FLAG_show==0)
    + H- [/ p! P/ K# I% |return 0;1 d* ?" z% v5 N$ e- q1 _$ x6 E1 g
    for(i=0; i<num; i++)0 b5 R) r- y% e7 r7 Y6 O: s
    {
    : j2 p# \' h, R, p3 L7 x0 Z3 s' Mt = (float)info[0];0 k; d' S* n% ~& B3 V; r$ _6 H
    temp = (t/101)*90;
    % d+ [- L8 A; T, \# dpos[0][0] = (10-num+i)*25+x+100;
    5 @0 h$ W0 z# G3 _- Gpos[0][1] = y+110-(int)temp;1 n- ]7 ?4 G: L4 w" V
    t = (float)info[1];
    1 P7 q6 s) l' A/ L% D' ptemp = (t/101)*90;
    / c9 Q2 B. N4 O; rpos[1][0] = (10-num+i)*25+x+100;
    ' V5 z+ o6 Z# R' w$ xpos[1][1] = y+210-(int)temp;
    ' ^* T8 ^% g, e3 C0 _# xt = (float)info[2];6 k- y+ w1 d  |6 j
    temp = (float)(t/101)*90;
    % R2 I3 V- u: W; U, [* T+ \$ [, wpos[2][0] = (10-num+i)*25+x+100;8 ]$ I, K: T, Y
    pos[2][1] = y+310-(int)temp;
    + @) L' [4 v3 x2 t5 Z7 o4 k- `}
    % \3 |7 ]0 K7 F+ q. W; {if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
    0 ^2 d9 V8 x$ r{
    1 l7 p* v4 X: t+ G: e2 \% \clearrectangle(x,y,x+400,y+315);
    ! t$ n& d& C; e. e! E# u. Tsettextstyle(20, 10, _T("楷体"));3 e) q, |, U* D
    rectangle(x,y,x+400,y+325);6 V: {$ Z4 ~! O) A) W: A
    outtextxy(x+40,y+10,"CPU");       //画柱状图
    8 ~: h0 K3 D6 ]) u, e1 G# o6 h' \& \outtextxy(x+45,y+10+100,"IO");
      x5 f8 r; c6 D1 p6 f/ b( ~  Gouttextxy(x+40-15,y+10+200,"change");1 @" {" {- Q2 s% T: W8 p
    rectangle(x+35,y+30,x+75,y+110);( @# ]% q- h! O
    rectangle(x+35,y+130,x+75,y+210);
    4 N! m2 s+ [" _* Frectangle(x+35,y+230,x+75,y+310);, q% O: U9 h- E9 r& C
    outtextxy(x+180,y+310,"SJF");6 t& H# r( A2 h6 G! E
    t = (float)com;1 F. |$ s% J; }. [& [+ u9 i+ n# z
    temp=(t/101)*80;" L% b1 D( L+ o5 ^# F1 n8 v
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);
      X$ Z) N/ Z6 }% t. S% ot = (float)wai;
    0 B1 X; ?# e- _2 W3 H: o" ctemp=(t/101)*80;
    0 }$ {( c# S7 n8 S$ P* p' nfillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    7 l% ^/ K( v; f# k7 I6 Z& Y, zt = (float)cha;; I% V4 ]: ~) e; B8 ~
    temp=(t/101)*80;3 _' c) j( `9 W4 |! S% U. [( p
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);3 {# p+ e' ~2 Q; ], K  e
    for(i=0; i<3; i++)   //画坐标   high=90,length=2507 W4 a2 w' K9 n) h8 A
    {$ E* F8 t  S0 \, g4 d
    line(x+100,y+110+100*i,x+350,y+110+100*i);
    - v2 r: D: B- }line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);
    - {9 x7 q* ^! Y+ Sline(x+350,y+110+100*i,x+350-5,y+110+5+100*i);: n$ d; i& w9 S& h! N  ~- l
    - P7 d: E% c. M6 A# `  i4 v. R+ |
    line(x+100,y+110+100*i,x+100,y+20+100*i);
    ! z5 W# V# Z; B. _7 w/ Cline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);
    , Q6 ^. T! t8 Q$ z9 m/ `9 nline(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
    2 S0 o% K4 T6 W3 qfor(j=0;j<num-1;j++)
    % X: ?0 R" ~& H' K, V{- A  U0 |" ?1 I- |# B2 H+ E
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);/ F- p' v; V" q9 s" I% H8 K
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);8 w+ w  m- O2 G! d8 G$ @0 K; }
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); 0 Y4 N% d6 k) d; {+ A; ~
    }# H* ]# {% y% ^5 {0 E3 O: O' v
    }
    1 P; ^: K" ~4 y! P" S; a* j+ ~8 X}/ S& z. [0 W, l: r1 X
    else if(FLAG_SJF==1)/ d* B. `# L; f
    {
    5 K, C: w/ |- nx=0,y=0;
    & e( K5 t" t. h( U& N3 f& Zfor(i=0; i<num; i++)+ \7 E! u9 i0 v% f) d
    {
    ) G- S4 m, i% I5 s; s% Zt = (float)info[0];# u. r% a, b: Z6 z9 o( Q9 w3 h4 C
    temp = (t/101)*180;
    , k7 ?1 o  |$ w6 o/ T$ f. Z; Q2 Bpos[0][0] = (10-num+i)*50+x+650;/ V6 b6 S  n+ u1 \
    pos[0][1] = y+210-(int)temp;
    " Q; \& G3 @: I5 ~; K: O0 mt = (float)info[1];
    0 y9 n& e; R- dtemp = (t/101)*180;( I% I: R/ X) q/ q1 O0 Q: ?
    pos[1][0] = (10-num+i)*50+x+650;% D/ S( D6 V: D6 }) u: c9 \- ?
    pos[1][1] = y+420-(int)temp;, n9 B$ m0 T8 O6 Z! |
    t = (float)info[2];1 c0 @: a- {5 m
    temp = (float)(t/101)*180;
    8 I/ q; D$ p$ v9 i9 S2 [  spos[2][0] = (10-num+i)*50+x+650;
      y7 I4 L$ I: H6 H# dpos[2][1] = y+630-(int)temp;
    : |( b. u; W' U}
    5 U( _& e; H2 U; Tclearrectangle(x,y,x+1200,y+650);5 D/ }2 F& v3 [1 ?3 I
    settextstyle(40, 20, _T("楷体"));/ ^% |+ ?* A* Z5 V# b! E
    outtextxy(x+50,y+50,"SJF");
    ( _9 p% ?. ]; q3 l( Y7 c7 I! {outtextxy(x+280,y+20,"CPU");       //画柱状图
    . g* _7 y% X5 H  routtextxy(x+285,y+20+200,"IO");2 R2 `$ j3 a" d6 H+ B  r9 h7 Q0 e
    outtextxy(x+250,y+20+400,"change");- Y8 Z. Q, a2 X8 r) q, e
    rectangle(x+270,y+65,x+330,y+215);6 B8 X0 [7 r* H& ?
    rectangle(x+270,y+265,x+330,y+415);( c: }3 }' x+ |! f' \+ J
    rectangle(x+270,y+465,x+330,y+615);
    $ u# i  |% D6 k" Q" K# q- ]outtextxy(x+290,y+620,"TT");
    ! _9 j9 G+ c* w' w+ r! a8 H9 ~t = (float)com;* X+ o" |* h* |8 M
    temp=(t/101)*150;
      J+ R- @* @7 y! jfillrectangle(x+270,y+215-(int)temp,x+330,y+215);% ^0 \! [; ?/ q
    t = (float)wai;
    . ~, u9 v0 A4 ~% h/ W# }4 Xtemp=(t/101)*150;
    & J# D; U; X$ y  Cfillrectangle(x+270,y+415-(int)temp,x+330,y+415);
    . J# P+ B7 C* f3 _2 P: }  ^, mt = (float)cha;
    3 L* Y; I! ^, x# \  _9 {temp=(t/101)*150;# ^+ a  U& T+ d
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    7 W' l* \& G5 a% tfor(i=0; i<3; i++)   //画坐标   high=90,length=2507 m9 a8 W7 l+ T2 s( {
    {
    " N4 W; ]5 H4 h# i4 @line(x+650,y+210+210*i,x+1150,y+210+210*i);# e, |1 q" V1 E4 n! \+ y& T$ |) @
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    1 N: j+ K  O* Aline(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);  ~9 `; E  S) Q7 r
    1 E% C# L) Y- C, N0 I
    line(x+650,y+210+210*i,x+650,y+20+210*i);
    9 [  k9 j; g7 oline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
    5 L+ p8 p( v0 ^line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    ' L* B- I+ ]: E/ D/ |3 x6 Z* _for(j=0;j<num-1;j++)7 Y- Q2 m6 q1 _0 P7 c) A
    {1 W% Z+ U5 w4 ?/ r7 Q
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    0 m  V2 z) X9 F7 x8 S( ?line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    3 ]; O5 z7 ^0 P) e, D+ Aline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    9 ~- c/ |# \# g}
    0 G5 o% y, C  P5 h  s/ c}
    0 }  F6 e& r) I  ?. w& S}+ D6 D& R- U5 c9 M9 u0 D
    return 0;
    " \( D  f1 p- A2 w1 B}0 x2 t% e, @& x* B5 C4 d
    int High_response_ratio_dispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)! b, I' ~* V6 \
    {" Q1 ^  h5 _$ r! u/ ?
    static int compute=0,waitio=0,change=0;
    - B- {, @" ]0 x$ u$ }3 Ystatic int computeLast=0,waitioLast=0,changeLast=0;) P- B. Y. O6 T8 I- y* k1 o; x
    int i=0;
    ; \2 [+ I: j. c  L# e) C+ \* f: z7 o" @if(draw==1)
      r$ b$ `& L4 T& t{
    3 V/ P; L2 m9 c, i' W//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);- d. ~$ c3 N2 v
    drawPerformance_HR(400,325,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);/ z- G$ I8 I( n8 E( B
    computeLast=compute;
    ( Q; Z! u7 \% F- K" swaitioLast=waitio;+ ?2 S# L. s& e9 n5 Y9 T
    changeLast=change;$ K4 S  ]* V! _# F; g8 r  D
    }
    3 A5 k7 C" c1 B( w" wif((* memory).p[0].flag==ready)
    ; K: |  o# c* M" }. c- e2 E(* memory).p[0].flag=computing;4 Q4 U7 g! L. S# W% q- k4 U$ L$ y: k
    if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)
    2 b6 L5 |! x3 e! h7 }# R{
    % n3 L) V* ]6 r  s0 {9 A9 Ui=(*memory).p[0].computeNum;
    ! `# h9 U" h8 M* D5 j: pif(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed
    . z5 l+ ~/ L- B' ]8 @, B{
    7 i& ~0 V% h: A1 c  x. D+ o5 I(*memory).p[0].flag=IO_waiting;
    ! b, X/ c: j7 k(*memory).p[0].computeNum--;% H; r+ k9 L3 @! v
    change += exchange_IO_Compute;
    : X& k2 d4 O* b2 _) ]compute++;4 P# }4 l# r$ S; u# V+ s
    }
    * X8 q& U# E0 n3 j8 k. Melse
    0 N: z1 L& [  ^! P* L5 d{. J9 l! U" l$ `8 j' S) u: e! N
    compute++;
    1 F/ k; v. x' v1 c}
    4 Y3 B! L5 j) _, _; X5 K}# T5 i' F( L, p! ^
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting): g( d/ V- X2 k  p% T
    {
    * \/ k5 m6 V: x2 a: H/ ^" u/ L, y- x2 j5 c& @- }: h8 y' W
    i=(*memory).p[0].ioNum;$ I, H& T) z, @! i/ s- Q3 p& k( J0 V
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed
    " ?) P6 \5 J. o2 R, e{) x! k& m4 X5 e
    (*memory).p[0].flag=computing;! s. e, A( H, `4 L
    (*memory).p[0].ioNum--;
    % \* n( R1 a' u5 A+ G: B+ Qchange += exchange_IO_Compute;
    * c7 c4 s3 Y( Z' N$ o# }waitio++;8 b% P! P) _  f+ ]. q3 R
    }
    ' E; U+ z1 H3 }0 Qelse+ Y: o6 k+ ]6 x5 J# |
    {
    & s; Y+ g* Z- [$ V9 Zwaitio++;' H3 _# X9 \9 x3 G5 t' M$ e! j
    }9 s1 [! d# G1 j0 b* t% E9 j
    }% x( w- x/ z$ ]0 _
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)
    ; l; f5 j- Q* O* ^{5 L3 A, C! O6 t, a5 y- F9 k* M
    (* memory).p[0].flag=IO_waiting;
    , ]1 M/ }4 R# G. B2 L1 K& Hchange += exchange_IO_Compute;
    7 l4 ]' u' k, _# m}
    $ U; \8 t2 z  `* R, Felse if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)) v$ r  m5 ^; m
    {& F" o4 g: Y8 _0 |2 s
    (* memory).p[0].flag=computing;
    ! T7 ]' V6 U  D& Wchange += exchange_IO_Compute;
    1 b( }3 L( n& ~* s1 T0 u6 m" C' c}
    $ P# S8 U) y4 rif((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成% n1 q- @, _1 g7 O# [) P
    {
    # ]' q8 y6 P# {2 O, X, ^(*save) = (PCI*)malloc(sizeof(PCI));
    $ E2 V8 d& B4 c8 J( U6 a3 a" R(*save)->next = NULL;
    ! L; \+ v* \; i3 [) T9 G(*save)->processID = (*memory).p[0].processID;" q, c+ [7 e6 o9 d3 ^
    (*save)->comeingTime = (*memory).p[0].produceTime;
    0 Y+ d( Y2 o# C1 Z$ ^0 `(*save)->askMemory = (*memory).p[0].askMemory;( `# U: Z1 T  f2 g) `/ b! l: G; D
    (*save)->compute = compute;
    & v" J; \) Q/ Q6 D$ O# e" @(*save)->waitio = waitio;& I, V, U# {$ \! g+ y- n& l
    (*save)->exchange = change;; o9 F: n  x$ Q2 g
    (*save)->completedTime = systemClock;
    - z# v' B  e4 @" X( I1 F7 |(*save)->runningTime = (*memory).p[0].runningTime;
    . ?" u1 M$ c( I" T2 S- y8 b*spareMemory = MAX_MEMORY;         //*spareMemory + (*memory).p[0].askMemory;
    . c( v3 r) v3 P6 a3 J# @! N8 Ucompute=waitio=change=0;
    $ j; M! A8 c; |" \computeLast=waitioLast=changeLast=0;1 B3 G- p& `2 ?" Z# g
    High_response_ratio_s_to_m(&(*storage),&(* memory),&(*spareMemory),1,1);
    9 J5 y# P! C4 |; C/ c& q8 Schange += exchange_process;
    1 d0 H+ I: R9 W4 ireturn task_completed;
    % [& @% D8 |0 S}
    4 O% S: O8 c0 c$ {6 ~; x3 Aelse( f: R4 @+ K; e8 X9 z8 a4 y0 i) |; G
    return task_not_completed;. \# F8 ~. B% j! I% x
    }9 j+ Q8 ~- t+ h6 b
    int High_response_ratio_s_to_m(processPool *storage,processPool* memory,int *spareMemory,int flag,int dispatch)
    # i2 N1 E% d& B/ l& J{5 B; z. u  q- {2 M2 ?
    static int waitTime[initProcessNum],i=0,j=0;
    - G) ]& @  @( G1 }static double HR_ratio[initProcessNum];
    " M- \1 {% T( T! y" c. j1 r) Gif(flag==0)                    //初始化数组
    $ J8 m9 ?- Y" [5 v# z+ x3 e0 s{) ^$ Z1 z  z+ t: T  W
    for(i=0; i<initProcessNum; i++)
    : Q; p0 z) E# D- C) s5 e& ?{
    6 d- M2 i9 `1 ~8 R, m7 WwaitTime=0;
    9 ]' t, f1 i. z" _1 T/ ]3 MHR_ratio=1;
    ; c' @; o" V. b7 g; [% Y/ q}
    + l  j" }) o% s. [. i( @- c9 ^}
    ) x& K" T' L4 u, ~" yfor(i=0; i<(*storage).proNum; i++)  //等待时间增加,重置响应比* R, }5 ^( ~6 G3 [4 M7 r% f
    {' t' d  E' U, k; M( X* Y2 _8 I
    waitTime++;/ S9 @3 _6 z. w) z/ v% U: S$ Q
    HR_ratio = (waitTime+(*storage).p.computeTime+(*storage).p.ioTime)/((*storage).p.computeTime+(*storage).p.ioTime);
    ' S% ^  k# F  L8 b- {; Aif(HR_ratio > HR_ratio[j])
    ; x/ ]7 b' J% M- x* h' Q8 U1 jj = i;- L& I1 S. f2 C* N  }
    }( g0 A+ O% I: x: X2 \1 Q$ R' c; x
    if(dispatch==1)                    //需要调度一个进程到内存中执行5 B) j( e- _3 C/ C+ b/ W, d
    {/ P7 M% x/ B6 {5 B. ?
    if((*storage).p[j].askMemory < *spareMemory)+ y4 K1 w, f/ v: k; Q+ o
    {# _' c& n  i7 c7 d
    (*memory).p[0].askMemory = (*storage).p[j].askMemory;
    4 P, A1 G: s6 L! S- `(*memory).p[0].comeingTime = (*storage).p[j].comeingTime;: n$ o( p1 s% ?- ~/ H
    (*memory).p[0].computeNum = (*storage).p[j].computeNum;. ?# j) P) F9 K8 }0 [; R. S
    (*memory).p[0].ioNum = (*storage).p[j].ioNum;
    ( W" j2 B5 t( }# s! r(*memory).p[0].processID = (*storage).p[j].processID;7 v$ q: m, u* q: n$ y
    (*memory).p[0].flag = (*storage).p[j].flag;
    # B( j" z* X5 R; u(*memory).p[0].ioTime = (*storage).p[j].ioTime;+ B" V. T2 H5 Z+ X1 F
    (*memory).p[0].computeTime = (*storage).p[j].computeTime;' o% Q, v* c  ^* N  V$ f
    (*memory).p[0].runningTime = systemClock;
    * p; A* V. J  s$ f1 l) H2 L! r(*memory).p[0].produceTime = (*storage).p[j].produceTime;
      N1 g6 A) o7 x3 {3 r+ E4 Y( Ufor(i=0; i<(*memory).p[0].ioNum; i++)
    * Q3 @" h! N8 G5 i' h& g7 W(*memory).p[0].ioClock = (*storage).p[j].ioClock;
    * l# b+ [+ ], R1 p" [for(i=0; i<(*memory).p[0].computeNum; i++)( ?9 h8 s& ?9 }- x$ y7 P
    (*memory).p[0].computeClock = (*storage).p[j].computeClock;, o' n& R2 L* ?4 _/ p, p/ [
    (*memory).proNum=1;7 k" d7 |( \) o0 f8 V- N
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;
    " d! |% x0 S# X9 E7 `produce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程) B# M. H. x+ @3 U. O# F
    (*storage).p[j].produceTime = systemClock;
    / c+ k' w; g+ [( o/ KMAX_COMING_TIME = (*storage).p[j].comeingTime;
    * }% ]# z/ |) \: u$ nwaitTime[j] = 0;& ?4 s1 ~9 `1 v- S7 `0 {2 d. s. b
    HR_ratio[j] = 1;; Q3 |, u. Q6 |, h3 _% i
    }8 S! u- B* L/ }6 k3 w# ]$ y9 H# z% P
    else
    1 Y. h1 i  R/ z0 |: I{5 P" z- I7 _: `1 k! a
    printf("A process ask for a memory overed the system capacity\n ");# j; D" T( w" C7 X8 H+ z
    exit(1);
    9 i4 H  U. u, F1 W6 I$ K# ^' x: v}
    ! ?  `9 h: Z7 ~( {, d}
    1 r! `  m9 Z$ p3 {- {return 0;
    & D- {6 e0 x; P6 N8 h% X}% H  L! Z" X, b* r
    int PriorityDispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)
    0 n' ^# c' Y  F4 M9 f- G{. t4 T. ^4 Y7 M
    static int compute=0,waitio=0,change=0;' e6 E4 v( c3 f& c4 {) |' Z
    static int computeLast=0,waitioLast=0,changeLast=0;
    ) `" Y7 N$ H6 A  _5 r4 U' xint i=0;' R( O* G; T- K. x, z6 h0 \: s
    if(draw==1)# p1 L! z% z9 g4 L. N* q/ }. g% ?
    {. P' N' C9 P/ A- O  E3 P+ k, h
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    & N$ g. a' x; K+ U/ G$ j0 kdrawPerformance_PF(800,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    5 ^$ H8 `( d2 L" ~# r1 B% l" n2 b
    ) e& d8 R% ^6 P& h. d0 Q' ~; `
    computeLast=compute;: `' F4 b, Y2 ^0 v
    waitioLast=waitio;; f7 }+ H3 t5 [3 e4 O/ a5 ]
    changeLast=change;
    5 [9 }" Q# `2 k! [0 L}
      J$ ^: j7 u* d% X- N  Yif((* memory).p[0].flag==ready)0 R2 ~" h  j) z" U1 Y0 d
    (* memory).p[0].flag=computing;* P+ R' F3 W& D  b! p% T( X
    if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)- \$ b) R4 k! u9 t5 h1 \6 Q, l
    {0 P' Q& D1 U8 Q5 `! q' e
    i=(*memory).p[0].computeNum;
    , E/ K9 E7 x. ^5 qif(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed
    " e4 p5 Z$ |% r. X# L{
    : A- b6 B) _! J2 m* |(*memory).p[0].flag=IO_waiting;
    * U5 `; H, Y- B. Y$ y/ o7 H  W9 H(*memory).p[0].computeNum--;8 G3 R! F- ~' m' \. ^  `, }. z: o4 h/ ]
    change += exchange_IO_Compute;, _- e3 O$ c, U0 i/ }7 q+ Y
    compute++;) X7 W" Y4 v" T6 A1 x. f% e$ {
    }' F. N- B# n0 C! h( X
    else
    # A0 O3 |) D8 K  _) _{
    8 u- X7 U$ Y2 E; Scompute++;
    $ U5 U5 x" i9 _7 U* e3 ^}
    6 J' s. b$ t+ ^; {. ~}0 R( k( y5 E1 l/ a3 p5 |, ]- g
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)
    * R" G1 w) X1 B( k8 S{. I7 J7 s" k7 d1 W

    ) @* y! @6 E* S, ri=(*memory).p[0].ioNum;& H, d: B5 W: k9 c( [
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed1 {% ~# t& O$ D% G) F* ]" S: T
    {
    4 M/ g8 t# S; o+ J(*memory).p[0].flag=computing;+ b" I) @: \1 N; I. C) ^# X; e
    (*memory).p[0].ioNum--;# U6 b* i$ U; R. R8 K, Y
    change += exchange_IO_Compute;7 \: W+ r6 i" Q% n$ T2 k
    waitio++;
    % @! ]4 j# I2 n' F5 U}' H* m0 ^* `4 e
    else7 T: h. R9 O3 H7 ~
    {
    . q) m7 _4 d4 b+ swaitio++;, B% b' u6 F( Y5 W; t, M* f5 P
    }1 Z( m& \) K" J6 l- E
    }
    + B! [4 Z& T' k- w' ]' zelse if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)
    5 ~- Q, ~, T! p% {& @" c{% C' T; p3 u- B' o1 i
    (* memory).p[0].flag=IO_waiting;
    . v* p. J* Z* M, G" kchange += exchange_IO_Compute;; F. _1 z. D  V, Q; E- \3 b$ ~# Y3 R% g0 v
    }
    ' T! `+ L: k/ k. Melse if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting); V" m- ~5 k) \: l( U
    {( j- [. U  p$ Q$ F& I7 A% p6 I
    (* memory).p[0].flag=computing;$ M1 O; {. z4 H  M
    change += exchange_IO_Compute;
    % ]. v# J8 {* ~3 R! {6 z6 o}- f8 v3 i0 w$ `  ?
    if((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成
    0 n& _/ R: h& B- w6 H. h{2 {2 a, Y* ?" s! }2 w' T% S" z
    (*save) = (PCI*)malloc(sizeof(PCI));% \9 z9 f0 p- T: R6 _4 [! u, V
    (*save)->next = NULL;. F8 t$ P+ E* r' P( R1 ^
    (*save)->processID = (*memory).p[0].processID;
    # V( z' _" Z$ O) {# {* J# `(*save)->comeingTime = (*memory).p[0].produceTime;$ Y% m% R8 b0 H' k
    (*save)->askMemory = (*memory).p[0].askMemory;0 ]/ B2 X- c. p2 B5 k$ T: w
    (*save)->compute = compute;
    $ ^" c4 }- @' N9 V9 Q. E(*save)->waitio = waitio;
    $ q" J8 R* W* O, A! n6 [6 A) Y, O* w5 A(*save)->exchange = change;) ]2 k  X1 P9 y0 M
    (*save)->completedTime = systemClock;
    " {" e' t' u9 q(*save)->runningTime = (*memory).p[0].runningTime;4 L4 Y* g  F7 @
    *spareMemory = MAX_MEMORY;      //*spareMemory + (*memory).p[0].askMemory;
    4 ]- A" k  Z$ B* y9 dcompute=waitio=change=0;' H8 t& [: |  ?
    computeLast=waitioLast=changeLast=0;; `8 V  c* P: j1 i" G
    Priority_storage_to_memory(&(*storage),&(* memory),&(*spareMemory));
    * ?4 x- t8 M: ^9 ~0 wchange += exchange_process;
    7 P, a/ _$ b5 ereturn task_completed;- h  @4 m  N$ C$ G: T- p
    }0 \, {) a/ d; ~+ J% r4 n- k
    else% r1 ?3 {5 L5 E+ A! Z' D; I/ f
    return task_not_completed;
    8 t# q; `2 Y# o}7 V: F# p- U( A6 I# l
    int Priority_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory)& W* u: H1 c' Q- v& N
    {
    + O& m( W4 [9 E( Y3 @int priorityNum[initProcessNum],i=0,j=0;
    . |- \0 P' r! H5 v- Zdouble temp=0;8 z( b8 j" m( k- J
    for(i=0; i<(*storage).proNum; i++)    // setting priority to each process
      a( j  s" v' E! c0 V{& o3 I4 ~/ f/ @  h" R  Q: R
    temp = (*storage).p.computeTime/(*storage).p.ioTime;- X, s' O, I% s5 ?* x) y5 A5 f
    if(temp > 0.8)
    " C3 U7 a, L2 ^priorityNum = 6;2 ]$ N6 j# z2 V. d
    else if(temp > 0.7)
    * _/ t; J. q3 f1 D& D! P9 xpriorityNum = 5;
    ( @+ J) z. ], U. ]else if(temp > 0.6)
    4 U" _8 u. ^1 K( J+ o  K2 xpriorityNum = 4;
    5 d( t4 n8 Q0 helse if(temp > 0.5)
    1 v9 S) O! a# a, U3 T5 fpriorityNum = 3;
      }) l6 {/ V. i/ [3 [0 y' l  Kelse if(temp > 0.4)3 O4 c$ r% W3 a3 A" D# Z; M
    priorityNum = 2;
    ( a6 K2 B( G+ v9 i$ ?0 v+ qelse/ p# O8 O/ m$ K9 H( p
    priorityNum = 1;) r) ]; I# G: ]3 c
    if(priorityNum[j] < priorityNum)
    & r" M7 r1 l1 f+ o, S% C4 r; Cj = i;) U* U% A6 C  u0 `1 a6 x( v! d
    }  L  t; ?* S* S5 K$ L8 ]. n
    if((*storage).p[j].askMemory < *spareMemory)$ Z2 O3 M# V1 C- z9 |  }. L
    {
    7 v. R$ y! J, a- Z% R+ l) B(*memory).p[0].askMemory = (*storage).p[j].askMemory;0 V6 F1 G4 J9 I- ^. m
    (*memory).p[0].comeingTime = (*storage).p[j].comeingTime;. r/ C1 I$ {8 Y* ^* B9 C  X" ?% V
    (*memory).p[0].computeNum = (*storage).p[j].computeNum;3 l) A# M! m  s" q$ F& W! S
    (*memory).p[0].ioNum = (*storage).p[j].ioNum;3 {$ K5 ?/ u! T( K, l4 p, M
    (*memory).p[0].processID = (*storage).p[j].processID;
    ( ~% S1 S3 @. P$ D  {* b& n(*memory).p[0].flag = (*storage).p[j].flag;0 B7 h2 w0 J& f0 J. r' [2 b; I
    (*memory).p[0].ioTime = (*storage).p[j].ioTime;5 O$ [7 U2 `: r$ r2 o# u. g4 w
    (*memory).p[0].computeTime = (*storage).p[j].computeTime;
    * R' Z+ E7 p1 ~) b& E; G(*memory).p[0].runningTime = systemClock;
      o8 b: Q& X# c. k+ g: [(*memory).p[0].produceTime = (*storage).p[j].produceTime;! u# r# S0 P! R; d! p0 ^6 I
    for(i=0; i<(*memory).p[0].ioNum; i++)
    # b6 W6 P% P, H9 \& Z& `- [(*memory).p[0].ioClock = (*storage).p[j].ioClock;3 ~( l* y4 N! |* G& V% t" ~  a
    for(i=0; i<(*memory).p[0].computeNum; i++); u' `: ^- Q5 z+ Z8 T: A% }- `
    (*memory).p[0].computeClock = (*storage).p[j].computeClock;
    " C" J4 B$ N$ T6 F, M$ X(*memory).proNum=1;
    : u  ]( l' P- r% D/ U*spareMemory = *spareMemory - (*memory).p[j].askMemory;
    3 G! s" i0 b  }3 B0 t% w5 \produce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程- I$ m. C, `7 E+ }! \- r, _: j1 D4 p/ S
    MAX_COMING_TIME = (*storage).p[j].comeingTime;
    3 Q1 o- ~8 ^! y  ]& Y* ^% |. d}
    * g. [" L2 I8 P4 \( Eelse" y  F- ~6 z% o2 ~% [$ K6 r7 P8 G
    {  s# c, B3 p4 P% o" z
    printf("A process ask for a memory overed the system capacity\n ");9 s# I0 K' {0 h; _+ Z6 v& d% S. I! ]
    exit(1);: n, L4 W% P% t# E1 E! A: o9 q
    }
    ! U3 ]+ G2 |8 ureturn 0;
    % P3 w3 f. e2 s' h) ~4 y}: T" o/ G4 P5 I% c7 ]
    int ShortJobFirst(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)
    9 `- m- D- h9 w4 F% H3 f% }{
    ; l  R* J( Y7 c: wstatic int compute=0,waitio=0,change=0;! ^5 t5 x2 e5 f3 y
    static int computeLast=0,waitioLast=0,changeLast=0;
    4 i0 a: B* f) Yint i=0;
    + m' \/ b3 p: d6 F( ~if(draw==1)
    4 y+ f6 ?: ]: u6 E: W3 h{
    ! J, W6 u4 k8 I2 b# o7 W. _+ R//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    3 Y9 a+ {7 U% a: I+ IdrawPerformance_SJF(0,325,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    % c$ ?" e' O, P' f2 H
    - H, _) I# S+ M0 a* W+ a' G1 q7 u; A$ ]9 s: n# w
    computeLast=compute;
    ! X4 k2 B9 l/ r' k- X% o: ywaitioLast=waitio;
    1 e: C3 }8 d* [' s4 p2 k+ I0 C- fchangeLast=change;& D6 k! a( N" H4 `
    }* M5 R$ s' e7 Z' s  s9 f3 O
    if((* memory).p[0].flag==ready)
    5 F1 }7 J2 ^( w2 r5 `(* memory).p[0].flag=computing;: N2 Q* e1 P2 ^4 r
    if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)
    ; Y/ c- p* i7 y# H* q1 q{
    . g, ^" W0 [1 b& S- t4 E4 ]i=(*memory).p[0].computeNum;
    " T; g+ a3 l! k: Lif(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed1 z6 b9 r9 m0 D' |% D- G
    {" C$ g4 J" N9 x/ S
    (*memory).p[0].flag=IO_waiting;3 Y0 [7 C& s9 t8 f6 a4 M4 w( H* D
    (*memory).p[0].computeNum--;* f$ k1 p- ~  i; g
    change += exchange_IO_Compute;
    7 @6 N+ J+ r/ a2 T+ _( Bcompute++;3 A6 m% G' _2 e  j# U2 q' \. t
    }# n! V) f. p! K" S* [- V( v
    else
    , [, T; C9 u) C# h/ H) E{5 L, ]/ A1 W$ f6 G
    compute++;9 B% u& ?& J8 @. N2 x; z9 z9 l
    }
    6 m" p, _; x1 {! ]* s}% G. K9 o3 o  H4 c' d  C2 }( ?9 q
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)
    0 g! j& k) Y, w{
    - C" W! J9 Q- y
    ( W7 f/ ^  B7 k" A: k( B4 `8 {# Ri=(*memory).p[0].ioNum;$ d* n, a* U( \8 `& z: W
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed! a0 ^5 ?8 j7 s3 |+ R7 [0 @, \
    {
    2 }& `! w: J+ `. Q  W5 P(*memory).p[0].flag=computing;# U2 F' _8 x4 \# V# {, p
    (*memory).p[0].ioNum--;- g( y; c/ h9 ]' O- w
    change += exchange_IO_Compute;% P- u5 v' z2 Q6 T" {
    waitio++;" s9 a* I* t0 _# d
    }* B+ F9 d3 _4 [" O# A" v0 r
    else
    3 }7 k: ?. p& ?9 O+ _. K  ~9 G{
    . q- l5 O- m* }$ i: ^waitio++;& ]. X% ^, x9 }7 x
    }
    ; _! N6 Q6 [& u; U5 V+ k}
    + ]8 ]# W) j- aelse if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)
    7 \! x( L' L5 A  U8 L( n4 [" a' K{
    # |, \' b. o8 X% N(* memory).p[0].flag=IO_waiting;
    % q9 I) Z$ T$ U- `5 bchange += exchange_IO_Compute;
    ' c* g  u  Z. \}
    ; j# C6 x& n7 |. R" U7 Kelse if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)
    - \( P2 |5 ]# ?) u. E% i9 B" ]{. Y& b7 \& w' }# J" [+ Y
    (* memory).p[0].flag=computing;$ F- p% c+ I' J4 l1 P! ]3 M, h. u
    change += exchange_IO_Compute;9 V+ L6 V; O& `' E. a2 K6 p1 H
    }
    8 ]" V2 ]0 e% y. Aif((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成) X' P1 G: Y0 J; E+ r
    {
    - C( U+ _# w( p) i1 E2 M$ e5 t/ E! J(*save) = (PCI*)malloc(sizeof(PCI));
    ! h& r6 D% h9 ^/ k1 U( g1 S( H4 ?(*save)->next = NULL;
    ; L5 c8 A2 O% F(*save)->processID = (*memory).p[0].processID;2 y8 Y% a+ U) {& E9 f! {  g2 D
    (*save)->comeingTime = (*memory).p[0].produceTime;( N& H, {8 }- K7 K
    (*save)->askMemory = (*memory).p[0].askMemory;
    , D, V0 R8 T1 ?( s: W& y+ U5 {: S(*save)->compute = compute;
    + h/ E; |4 f2 \. p( _& q: Q(*save)->waitio = waitio;
    - {, \& K$ O* m' t& ~(*save)->exchange = change;. }0 |+ p: C& F3 v- m' Z
    (*save)->completedTime = systemClock;
    / D  T1 A5 p$ Y/ v(*save)->runningTime = (*memory).p[0].runningTime;
    " `+ `% F. n( a9 Z, @+ y*spareMemory = MAX_MEMORY;//*spareMemory + (*memory).p[0].askMemory;
    : s$ B5 [. {/ Q8 W/ k8 O6 j8 wcompute=waitio=change=0;) m$ T5 ~5 `4 G  c  T
    computeLast=waitioLast=changeLast=0;( i; I' I; }7 x$ X$ D
    SJF_storage_to_memory(&(*storage),&(* memory),&(*spareMemory));/ F+ a4 Z  e9 j! f
    change += exchange_process;5 h& X# E% z/ B: v7 V
    return task_completed;
    9 g" r! p' |. H. r- \1 h}
    4 V+ K1 p; V- f( R. ~  p2 e1 l6 ielse
    . c( Z9 i2 g" W; v6 breturn task_not_completed;" J5 _+ Q8 k0 G) s; O: F
    }* s+ t/ S2 U8 X: e
    int SJF_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory)8 }, ^8 H9 ~6 I, C; r5 r2 R
    {
    ! \( Y* K0 e+ Z' _3 {int i=0,j=0;5 M! U+ J: y* K* H0 i7 ^' `
    for(i=1; i<(*storage).proNum; i++)
    ! j! Z8 D" s6 S6 v& `{
    3 J2 S$ H+ q2 L' W* k4 L9 u8 m1 [if(((*storage).p.computeTime+(*storage).p.ioTime)<((*storage).p[j].computeTime+(*storage).p[j].ioTime))6 `* p) E1 U/ m) U7 z
    j=i;
    ( U  h* |1 ^& x3 f( t! o& A1 Q0 j}
    0 q: V- Z+ g, U( z9 @" \if((*storage).p[j].askMemory > *spareMemory), Q! l" w3 H* d, S/ C# i! B0 C$ Q
    {0 h% H- C6 I' b3 a* D" T
    printf("The memory asked is overflowed than the system memory.\n");
    1 i- V9 g$ w  R3 `2 U3 g: Mexit(0);
      Y: K- G2 U7 f' u- |}: j) D) ^3 V/ }! m/ `( t3 y2 l
    else, w4 P% R5 D9 H0 |2 O
    {
    , R# e/ h  R! F(*memory).p[0].askMemory = (*storage).p[j].askMemory;( O" ^5 R, |5 [, D; {& d) G- p, c
    (*memory).p[0].comeingTime = (*storage).p[j].comeingTime;
    ; o# m9 k% ]9 d7 s1 g4 V% I, \7 Q(*memory).p[0].computeNum = (*storage).p[j].computeNum;
    ( h  E3 l+ u4 ]- l; O# y" M(*memory).p[0].ioNum = (*storage).p[j].ioNum;, C+ K) N- j, w3 b- p- P
    (*memory).p[0].processID = (*storage).p[j].processID;
    8 R) F/ |6 W/ M: j(*memory).p[0].flag = (*storage).p[j].flag;
    . a! W# E* ?- L( H% @8 D; a0 K: }0 `; a4 U(*memory).p[0].ioTime = (*storage).p[j].ioTime;- g8 D; h1 u, A0 [
    (*memory).p[0].computeTime = (*storage).p[j].computeTime;5 W4 ^1 Y  O0 d! X4 }: Q2 x, O
    (*memory).p[0].runningTime = systemClock;
    ! k' h( X! _( T0 q: Q" g(*memory).p[0].produceTime = (*storage).p[j].produceTime;' t# x+ y2 L& m
    for(i=0; i<(*memory).p[0].ioNum; i++)
    8 N0 l# |) F/ I9 K$ F! y' y9 c4 p(*memory).p[0].ioClock = (*storage).p[j].ioClock;1 K8 l* V% ?4 l; r% e' G
    for(i=0; i<(*memory).p[0].computeNum; i++)) P) V1 W" }5 P8 I* B1 y( H' z  W
    (*memory).p[0].computeClock = (*storage).p[j].computeClock;
    ) ?5 u8 j9 b/ b/ A(*memory).proNum=1;
    & _9 ]' N# E' K, B  J4 X5 M0 u*spareMemory = *spareMemory - (*memory).p[j].askMemory;
    9 R9 m1 o, g* j. Cproduce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程
    0 t; W7 o( X: H& g  pMAX_COMING_TIME = (*storage).p[j].comeingTime;
    / Y0 j1 Y% `; ]3 v# J}
    " v( I. w  {7 K1 c) \return 0;  T% c& E/ F2 @. ]
    }/ F: v4 m: t( M2 Z- C
    int TimeTurning(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)
    % |$ Y( I9 }: [{
    $ c; r4 O  x. k& F/ s$ nstatic int compute=0,waitio=0,change=0,clockSegment=100,poi=0;! G; G! S  [/ F/ d4 @
    static int computeLast=0,waitioLast=0,changeLast=0;" f* x+ D8 [3 C6 m
    int i=0,j=0,k=0;1 f8 `; P- q! f8 \: e4 w7 ]* |
    if((*memory).proNum<=0)5 j* y( d6 T- N# k7 C
    TimeTurining_storage_to_memory(&(*storage),&(*memory),&(*spareMemory),-1);
    2 ~! A" T2 N; w' D. rif(draw==1)$ H' Y9 p. s  R( V( h, U& Z
    {
    # m% t$ s3 o! B* t//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    ' E7 g! t0 k  U5 V& K1 P0 ~drawPerformance_TT(400,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);9 h, B! E4 Q/ }9 P9 f3 ^
    ( O% I' Y9 Z1 C. m* j+ r) |8 W
    " ~; K0 _: q" a" u1 t8 l
    computeLast=compute;
    1 k% k$ k1 ]0 X  T% A: lwaitioLast=waitio;1 W' x6 w* d9 ?4 w) c" f3 A* l
    changeLast=change;
    5 A' z/ B6 ~+ m$ b}8 q$ c+ U5 N- y! d* J* t
    if(poi>=(* memory).proNum)
    0 ?' x  }/ G! f0 q" g" Ppoi = 0;1 S6 ]5 ]) r/ n9 ]- x( \
    if((* memory).p[poi].flag==ready): y# U5 N, p% X! D1 a& {
    (* memory).p[poi].flag=computing;5 ^2 J3 f) S7 y; i4 u, }  f
    if((* memory).p[poi].computeNum>0&&(* memory).p[poi].flag==computing)
    7 x% ?# m; ]# q, p: }/ K{/ N$ X5 U2 `& I& w
    i=(*memory).p[poi].computeNum;( I4 b4 W0 F' C0 |8 X, J
    if(--((*memory).p[poi].computeClock[i-1])<=0)// one compute tase is completed* v& j1 G: M+ X5 }+ Y5 D$ p" G- g
    {0 P1 G' {/ [& W, e+ C4 d& {
    (*memory).p[poi].flag=IO_waiting;
    * D3 c& |: |4 X9 X(*memory).p[poi].computeNum--;
      H) ?3 M! R3 a2 R1 nchange += exchange_IO_Compute;
    - W6 Z, P- ]8 Q. h: J$ Pcompute++;3 r1 D. @+ P$ J( X% c; C  I+ x
    }
    $ P, c# I1 c9 u0 l8 J% `else# f7 L8 Q! V. f( y" K2 g
    {
    % c* C; e$ m6 }- Scompute++;
    ! p& l9 A4 p6 a/ o0 M4 ]* i0 Y}7 [4 U1 J! G% U5 P' Z
    }: J$ h5 f: D6 o1 g0 i
    else if((* memory).p[poi].ioNum>0&&(* memory).p[poi].flag==IO_waiting)" J3 j8 E1 k, R& Z7 ?
    {
    4 Q: O& l& i( i+ k5 X
      p) m0 y" [  e( `) e# ]i=(*memory).p[poi].ioNum;* L4 T- U+ l, P1 L# p4 R4 s
    if(--((*memory).p[poi].ioClock[i-1])<=0)// one io tase is completed9 C- z" I& C! a  k% f1 }4 a9 g
    {( P# s9 R, G5 u
    (*memory).p[poi].flag=computing;
    8 f0 s: ~, u3 O( F+ ~+ b(*memory).p[poi].ioNum--;
    9 U/ u- P5 z8 s6 i! schange += exchange_IO_Compute;  g- J1 f: J% V" j; _+ t
    waitio++;. T" J2 E' V6 q/ S* c
    }
    * z* a, b$ {! B4 @$ J! U7 f# Felse+ o, ~8 n0 h! @2 |
    {
    . X% d1 F5 C; i) M4 E7 k- iwaitio++;
    1 |9 L8 _- n3 M2 b% H8 I7 I}1 Z) i; g6 Y, e0 B/ s8 M
    }/ W: a; ]0 |$ n
    else if((* memory).p[poi].ioNum>0&&(* memory).p[poi].flag==computing)
    # d" J# ~9 ~& X$ D9 \. w4 d{2 t6 [* Z( N0 g
    (* memory).p[poi].flag=IO_waiting;
    * o* w% ^+ c8 }) j/ y3 Hchange += exchange_IO_Compute;
    4 R- w0 {; d6 c}
    6 S2 X) P$ W% S$ ~/ S# Eelse if((* memory).p[poi].computeNum>0&&(* memory).p[poi].flag==IO_waiting)9 \, |0 z/ {7 m2 G' F+ A
    {3 Y. b  H' \9 O3 x! R8 `
    (* memory).p[poi].flag=computing;) G0 H4 _) j# f( A$ M' b6 |
    change += exchange_IO_Compute;" k$ P2 H- W  d5 I6 P! }
    }) B( Z8 b$ g1 E
    for(i=0; i<(*memory).proNum; i++)  //其他等待io的进程可以并行推进' A$ ]/ z: s- ~( d+ z
    {
      z: _5 s9 E# _9 x; n5 p2 s) Zif(i!=poi && (*memory).p.flag==IO_waiting)
    ( P7 o* R" {; p+ C* Z) ~{; G# ~/ I8 h( J  i. c2 k
    j=(*memory).p.ioNum;
    3 B* @1 s& x6 a" o, _if(j>0)
    $ p0 f# r5 B. C0 h{
    : r- L1 F3 ]; ]* v5 dif(--((*memory).p.computeClock[j-1])<=0)// one compute tase is completed
    / A) V2 _1 ]/ P6 z" N* H- F{
    5 {  l/ K! z: u* V% n(*memory).p.flag=computing;1 y. E4 B4 b( X: l
    (*memory).p.ioNum--;% {; t0 a1 s: q0 N4 q/ \) C& N
    change += exchange_IO_Compute;. h+ T) k% V5 j& d( Q
    }' a1 M. Y5 t8 E
    }
    ( `5 k! Z5 T# T% q2 x9 F}
    - h. @/ |$ P+ F+ |}7 S: y! u1 F+ m% E7 E; B, \
    for(i=0; i<(*memory).proNum; i++)  //处理已经运行完毕的进程
    * M# U4 n$ Y& @5 u* ^% m. q{
    % [9 S4 A# Y; r, A1 nif((*memory).p.ioNum <= 0 && (*memory).p.computeNum <= 0) // a task is completed
    . y5 n# \& s# F. I8 R; E{
    % R- w; T2 D$ c0 g: m: |2 S7 `6 O! f(*save) = (PCI*)malloc(sizeof(PCI));
    ; b/ l% B3 e' w0 @9 S(*save)->next = NULL;( J& A. [( f% _* ?
           (*save)->processID = (*memory).p.processID;7 |  D, \: l  [. p% D3 l2 q5 `
    (*save)->comeingTime = (*memory).p.produceTime;8 d! A8 z3 y* L+ r- n% S9 T
    (*save)->askMemory = (*memory).p.askMemory;
    * i8 r1 @5 N/ c7 J(*save)->compute = compute;
    . I& q" q# v  Q+ q) L" `& p(*save)->waitio = waitio;3 ?# k3 F" t" s+ v( X6 P+ n
    (*save)->exchange = change;+ e! F) u: s" m+ m2 L  X4 r
    (*save)->completedTime = systemClock-(*save)->comeingTime;
    3 Q* V8 H& K: V(*save)->runningTime = (*memory).p.runningTime;/ n- J% A2 z/ P% w5 I  c
    (*save)->completedTime = systemClock;8 g9 |" u8 k, |. ^
    *spareMemory = *spareMemory + (*memory).p.askMemory;
    " @& P: I; ~5 Z3 `+ T" rcompute=waitio=change=0;
    . A  C% d' p$ [9 X4 v9 [) z  hcomputeLast=waitioLast=changeLast=0;
    6 U  j6 }6 r8 m5 t4 pif(TimeTurining_storage_to_memory(&(*storage),&(*memory),&(*spareMemory),i)==1) // 调入一个新进程进入4 k( x% ~9 p, u& S2 X9 }# `
    {0 {) a- |& T! O+ U! R- d
    if(i==poi) //占用CPU的进程已经运行完,将时间片分给其他进程3 p. s  Q3 K+ }& D, W
    {
    ; P3 k" |' p0 I! z( v, h7 upoi++;
    7 V" o, B# Q) x& A' ?0 i   clockSegment=2000;4 h7 K% \* z, I
    }
    5 s, ^6 t" N- v7 f1 {}
    2 [( _5 }2 X4 C. U/ b* X5 Telse  //没有足够内存调入新进程
    3 }( L3 ]# f0 H9 S{% x* j% i- J0 r2 R; n
    if(i < (*memory).proNum-1)
    0 q+ T7 h; M: {; ~$ L{
    4 y  c; P$ X4 F, X- O  F& afor(j=i; j+1<(*memory).proNum; j++)
    2 i, v0 D( x* h% i{
    4 m  L6 y* O+ n: ?0 {0 X  Q(*memory).p[j].askMemory = (*memory).p[j+1].askMemory;
    ! S4 k$ E. J0 ?- s+ N6 ^(*memory).p[j].comeingTime = (*memory).p[j+1].comeingTime;
    # P9 x4 T: p, t6 ]+ b" E" g(*memory).p[j].computeNum = (*memory).p[j+1].computeNum;4 I" C9 L- N1 ]& M
    (*memory).p[j].ioNum = (*memory).p[j+1].ioNum;
    0 h; e0 M8 `, E+ x; [2 i4 m( |(*memory).p[j].processID = (*memory).p[j+1].processID;& l9 k" {9 p/ k/ y
    (*memory).p[j].flag = (*memory).p[j+1].flag;3 R9 I2 b. t8 J9 P
    (*memory).p[j].ioTime = (*memory).p[j+1].ioTime;
    * O; E0 L0 _( i(*memory).p[j].computeTime = (*memory).p[j+1].computeTime;6 P5 W8 {- d* T% S" o! W
    (*memory).p[j].runningTime = (*memory).p[j+1].runningTime;
    . u6 o$ B9 m; [0 u9 r0 O(*memory).p[j].produceTime = (*memory).p[j+1].produceTime;9 Y6 \* }. }( d) ?! x
    (*memory).p[j].completedTime = (*memory).p[j+1].completedTime;$ i! j" Y$ k0 b) m! I# ^; L6 ~% b  U( D
    for(k=0; k<(*memory).p[j].computeNum; k++), l; i1 {, _" z7 d# V$ y
    (*memory).p[j].computeClock[k] = (*memory).p[j+1].computeClock[k];3 A/ i! P% ]) y4 Z9 B  W6 C# U. g
    for(k=0; k<(*memory).p[j].ioNum; k++)
    5 E; }7 `( l) |" z; k7 K& m(*memory).p[j].ioClock[k] = (*memory).p[j+1].ioClock[k];7 C4 b; H+ u$ O8 X, d. g- C, D/ @
    }
    / B4 _1 u2 a+ r' L/ Y. s# V, M( u: Rif(i<poi)
    6 W% ]) T( l2 O* npoi--;" R/ W$ o. @8 w& I; u
    else if(i==poi)
    ) @) e# I& I% _8 zclockSegment=2000;& d1 \5 }% g) `" ~- o7 y
    }: ^( }) ^. g+ U
    i--;
    9 Y* _, l! L5 d" [8 }# X(*memory).proNum--;
    9 x7 t8 Q7 U& h* r$ Z( d}
    ' _8 S, \3 m) Rreturn task_completed;! d' {  T) i1 [5 I
    }
    % S9 p0 Q( x) u" B% r}1 i; {. x7 A9 D# e" [$ e
    --clockSegment;
    ; B5 P' \1 Y1 |if(clockSegment<=0)& {* i. A/ r/ o5 q2 K) B0 H2 q/ s
    {5 F4 M. a, Y8 y( W! O
    poi=poi+1;
    7 {- ^% c* T- ^! Bif(poi>=(*memory).proNum)1 ^; l) J/ l3 I& _) s
    poi=0;
    + b* w% B7 b3 G, W6 d+ g$ zclockSegment=100;5 _* Q( }: w; N7 U
    }+ \& a1 U. h% j7 E/ {
    return task_not_completed;0 P) a. f* ?1 o7 ]1 i( U) Q
    }- g9 {1 X% x1 n6 X
    int TimeTurining_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory,int pos)
    & p) S. M$ R. t) z( |, [3 o9 I{7 a. o  N6 ]! V/ L: x+ t
    int i=0,j=0,k=0,flag=0,translation=0;  f( ?0 @" |5 F" k% I8 W# {
    for(i=0; i<(*storage).proNum; i++)7 f9 a2 s- K+ x2 ^: ~; {8 Z
    {
    ( K# f8 M. F+ Q, A; Aif((*storage).p.comeingTime>MAX_COMING_TIME)$ y3 D9 n, o+ O/ J8 j$ K& t+ j8 z
    MAX_COMING_TIME = (*storage).p.comeingTime;' l: X3 f8 j. ~9 H/ N! G. f
    }0 x& P* f% ?) K
    if(pos>=0)
    ; t& u" c) J. p" l: y3 ^" Q{0 j/ M. E8 o9 v4 j, v
    for(i=0; i<(*storage).proNum; i++)
    : |) ^9 _1 Z2 e( F, Q{
    ' {* ?$ [$ Q. ~# Yif((*storage).p.askMemory <= *spareMemory)
    # X6 O& T1 h2 `9 P$ E& _0 P{
    # \" |7 k/ ~# a4 X4 u( oj=pos;
    4 @6 g$ G9 c/ G2 M  j6 \' T! U+ A(*memory).p[j].askMemory = (*storage).p.askMemory;
    8 R! N3 A4 ]( p  D(*memory).p[j].comeingTime = (*storage).p.comeingTime;# q1 a9 m0 p7 d- G8 C
    (*memory).p[j].computeNum = (*storage).p.computeNum;
    . }  a6 ]7 R" \! k  j3 @(*memory).p[j].ioNum = (*storage).p.ioNum;& E) M! n5 w( q* m) F. c: E1 ?: F% s* i
    (*memory).p[j].processID = (*storage).p.processID;
    . k$ l5 }; p* H(*memory).p[j].flag = (*storage).p.flag;
    ! A4 \! ^8 Y& U(*memory).p[j].ioTime = (*storage).p.ioTime;( I$ w+ O1 T. B# _
    (*memory).p[j].computeTime = (*storage).p.computeTime;; C) m' j' A$ A4 H! b2 x- t5 X
    (*memory).p[j].runningTime = systemClock;
    $ x4 o. M  j, B( i(*memory).p[j].produceTime = (*storage).p.produceTime;! ^) V/ k2 Q3 K3 N
    for(k=0; k<(*memory).p[j].ioNum; k++)
    + M3 L9 W0 J) I: g) M(*memory).p[j].ioClock[k] = (*storage).p.ioClock[k];
    % h' T! F2 f7 e' Wfor(k=0; k<(*memory).p[j].computeNum; k++)+ o* j; _, U7 A- ^4 A% A
    (*memory).p[j].computeClock[k] = (*storage).p.computeClock[k];
    6 Y- c. A  J2 f3 r/ c*spareMemory = *spareMemory - (*memory).p[j].askMemory;  a* i% T8 P$ t( b6 ?8 Z
    produce_one_task(storage,i,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程
    , k' s' S" Q# p5 U, G: t, {4 LMAX_COMING_TIME = (*storage).p.comeingTime;
    : h! E& ^3 i" `translation=1;4 J7 O9 K  S+ O0 s1 z
    break;
    1 w; d& O: T& K0 D% s. j}/ [# h, m) L3 M0 e# p
    }* a! s3 j7 v0 D0 n2 N0 c
    }
    - }, r. K; S1 `7 }else
    : H8 [; Y4 n: e% C' e5 p7 v, u0 T* M{
    , G" C+ S. h, g8 [( `+ Rwhile(1)) f$ N1 W2 t6 M! n# X; W
    {
    ( t" F: @4 @4 r1 Gflag=0;: ~- D) l9 Y7 D3 I
    for(i=0; i<(*storage).proNum; i++)
    0 D& j' Y" t# ^0 P$ ]& D{, [) I+ ^3 M  U) t# K2 F
    if((*storage).p.askMemory <= *spareMemory)
    2 n& f5 A8 V! C% ^5 l6 p, j5 \/ {! `{
    : w- J- j0 D' a9 c  S- zj=(*memory).proNum;
    1 ]. ~) V6 [" M% @1 g(*memory).p[j].askMemory = (*storage).p.askMemory;
    , P: O. ]1 V0 M! y/ g2 H* B(*memory).p[j].comeingTime = (*storage).p.comeingTime;
    7 _6 `6 {( g! T' T6 W+ m% F9 s(*memory).p[j].computeNum = (*storage).p.computeNum;
    % K5 B1 _8 ^4 ~3 {(*memory).p[j].ioNum = (*storage).p.ioNum;4 B3 S* X7 y3 T; d$ O0 `8 O/ w
    (*memory).p[j].processID = (*storage).p.processID;5 K- @& \0 n. ?- s3 M- i
    (*memory).p[j].flag = (*storage).p.flag;
    3 n$ g) Q# w0 @. A& a3 n(*memory).p[j].ioTime = (*storage).p.ioTime;
    + E4 }7 k3 P: g0 B, S* \$ O(*memory).p[j].computeTime = (*storage).p.computeTime;6 _" B1 O. C( S* O6 x/ H
    (*memory).p[j].runningTime = systemClock;, b: M% \! S. Y: d
    (*memory).p[j].produceTime = (*storage).p.produceTime;1 w8 r0 W) N& O1 m
    for(k=0; k<(*memory).p[j].ioNum; k++)
    - F/ J1 C( Z5 F! b/ _9 J/ d1 i(*memory).p[j].ioClock[k] = (*storage).p.ioClock[k];
    * _1 U* P* T" J/ ~' E. Rfor(k=0; k<(*memory).p[j].computeNum; k++)& r3 i. L2 A1 p+ R# t- Y
    (*memory).p[j].computeClock[k] = (*storage).p.computeClock[k];4 l4 ^3 ~) ]$ F1 Q3 K
    (*memory).proNum++;
    * Q6 ]: A: X4 ^% J* }& b1 N*spareMemory = *spareMemory - (*memory).p[j].askMemory;
    1 \! [% k* d$ V3 p. L7 ]produce_one_task(&(*storage),i,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程  K" ?; G) R  C7 t7 r
    MAX_COMING_TIME = (*storage).p.comeingTime;) r; g" Y0 s! J* y
    flag=1;
    ) s0 [5 E* L  @; atranslation=1;
    0 Y7 A6 G1 N. o}) r" \/ D: G% s5 U( p( Q  ]2 u
    }
    ! D) L, Q8 i8 k2 |3 V7 ^- D+ Aif(flag == 0)7 k1 W9 M  A! `- p( h' L
    break;
    ) a* J' _- {6 K2 k* l! Y}' U. x+ v- {2 N2 L# }+ d
    }
    9 ]8 K' e( X3 h7 q0 W7 Ereturn translation;/ j  ~- {2 g- l, m
    }5 S) c6 A2 z) k9 D* H
    int FIFO(processPool *storage,processPool* memory,int * spareMemory,PCI ** save,int draw)
    - H' U- C$ C. e+ l{
    6 D' `4 y2 [- S: N# b6 Istatic int compute=0,waitio=0,change=0,flag=0,flagiocpt=0;
    - S: [- ^& b7 {- B2 r% n2 Jstatic int computeLast=0,waitioLast=0,changeLast=0;/ |. h8 D0 q- U; A2 z. T: H
    int i=0;8 N  ~. Z/ ]; j
    if(draw==1)6 Q+ H% q6 ?: p3 b
    {
    2 S( v. Q! F0 D8 t//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);$ C& E! V) R0 e! R. j+ ]: i9 }
    drawPerformance_FIFO(0,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    ( j; U  f- J0 @$ H# i
    6 M: |, z, ]6 H( a& A" j" x! ?+ ~- H6 T8 w2 w+ o. p
    computeLast=compute;
    : q- h; I0 e6 k# F6 u( o$ zwaitioLast=waitio;0 M  E' Q/ c7 E& V' {1 E- B  N2 T1 Q
    changeLast=change;) Q4 a5 N9 x; E
    }
    1 D, _9 z! }8 oif(flag==1)  
    ) Y# p2 v' [8 T4 J- r{
    " d* k& C: m: kif((*memory).p[0].ioNum>0||(*memory).p[0].computeNum>0)  //task is not completed% m+ X. l' j. d" B
    {$ i# R! }( R; r- b
    if(flagiocpt==0)   // implement compute# m: s6 k3 O- o5 D, S, u
    {% R5 M+ `8 ]: W+ K& g
    i=(*memory).p[0].computeNum;
    0 e+ F' ?1 I. B) pif(i>0 && (*memory).p[0].computeClock[i-1]>0)
    % e# w3 L3 F% b+ o; a2 ~; v' \{
    & T# p& M+ ?& oif(--((*memory).p[0].computeClock[i-1])<=0)// ome compute tase is completed0 K9 s, e7 [( r; f
    {
    5 H& C3 [. C. M" Mflagiocpt = 1;
    " d2 E0 G9 d* x/ h0 `(*memory).p[0].computeNum--;/ {$ t# e0 W: Z* D2 |
    change += exchange_IO_Compute;/ t# A4 M/ _, K1 ~
    compute++;
    / J3 T. a% E( |4 s9 T}
    * o0 m" {6 ^4 e* t4 V! Yelse
    % ]* S% y$ N0 Vcompute++;7 ~0 u# e# d1 r" |

    5 s' s5 F0 P- _& q# O% F8 `0 S, V}
      N# J* O" [" R# Ielse
    6 @' g' c# X7 p% Qflagiocpt = 1;
    ' }" S/ f" Q) H0 O) ^}& [5 e+ {, E  i2 W  f
    else  //wait io
    8 v3 @8 M/ i. g/ k! \{
    6 c9 p1 G7 w9 v: G9 `! s4 E6 Zi=(*memory).p[0].ioNum;
      h% c8 i4 N% O" @8 h1 Kif(i>0 && (*memory).p[0].ioClock[i-1]>0)9 I6 N: n0 e4 T
    {
    ; h* {/ I1 z7 O7 q6 [if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed
    ; T: j2 `, O$ V# \/ w+ O{, l9 a* @% {9 l! O, J
    flagiocpt = 0;
    , i7 X0 e* E$ Y8 i7 a(*memory).p[0].ioNum--;. ^3 V: ]+ B( h* U  {+ l
    change += exchange_IO_Compute;7 b9 I  s8 x4 D2 R7 |% l$ C( _4 ^% T
    waitio++;! x1 Y  w+ o- G7 ?# \  Q5 E3 b
    }
    . O9 I1 q7 T9 S1 ~else3 H& ^9 M8 \. Y' [
    waitio++;, v% W$ h0 m+ t# Y7 W7 ^
    * m' d: g# b; \/ [% |* g/ a
    }
    6 M4 K6 ?  Z, ]else
      r( ?+ Y+ E1 o( T5 |, `/ rflagiocpt = 0;- v- R* N5 @) S: `6 P% A! B
    }. p- `2 v9 ?( K, F. C4 |8 K5 D
    }) r4 V) e6 q# A5 _/ u( C
    else  //task is completed, Y) t3 W7 w5 b& x+ y" _" U; O
    {0 Z4 S2 w, x6 I* ], v
    (*save) = (PCI*)malloc(sizeof(PCI));
    , n% n, a4 F3 y' X3 L1 p8 p" Y(*save)->next = NULL;0 {) a6 J) o7 V/ V' o0 n
           (*save)->processID = (*memory).p[0].processID;
    ) c% W) B! ~" U3 y9 U  Q(*save)->comeingTime = (*memory).p[0].produceTime;
    8 `3 T- m) T& R/ I$ G- z6 f(*save)->askMemory = (*memory).p[0].askMemory;
    ' N' v, n( S$ u) ~(*save)->compute = compute;
    5 z$ Z2 Z/ I! f3 [(*save)->waitio = waitio;
    9 d) f  @! f3 t1 v(*save)->exchange = change;5 M. {$ \3 r; w! z/ p/ B' }
    (*save)->completedTime = systemClock-(*save)->comeingTime;' r) }: M% c5 w" T  V
    (*save)->runningTime = (*memory).p[0].runningTime;
    * D1 N% S- Q, L' _/ f) X6 b+ c(*save)->completedTime = systemClock;- j6 c- W* q2 h" R0 o  G( @- k
    //*spareMemory = MAX_MEMORY;( A, A2 r- T/ p; E" f* r
    free((*memory).p[0].ioClock);# h0 [. b2 X: f- y
    free((*memory).p[0].computeClock);4 {2 `$ \) |: @: ?. G
    free((*memory).p);5 O  E  e" M& L+ H) ~
    flag=0;
    9 X) h. v; k: j: h9 j0 D8 r) Scompute=waitio=change=0;: m; C* J3 r( \5 L
    computeLast=waitioLast=changeLast=0;7 x# @& f9 i9 V& j
    return task_completed;' s3 u# M& a% t5 X, n) a
    }
    + |! l1 W2 B$ W. ~5 B2 n}
    5 L6 p* w( E6 R! |# Qelse           ~* S8 _: ]! P1 F' F) y
    {( J- ?7 s8 \) v8 c: X
    FIFO_storage_to_memory(&(*storage),&(*memory),&(*spareMemory));
    8 L' }" _9 O; |& }change += exchange_process;
    7 c; r8 @4 R+ C//*spareMemory -= (*memory).p[0].askMemory;9 A+ U$ [) B& L0 G% C, ?
    flag=1;
    ' M& |. f1 F9 S3 y$ s% F7 g//showProcessInf(*memory);7 A. e! r1 p* d% g+ K# I. O/ r+ u( k
    return task_not_completed;
    " u7 l! i) a7 R1 \}
    : g3 }2 @6 f% V4 u5 ?5 |! Mreturn task_not_completed;0 q/ o4 u! D) Y8 m8 h
    }
    $ x1 S+ R! W8 I0 y+ V* r$ S, B; _int FIFO_storage_to_memory(processPool *storage,processPool* memory,int * spareMemory)5 P2 ]2 [, l; b+ z! k5 H8 p" m# r
    {
    $ ~; I, \: w7 fint i=0,j=0,k=0;5 d2 A5 |! M2 O$ B/ D" B% Y
    MAX_COMING_TIME = (*storage).p[initProcessNum-1].comeingTime;1 L- G* {. z  Y0 `- F2 }- a. J) Z
    (*memory).p = (process*)malloc(initProcessNum*sizeof(process));
    9 e. }  _% f$ R, vmemory->proNum = 1;) Z' o7 |& }, V- p1 R$ |  |; G. b
    for(i=0; i<initProcessNum; i++)
    + j, U& S' }% l1 e& G# @{) @9 }9 e  B5 X# r* |
    if((*storage).p.askMemory <= *spareMemory)
    - z4 A. `) R/ @5 O2 }+ k{
    ' S6 s. e% z3 i6 o0 U  [7 O2 w(*memory).p[0].askMemory = (*storage).p.askMemory;
    9 @' m4 J; F( c) I: _6 \(*memory).p[0].comeingTime = (*storage).p.comeingTime;
      j  e3 n/ ]1 u' h, w(*memory).p[0].computeNum = (*storage).p.computeNum;- M$ Q# o$ j+ ~6 w, c! Q
    (*memory).p[0].ioNum = (*storage).p.ioNum;- R) t9 Z4 T, \# _
    (*memory).p[0].processID = (*storage).p.processID;
    3 ^( f9 O! r+ b. D2 f* v# j0 e(*memory).p[0].flag = (*storage).p.flag;
    + d; ]+ N' v, G- Z(*memory).p[0].ioTime = (*storage).p.ioTime;
    % z/ {: P! V% L7 T: Y3 M0 m(*memory).p[0].computeTime = (*storage).p.computeTime;" a% P- g0 Y4 r( x
    (*memory).p[0].produceTime = (*storage).p.produceTime;; z  c) u# W( M% G
    (*memory).p[0].runningTime = systemClock;
    9 y! U) a8 C: y! X(*memory).p[0].computeClock = (int*)malloc((*memory).p[0].computeNum*sizeof(int));
    # |& N% ?. Y' b(*memory).p[0].ioClock = (int*)malloc((*memory).p[0].ioNum*sizeof(int));
    9 {# L( w& Z" Z7 G7 n' vfor(k=0; k<(*memory).p[0].ioNum; k++)$ ]/ D9 }, n0 J
    (*memory).p[0].ioClock[k] = (*storage).p.ioClock[k];  K" j- k% M0 L. L1 Z
    for(k=0; k<(*memory).p[0].computeNum; k++)- C( v# v3 F) g- Q  Y2 y) w
    (*memory).p[0].computeClock[k] = (*storage).p.computeClock[k];
    3 l% y& S" ~( b% D( K; ~$ nbreak;& @% J7 O, G4 }% ?% b- V0 ]3 k" F
    }
    ! G2 q5 ]. B8 u+ C3 O6 @% q}4 J- j8 D" t5 n3 |% g1 |
    if(i<initProcessNum)  //调用一个作业进入内存后,并再生成一个作业等待调入
    8 X3 O1 i* k; y$ ?{3 F6 e4 h/ H( f, I! s* z
    produce_one_task(storage,i,ID_FIFO++);* S4 r! S( t' P, e, S0 ^
    MAX_COMING_TIME = (*storage).p.comeingTime;1 Q5 `+ r  E/ O3 p
    sort_by_comingtime(storage,i);5 o) O) l: R- {5 @. W- R- y
    }
    / y4 B* g# w5 zreturn 0;$ B- n" s; B% \
    }
    % I6 K' ]- u6 n- X: V; x/ ?int sort_by_comingtime(processPool * p,int pos)
    2 C* D8 C5 N8 e/ q7 G{
    + b1 [3 [5 U; m9 vint i=0,j=0;( r  Q7 K2 Q- v0 |: {0 J
    process temp;
    9 B/ ~) h7 P) E. }' Z1 Y/ uif(pos<0)
    : P' S# F& B) k$ s% H{1 H; |6 Z4 A0 [7 Y, R
    for(i=0; i<initProcessNum; i++)/ ?  ~9 w" @% @" L1 @
    for(j=0; j+1<initProcessNum-i; j++): i5 H  K5 p! B& \% T) b5 I7 F9 f
    {) P+ i' ~: A( b3 E6 M
    if((*p).p[j].comeingTime>(*p).p[j+1].comeingTime)  p( _1 h0 {- y- H$ E  h
    {
    ; |: M& O4 r" K8 ^  R; [9 P0 [temp = (*p).p[j];
    ) Y7 `5 j0 v5 W1 a/ w2 q(*p).p[j] = (*p).p[j+1];: Y7 c+ n. o7 Q0 B8 E/ L) ?
    (*p).p[j+1] = temp;+ |% a6 Z5 w% G2 {  T% b3 t" F: c* x
    }/ U5 T" V5 |; z
    }" `4 _' f3 o7 X
    }
    & H3 A/ M2 ]. g7 k. Helse if(pos<initProcessNum)
    " v/ h0 Q, s! r+ L) O6 z{8 _1 ]2 l. r, Z/ z. e% w( `
    for(i=pos-1; i>=0 && (*p).p.comeingTime > (*p).p[i+1].comeingTime; i--)! c2 |! {9 V; _3 m( C- y- c) I
    {
    3 ^. i. [. W+ ?2 R- U+ G' g7 Atemp = (*p).p;& p  ~* @7 T1 V  Y: [
    (*p).p = (*p).p[i+1];
    : |4 f( s5 e2 y( T, ?(*p).p[i+1] = temp;+ C1 V  ?5 N: {6 n
    }
    ( Z/ v, A( Q2 T: K+ A5 C+ qfor(i=pos+1; i<initProcessNum && (*p).p[i-1].comeingTime > (*p).p.comeingTime; i++)
    # O; _( H( C/ U" z, J& i{0 o: m' V* ~+ q& V: G
    temp = (*p).p[i-1];- D9 A$ f: M/ T' i: O' J
    (*p).p[i-1] = (*p).p;2 h9 }, ?0 w2 F2 Y: f7 b4 C
    (*p).p = temp;% C" k1 t" s( O" J' L
    }, G& i* [6 G3 E; ]4 V
    }
    9 m' t% l6 V3 t/ Gelse
    5 m# }# \' s1 K, u% V! yprintf("position eror\n");
    , i" _$ J# ]2 v1 ?# X2 W8 Preturn 0;2 P  r/ F/ t& \! R9 s* s
    }/ d0 O7 s3 S# p7 F* Y' @
    int InitPool(processPool * p)
    7 {+ v% N  s* n* G7 M{( r5 C. e3 w  K
    int i=0;& }% B) ?! ?% s2 ^  P" \
    (*p).proNum = initProcessNum;
    % x7 B0 A9 S7 ~+ l' K) T- ](*p).p = (process*)malloc(initProcessNum*sizeof(process));
    . s( p, |+ a& a" \+ t" ]1 ~- [" E( Ofor(i=0; i<initProcessNum; i++)                                        //init process information: `9 `; U3 o" K. n  n+ g
    {! A/ b7 K2 k. P( i
    (*p).p.computeClock = (int*)malloc(initclocknum*sizeof(int));: S3 V1 h# i' m  H; u
    (*p).p.ioClock = (int*)malloc(initclocknum*sizeof(int));
    # W0 Q3 a8 R4 [; }6 e4 k* Aproduce_one_task(&(*p),i,ID_FIFO++);
    # g* ~2 Q$ ?) `- L}/ |  f* h* E7 J$ s$ D: B( Z
    return 0;* Q7 o( M5 i2 W$ v0 S5 f
    }/ G2 [% I7 O; R% {# Y2 y9 v: l' z
    int produce_one_task(processPool * p,int i,int id)
    5 Y+ P1 ~  S5 S5 D0 p, E# l{0 q5 w$ k" f1 p, r0 I+ n
    int time=MAX_COMING_TIME,j=0,totallTime=0;6 ^0 B3 o% g% a' \- S* E5 `( l
    (*p).p.processID = initProcessID+id;           / b& i2 C/ F! }' ~* t, Y
    (*p).p.comeingTime = time+rand()%(MAXProcessRunTime/5);3 X- }( R2 |7 {' o! e/ _
    (*p).p.produceTime = systemClock;
    9 w% }9 s- O4 S6 b- \) v(*p).p.ioNum = rand()%4+20;                                        //IO number setting to 2--5;
    * x9 `4 q/ z2 ]) H$ e- R(*p).p.computeNum = rand()%4+30;                                   //computNum setting to 3--6;# y# E/ `+ k$ R. b3 m
    totallTime = (*p).p.computeNum  + (*p).p.ioNum;7 B$ s5 J$ Y" h
    (*p).p.computeTime=0;* w% P7 ?* T4 a! s# Z$ [
    for(j=0; j<(*p).p.computeNum; j++)& m7 b8 H$ t3 y! B5 A" s4 G8 c8 q7 L
    {
    : G" @' q! g7 I7 V(*p).p.computeClock[j]=rand()%(MAXProcessRunTime/totallTime)+1;
    ' L8 Z! E4 u) e(*p).p.computeTime += (*p).p.computeClock[j];
    ) \" N* @/ F$ j4 O/ t& z}
    $ J; p0 p. b" I7 R4 w(*p).p.ioTime=0;
    & u  y0 f) ~8 K; u3 X! A4 r- Tfor(j=0; j<(*p).p.ioNum; j++)
    5 }' t% L& Y- c' b) U/ Y{3 ?4 g: c; [5 r* E- [0 V
    (*p).p.ioClock[j]=rand()%(MAXProcessRunTime/totallTime)+1;
    ) n; ^, Q" [! D; s" q4 I0 R# f6 g(*p).p.ioTime += (*p).p.ioClock[j];
    % r4 W! V9 ^- b5 ?: @}
    # v' E; S, A& Q, p$ O(*p).p.askMemory = rand()%(MAX_MEMORY/4);
    3 a7 b' p6 f. y: [1 g2 d" E(*p).p.flag = ready;
    5 `4 ~1 g9 r$ z9 J+ _$ ireturn 0;
    7 ?3 k* N; d2 _" w2 H}
    7 k% p1 {9 r/ j$ Y. Sint showProcessInf(processPool p)
    ; s% b. n  w1 P7 }6 J1 y8 R0 b# ]- K{/ {8 a, e: O8 S( n
    int i=0,j=0;. {# k6 b7 A. q3 K' V" p
    for(i=0;i<p.proNum;i++)
    , ^( G: M" A* i& o3 Q* M8 W+ p& d{4 x% l# a+ F. M
    printf("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' H* ~8 ?0 y& ~8 _5 A
    ,p.p.askMemory);' g; I4 \0 W' s  X7 j  y$ i7 v* Y
    for(j=0;j<p.p.ioNum;j++)+ q0 `. n+ O+ J! o
    {
    - R1 ]* N! s1 l/ e5 Hprintf("%d ",p.p.ioClock[j]);- V- r: A! t' s0 N9 w' P
    }
    # Q2 h1 ~' H! `3 A3 [* }# wprintf("\n");
    ) U' j! K! e! }for( j=0;j<p.p.computeNum;j++)
    * \* }( v! o/ t+ W7 b2 z{6 f0 a% ?9 K4 w5 B& B. A0 v
    printf("%d ",p.p.computeClock[j]);
    ! Z  k6 f. @  u( t}7 B4 ^9 P% _: Q  {: R1 L
    printf("\n");
    2 U8 K) k, k) {}
    * B; T9 w6 a, I$ W/ ereturn 0;  I5 b5 [8 D+ F: O$ _; S+ O. Q1 v
    }( Q- V( z) b& z
    ————————————————
    1 ?# }5 j% s8 h% \) n- r. ^版权声明:本文为CSDN博主「wang_dong001」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。% G6 S2 c1 \$ {3 C, s& A
    原文链接:https://blog.csdn.net/wang_dong001/article/details/47843519
    5 J3 Q6 p; \; T$ }) h) ?: y
    4 C( Y( q6 l7 L# d' k& ~+ c6 ?/ |# Z* s5 }+ w, W- \+ a5 U
    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, 2026-6-13 22:03 , Processed in 0.487370 second(s), 50 queries .

    回顶部