QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2478|回复: 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
    : T" x" H3 E( d# D' d7 ?
    经典任务调度算法的模拟程序
    ! B+ D) ^2 r: z( l' n本科毕业设计写了一个经典任务调度算法的模拟仿真程序,测试了五种调度算法的运行性能。在程序中虚拟了任务的进程,按照不同调度算法策略从进程池中选取任务执行,在任务执行过程中,保存相关的统计参数,最后对这些参数进行处理,反映各个调度算法的实际运行性能,程序中可以通过修改任务的相关参数改变任务特点,测试不同任务环境情况下,调度算法的性能适应性。程序是通过C语言编写的,为了对运行结果图像化,采用了EasyX的图形库。由于计算机中实的任务调度过程比较复杂,在实验中为了简化程序的实现,在某些方面进行了特殊处理。) P& X6 m3 E, h

    9 B( r& b( R% V$ T/ h' r" p编程平台:VC6.0+EasyX图形库环境。
    , F. C7 T$ Q7 p. q& L& G0 P
    5 }3 r8 Q+ k2 G# z6 B" Z5 q' y0 S以下截取部分程序运行图::
    7 h1 E# b* L# l: q1 ^  w+ x0 q- y9 @" S9 ~: D
    源代码:
    . X* `/ f' p7 Q) |
    ( i$ H3 g, \9 T0 _* J#include<stdio.h>
    9 J" R: |, w3 l/ Q  X( W#include<stdlib.h>! I# H2 }3 ]3 \# i
    #include<easyx.h>
    6 Q* C2 A, P8 ^2 Q+ ?#include<time.h>
    9 b% o2 p9 C. o1 {# D( ?) Q/ g#include<conio.h>/ T/ R8 H& }% n* H
    #include<graphics.h>
    ! p: f9 R* m) k! v: B#define initProcessNum 10- u4 ?1 w( c2 B9 T! U/ q
    #define initProcessID 10003 E) R" h" C1 l# {
    #define MAXProcessRunTime 10000( T5 ^. R+ V" [
    #define MAX_MEMORY  4000
    / T/ l' F5 [; J#define exchange_IO_Compute 10
    8 n8 |5 |, E' O9 X! X. V#define exchange_process 255 v. B* t. }; |" n
    #define task_completed 1% n1 i9 D! o+ Y1 \1 l# d& F- t
    #define task_not_completed 08 F: s$ n& Y. S" b2 \% M/ S
    #define initclocknum 100
    7 b; K7 @# |- Z7 U0 i( Senum condition9 {. ~" V9 H3 M7 V- f7 k+ T& e7 b
    {
    * _% m, l. b$ ndead,computing,IO_waiting,ready! m/ H( C! [! z! y0 l
    };
    , V1 x# S9 h. G  V7 y" bstruct process, S1 |$ c3 i# o  x0 K
    {" S; P8 W' A  M! N$ @) r# F
    int processID;& P3 l+ k6 D/ L7 K' W* p, o  s
    int comeingTime;
    7 p1 r7 Q0 Y' p) u9 pint ioNum;
    . `; k* t3 x  e$ @/ _int computeNum;
    / ^. K$ w' Z4 B% |4 zint * ioClock;
    4 v0 ^% s4 g3 i0 P' _int * computeClock;
    # T! k6 l: d) T7 F( vint ioTime;  \9 |: t+ e  e0 U! N$ Y
    int computeTime;: U8 u" t$ x" Z. K* w) A
    int askMemory;
    % l' b. l; _$ ~condition flag;
    & [7 ]0 c% d* ]6 a* Gint produceTime;  //生成时间,以下三个数据成员用以计算相关性能
    1 L( Z' z; E8 C. vint runningTime;  //第一次占用CPU的时间
    4 ^. e" m  D2 [- D& ~; [int completedTime; //进程完成时的时间0 m: K: J2 P. }- S) m1 ?" ?& d
    };
      a" s+ D& j8 \9 k( y8 ttypedef struct processCmpletedInfo  //保存完成一个作业的相关信息: H, K6 f! s8 F8 {" o
    {: A2 R1 \; H0 b/ {
    int processID,comeingTime,askMemory;; g* W* d* t- |4 X( Y1 k' z: W
    int compute,waitio,exchange,completedTime,runningTime;+ K5 j1 p+ t' q$ s- h/ C; a3 {( w, R
    processCmpletedInfo * next;3 @) V, N8 A* j5 e! U6 l
    }PCI;$ C9 C* ~: ~6 M* D5 H+ }
    struct processPool, |2 I$ h6 F4 j/ L& a) ?( x; u
    {
    & l4 M  h2 g' c- s9 `2 zprocess * p;" Q3 B' l8 V( q6 ]$ u% p/ w
    int proNum;. W; W7 z  X: k
    };8 V6 j6 O+ c$ p& l% P, b: B# U/ Y+ 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;
    8 D8 ?/ R1 ^" O. Z5 _6 A& Kint InitPool(processPool * p);
    ; g& ^1 e" w( Iint produce_one_task(processPool * p,int i,int id);
    5 ~# p7 G* @! g* @) C$ @int FIFO(processPool *storage,processPool* memory,int * spareMemory,PCI ** save,int draw);
    + d9 _( w! H2 n9 s! `int TimeTurning(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    9 X3 g$ d+ T/ s/ ^( L* ?; sint TimeTurining_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory,int pos);6 S( J, w4 W5 p. T% l2 C4 t
    int FIFO_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);
    ) s6 n0 Z% ^$ v3 Z9 Qint ShortJobFirst(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    ' m( \" b% G/ B3 X% \int SJF_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);
    ! ~& P0 J) Z' k* }int PriorityDispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    1 I1 v  H/ u" Z/ p  dint Priority_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);* E1 d8 n: X7 G" G7 P
    int High_response_ratio_s_to_m(processPool *storage,processPool* memory,int *spareMemory,int flag,int disatch);
    , {: ^, l7 P" H# Yint High_response_ratio_dispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    % G/ ^6 Q/ Z6 W  f# a) O6 i. b( Z5 @. A$ \. h! I2 D* I

    ' h3 u. q; M( n: u+ U+ j- yint sort_by_comingtime(processPool * p,int pos);
    * q4 ]- ]; D8 u/ x, u5 cint showProcessInf(processPool p);
    ' M! Y$ ^) ~/ Dint drawPerformance_FIFO(int x,int y,int memorry);
    5 r0 E) C4 f: @* m7 T3 b& S% p, [int drawPerformance_HR(int x,int y,int memorry);
    ' V2 y4 _% ?' @' z, f8 W6 D, w- P. Kint drawPerformance_PF(int x,int y,int memorry);
    ; R* C8 o* P$ D- Lint drawPerformance_TT(int x,int y,int memorry);
    1 V8 _7 k7 |+ f# q  Bint drawPerformance_SJF(int x,int y,int memorry);
      w2 L7 w# m! h1 P4 gint MouseListening();
    # O. }4 B7 E' d+ W6 R- r' F: w: Cint MouseListening2(int *flagShow,int * showTime);
    " U0 l9 P! A4 |/ t: N" U  ?int showRunningResult(PCI* FIFO,PCI * timet,PCI * SJF,PCI* PR,PCI* HR);
    ) S- G# t6 d: v4 y/ J
    % N5 C8 \3 y; ?2 f2 {# {0 D
    " T+ d; i# C' zvoid main()
    , |) I% y  G8 @3 ]% n& Y! q0 V, F" a  K{+ \3 E0 @& c3 L+ H4 H
    PCI* FIFO_save_head=NULL,** FIFO_pri=NULL,* Timet_save_head=NULL,** Timet_pri=NULL,* SJF_save_head=NULL,** SJF_pri=NULL,  y" p/ |) D3 Q7 _7 H! D! F( W
    *Priority_save_head=NULL,** Priority_pri=NULL,*HR_save_head=NULL,** HR_pri=NULL,* p;
    9 V8 U! |/ h" U% b; o7 Y2 hint i=0,FIFO_memory=MAX_MEMORY,count=0,Timet_memory=MAX_MEMORY,SJF_memory=MAX_MEMORY,Priority_memory=MAX_MEMORY,HR_memory=MAX_MEMORY,6 M; g/ |( c2 T$ J7 a
    flagDraw=0,showTime=100000;
    ; X4 Z: T) Z3 C7 A% }processPool FIFO_p, FIFO_mmy,Timeturn_p,Timeturn_mmy,SJF_p,SJF_mmy,Priority_p,Priority_mmy,HR_p,HR_mmy;
    $ {- g2 [# P# e2 m& \FILE *fp=NULL;
    9 K' z: ?# z* b" C( D5 j1 P; V) [) d//processPool HR_p,HR_mmy;& i) g) V9 w/ v6 U$ `5 ^% o" ?
    7 t1 U% N4 d) C' H

    ( Q& J% |4 f" c/ x' Y% V" J5 R# {! Xsrand((unsigned)time(0));
    2 I" ]3 p  G* B5 J- P# MsystemClock=0;
    1 I5 B' E1 x* Y* pinitgraph( 1200,650,SHOWCONSOLE );8 a7 g! l) e- f. |+ \6 L9 _8 x8 _
    settextcolor(GREEN);
    , j# E2 `* N0 p& i' N$ Y& Rsetlinecolor(GREEN);
    . l$ N3 Y. i9 I& ^  s2 osetfillcolor(GREEN);
    2 H: j: B9 B; w# J* r5 r' I5 xInitPool(&FIFO_p);3 M: g' n/ |6 R6 I- T
    sort_by_comingtime(&FIFO_p,-1);4 j9 F) k6 Z& ^
    InitPool(&Timeturn_p);
    + @- U! g0 \- W# V7 Z2 M; h5 D+ }InitPool(&SJF_p);
      j+ d) g$ U& I2 zInitPool(&Priority_p);
    ! X4 d( W. N$ M4 ^( J  N0 P6 I$ iInitPool(&HR_p);
    ! z+ s$ o! a* f: U4 U) H//showRunningResult(FIFO_save_head,Timet_save_head,SJF_save_head,Priority_save_head,HR_save_head);
    1 H, d4 `7 E) i# A& E6 B" z* r+ \//Sleep(10000);
    7 i8 m1 q0 v, @* H! e5 ^7 c' j1 v( |: I$ j7 K

    + ?6 _% I; d8 m; ^/ n! e( oTimeturn_mmy.p = (process*)malloc(initProcessNum*sizeof(process));
    % x+ u& ^, k/ XSJF_mmy.p = (process*)malloc(initProcessNum*sizeof(process));: [' O2 S0 @6 M" {# Z
    Priority_mmy.p = (process*)malloc(initProcessNum*sizeof(process));
    & w" a$ _( r6 {$ B9 U4 R! cHR_mmy.p = (process*)malloc(initProcessNum*sizeof(process));
    , b% W* ]/ @2 j4 G; r  rfor(i=0; i<initProcessNum ;i++)
    0 Q7 d' l. [% w7 u0 s( W7 y{# b: C; H  ~3 f; @7 N& Y% S# a1 N
    Timeturn_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));5 ?6 w3 M$ s2 _7 s& A0 P
    Timeturn_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));
    & ?- z6 I8 @  W& Z2 L/ eSJF_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));) @& x- H  |: o0 _& ^3 }2 ]2 \! K
    SJF_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));( k8 t( m4 ]  V. p. B- y
    Priority_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));9 D4 Q/ q6 x. x7 n8 _" W
    Priority_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));5 ^7 O; L, H; k
    HR_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));& I3 i5 ?8 I* Y/ B1 s
    HR_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));
    4 B4 j# H2 O( D$ a& @. v6 {* U7 g9 @! f}8 \% n& H. w1 d- A
    Timeturn_mmy.proNum = 0;
    $ o1 i# f( f) ]! B0 ]  d: }2 y; Z! [TimeTurining_storage_to_memory(&Timeturn_p,&Timeturn_mmy,&Timet_memory,-1);! u; ^9 L4 v' x: s- G  u
    SJF_storage_to_memory(&SJF_p,&SJF_mmy,&SJF_memory);% J, L1 Q2 E- q- k( a: c! V# _
    Priority_storage_to_memory(&Priority_p,&Priority_mmy,&Priority_memory);
    0 {( k: C' I' a7 y: F! Q4 @High_response_ratio_s_to_m(&HR_p,&HR_mmy,&HR_memory,0,1);
    # z) Y3 W8 b7 O) z7 f//showProcessInf(Timeturn_mmy);
    " j6 E; g: x1 ~4 Z% h( _4 kFIFO_pri = &FIFO_save_head;# B# J$ X0 ^& b5 |
    Timet_pri = &Timet_save_head;
    2 Y! C2 v( ~, w! X3 k5 ?+ Y1 xSJF_pri = &SJF_save_head;& n8 x9 f& y! d& C1 g* W  ]
    Priority_pri = &Priority_save_head;
    / @8 `' l/ y% E" ?5 z! c* n! t7 |    HR_pri = &HR_save_head;
      A& {# P4 q$ Z/ s% j1 csetbkcolor(WHITE);/ x' Y5 \2 G3 t- A; Q
    while(1)  z. c8 b$ l& l( B
    {  B6 z* u/ ~* i6 m: Y" |
    if(MouseListening()==1)
    ; Y  Q! W9 W+ M0 x. x# FflagDraw=1;
    8 K% n  r2 Y4 e. Xif(count==100)
    5 m2 [2 [. V) F6 B0 q{5 @: H( h. R# L
    if(FIFO(&FIFO_p,&FIFO_mmy,&FIFO_memory,FIFO_pri,1)==task_completed)
    . y7 c% `8 A) g- s  ^0 p{
    ! h' N3 _8 B& E! _FIFO_pri = &((*FIFO_pri)->next);
    $ e2 ?& }$ e& k) L1 S0 j' O& E/ A- b; Y. [( [+ F! N; {: b" l% {6 N
    //printf("hello");
    9 c1 A+ _7 {  o: S}
    ' r8 A0 t2 l4 p7 g* cif(TimeTurning(&Timeturn_p,&Timeturn_mmy,&Timet_memory,Timet_pri,1)==task_completed)
    ; G" j& y8 F6 z6 D+ h{
    - _2 R* t! _2 ?$ |" v4 r7 y6 ?3 {    Timet_pri = &((*Timet_pri)->next);
    , z) y. F/ s. Z" W/ q* U//printf("hello");: Q. T" G* i3 n1 A
    }
    6 W- D8 y- ]6 @9 Y# i6 @5 `% b3 gif(ShortJobFirst(&SJF_p,&SJF_mmy,&SJF_memory,SJF_pri,1)==task_completed)
    0 V0 e7 B1 a- p9 t4 I0 c: w7 [0 F, v{
    % Y- \# r8 K9 Y; V5 A( ^# m6 ~SJF_pri = &((*SJF_pri)->next);
    + K: d6 V/ j! k$ g9 e2 Z//printf("hello\n");
    2 B+ L9 @/ E3 q/ y}$ g. o5 k9 B4 M5 }% [
    if(PriorityDispatch(&Priority_p,&Priority_mmy,&Priority_memory,Priority_pri,1)==task_completed)# h) t" w) j: d
    {
    $ f7 r7 A2 X8 dPriority_pri = &((*Priority_pri)->next);
    " e& K, E6 n( a8 c2 @5 }3 G3 G) B//printf("hello\n");* n, P9 z4 V: y" t% V, q# E
    }9 p0 @5 p( T3 C" z; r8 p
    if(High_response_ratio_dispatch(&HR_p,&HR_mmy,&HR_memory,HR_pri,1)==task_completed)1 `7 P' O# V) c, m  O
    {: j9 R6 n9 }# n% U  T: \
    HR_pri = &((*HR_pri)->next);
    - [0 `% k) \( s% [0 J5 T& A0 G. }2 X6 }//printf("hello");
    ' O9 H2 j4 X6 t" t% a}
    ' F0 o$ j6 u: p. o2 V' j& y! C" zcount=0;; x0 R" B5 W1 U: t. t7 V) O& x
    }
    $ ~- A% X: t; V0 Y. U5 c1 g. L0 Telse+ I. h' \6 e" y+ h* j) B: v
    {9 }4 z* P* O5 o+ S" q! l6 y% _
    if(FIFO(&FIFO_p,&FIFO_mmy,&FIFO_memory,FIFO_pri,0)==task_completed)
    8 U9 Y& H6 _4 g3 ~* [: z2 C; N{7 K+ o* k* T& i3 @" U% ]
    FIFO_pri = &((*FIFO_pri)->next);) [" x& G4 z; b9 G' ~! t) h
    // printf("hello");, z6 `) P, P# R9 R  s6 W1 U
    }- Y3 t& m0 b4 b) j9 C$ p- j! Q
    if(TimeTurning(&Timeturn_p,&Timeturn_mmy,&Timet_memory,Timet_pri,0)==task_completed)
    2 b9 h  V9 ~3 [! N{9 }/ X+ P1 j  B6 E, i
    Timet_pri = &((*Timet_pri)->next);
    2 e+ z- ]; P7 v8 z// printf("hello");* C, a5 a# o* c0 g  p
    }
    $ u2 Q+ {( f: e. z1 }, aif(ShortJobFirst(&SJF_p,&SJF_mmy,&SJF_memory,SJF_pri,0)==task_completed)9 `+ c: |8 m3 I. i8 ]+ `
    {
    " k7 [- Y0 X5 U5 x3 t   SJF_pri = &((*SJF_pri)->next);2 V  x0 @4 }  X- j9 @
    // printf("hello\n");* U' T4 [: p4 K, s+ c
    }
    1 X0 S9 S' `) f- X; H+ z0 o  n9 A7 mif(PriorityDispatch(&Priority_p,&Priority_mmy,&Priority_memory,Priority_pri,0)==task_completed)
    ! k7 g: \3 c9 a9 u; b: ~% ~6 d{0 Q2 r  |/ c  [# [$ a  Y" H) Y
    Priority_pri = &((*Priority_pri)->next);( }7 u# W+ c4 D2 N7 \
    //printf("hello\n");
    + r7 R3 p& H( t4 _1 \}
    $ k: D. }2 j% R( d1 rif(High_response_ratio_dispatch(&HR_p,&HR_mmy,&HR_memory,HR_pri,0)==task_completed)
    ( N' j- Z1 \7 [3 f4 a# w{" n4 R' F8 i. X6 S8 S5 `
    HR_pri = &((*HR_pri)->next);
    ; x1 r! D( H% q7 @& A  M5 n( E' d//printf("hello");7 T- x  G8 d9 h/ n, O4 z
    //Sleep(1000);
    $ v: W7 K3 y  B, L/ P5 h9 v}
    9 ?) G* h5 C( N0 acount++;
    ) o7 F4 d4 G6 X) ^}
    : @5 I+ x* E; M0 R* \. vif(systemClock==showTime)
    $ D! Z% G: _3 A, q; t  B{- Y. n/ m: W: V: V% k. K# Y
    /*PCI * p=FIFO_save_head;
    # k5 x% t1 X* X) X* iint i=0;
    0 |. O' j1 H$ d& b0 Tfor( ;p!=NULL;p=p->next)0 r0 e& K- _: x5 x8 M3 H9 S) q
    {
    ; B" G/ R. w  u- z& _printf("Id %d\n",p->processID);
    * |; M$ J1 I4 U* iprintf("comeingtime %d\n",p->comeingTime);
    * s) r  M% p- Dprintf("runningtime %d\n",p->runningTime);* D9 m8 y* I- e0 s1 G1 y+ W
    printf("asdmemory %d\n",p->askMemory);
    / L4 Y. q2 Y! R2 ~1 p6 U9 lprintf("completedtime %d\n",p->completedTime);( h9 c: C7 e; ~* D( J
    printf("compute %d\n",p->compute);
    5 u' p+ @; b% F/ l  _( K# Y8 t$ pprintf("exchange %d\n",p->exchange);
    $ R, o: E% T" m0 H8 {printf("waitio %d\n",p->waitio);
    , R# c* @0 i- I% E  f. Xi++;4 I2 m- `# M: X; u

    : A( k! n4 w! W+ u2 I* I; T0 f' W' c' A# f7 P0 T6 V* C
    }
    % J" H. I& F; z% N4 Nprintf("%d\n",i);*/
    0 h$ F- x3 M3 j1 r6 s! d9 Y# oif( (fp  = fopen( "data.txt", "a" )) == NULL )
    $ V1 y" Z4 x6 n! \1 y{
    : L" f6 L4 c2 p5 u- hprintf( "The file 'data.txt' was not opened\n" );
    ) P" y3 d) D2 `3 R9 W* T//return 1;( Y6 I/ O/ l$ \' y
    }
    6 J' |/ F% \/ q% U/ Lelse2 [2 Z3 [; L; r. ?6 ~0 p
    {
    - i  e  w( n( Q% _$ a& l2 a2 Zfprintf(fp,"FCFS \n");3 |* ?( O, o; i: o
    for(p=FIFO_save_head;p!=NULL;p=p->next)2 Q2 m0 U0 ^4 G' ^
    fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,4 ^+ N. A/ i/ k8 j  L
    p->exchange,p->waitio,p->runningTime);6 E! v" n1 \$ c
    fprintf(fp,"\nTime turn \n");  E* l4 G$ }& F/ ~) e
    for(p=Timet_save_head;p!=NULL;p=p->next)
    9 B" ~( d0 F; ]4 `fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,3 r$ U) O+ g" {" v3 K: L
    p->exchange,p->waitio,p->runningTime);4 z5 y( ?: u9 T
    fprintf(fp,"\nShort Job First \n");3 K  S* F' Z5 D: U  I
    for(p=SJF_save_head;p!=NULL;p=p->next)
    + v4 s: o/ d2 ^5 U% G1 Z1 ufprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,, f8 x5 q7 U7 C; _* X  Y$ i
    p->exchange,p->waitio,p->runningTime);
    4 M5 s+ s6 T" `  H6 r& z* u9 S5 jfprintf(fp,"\nPriority  \n");
    % S7 Y3 w0 i* C0 Rfor(p=Priority_save_head;p!=NULL;p=p->next)0 z' ~; ~% J, d2 ]* T
    fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    2 u" ?6 \. z/ h5 H3 c7 d) T+ g. V- [$ Kp->exchange,p->waitio,p->runningTime);
    , ]/ i3 o3 l+ @- U( [fprintf(fp,"\nHigh response \n");/ e5 Y: N1 w5 x7 A% j7 s7 S
    for(p=HR_save_head;p!=NULL;p=p->next)* N( o5 Y8 S) z: ?# ?3 Q
    fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    , [* @6 s$ H: J1 e4 d( f; vp->exchange,p->waitio,p->runningTime);
    2 P# |: j! a( nfclose(fp);  V$ `4 f. i0 ?/ U' T/ Y5 \5 \
    }/ |4 Q' ?2 H1 ^0 i/ [# K- W
    showRunningResult(FIFO_save_head,Timet_save_head,SJF_save_head,Priority_save_head,HR_save_head);
    5 y5 p6 ]8 B0 o% \MouseListening2(&flagDraw,&showTime);
    0 \& M2 ?1 {5 G9 {}) j' O7 C7 D/ _; @* f' d
    systemClock++;3 Q5 e: q2 T4 X6 ]% X# t0 `8 b
    if(flagDraw==0)  C  x. x# u! f: q' r! G. A+ b
      Sleep(10);
    # n- ]& Q9 y; Z/ c0 k* k}
    8 K$ Z! |* J7 q4 `# Y5 o7 P" h1 v8 r# _# `" @* r( o) x
    , _4 t% q( h. Y% ?% U8 Z
    }8 m* H$ M0 M# y7 s) w
    int showRunningResult(PCI* FIFO,PCI * timet,PCI * SJF,PCI* PR,PCI* HR)( U, M( G# Q0 k! g, w; w  [
    {
    6 z- r5 _+ c; u9 WPCI * p=NULL,* name[5];2 n4 L1 Y- s" g" a& B3 W  z! y
    int count=0,i=0;, d8 Z( k+ H4 W) g
    char ch[5][10]={"FCFS","timet","SJF","PR","HR"};
    - x1 l% v9 _2 {: r) h8 Z0 H% Mdouble turnover=0,wait=0,c=0,w=0,change=0,pos[4]={0,0,0,0};# \+ @9 P" g; n) L2 n
    struct info7 U; b: }* q5 |8 r, y* J! ^
    {
    9 u" q8 _3 u5 G8 M8 c9 c" Fchar name[10];6 X0 o3 `2 a* K6 K( I+ p
    double throughput,turnover,wait,CPU_rate;
      P1 S) u) G1 K* T! O( Q( R}inf[5];  z/ n$ D4 M1 z% F; W2 q7 l# b
    name[0]=FIFO,name[1]=timet,name[2]=SJF,name[3]=PR,name[4]=HR;
    8 P' A! x- _1 N: nprintf("调度算法..........A\n");0 p; }( J) U7 F( G
    printf("吞吐量............B\n");
    3 v1 a5 B$ Q1 u! y* ^1 @printf("平均周转时间......C\n");: g) R! Y5 ~$ ?: V  m# L6 I
    printf("等待时间..........D\n");
    ! h* B6 r6 _% c# I0 ?# D, ]- ]6 Xprintf("CPU利用率.........E\n");
    # f7 `9 ~4 i* K" G/ h1 y" ?printf("A\tB\tC\t\tD\t\tE\n");) @4 @+ a7 K: e4 h( ?4 x) ?: j5 g! S
    for(i=0;i<5;i++)' v8 ]5 w* [8 @- }$ w
    {" |; U9 F' k" h& j; [4 ^. r+ _4 D$ k
    count=0,turnover=0,wait=0,c=0,w=0,change=0;
    3 n6 d# s# d- Qfor(p=name; p!=NULL; p=p->next)4 i5 M* c0 {4 {! c9 ^
    {5 i' i6 ^+ P0 q- ~
    count++;
    ! P- {- D" u2 W3 Zturnover += p->completedTime - p->comeingTime;$ L2 @- `! ?9 j$ Y. i4 ?
    wait += p->runningTime - p->comeingTime;
    / [6 K7 o" z/ `7 Z- u" Pc += p->compute;
    + l* |1 @/ J$ nw += p->waitio;
    & ?$ t) Y, k% V/ \' {change += p->exchange;! n, B! {3 `1 L
    }# D+ A* o! h; u; G, I: U7 U7 o
    turnover = turnover/count;
    + u# i8 ]4 x2 jprintf("%s\t%d\t%.2f\t\t%.2f\t\t%.2f\n",ch,count,turnover,wait,c/(c+w+change));7 j- D4 D& ?* {$ E! N5 M
    strcpy(inf.name,ch);% F+ Z7 A. _2 {) z4 W7 U
    inf.throughput=count;2 ]) M4 \) o; a6 B. n
    inf.turnover=turnover;
    8 S- y2 E- X9 P. F; v! Vinf.wait=wait;
    ( W( t- Q+ i& Zinf.CPU_rate=c/(c+w+change);
    - g& l# w1 f9 p+ s/ g$ n* x}, P) W" k  T- U" h
    //画图! J( @0 d9 t7 _
    //cleardevice();3 O# u: U; _( R( \& s
    line(0,600,1200,600);+ ~% O% P2 j$ w+ @0 E
    line(10,600,10,200);, e& b. k; P4 Y6 o/ \  \
    line(10,200,5,205);
    7 M) E2 D# v) Zline(10,200,15,205);; @' U) D/ k9 G' A" G. ^
    line(310,600,310,200);
    . l8 q3 g9 q9 @+ |8 d6 q2 {line(310,200,305,205);
    6 l3 F# S, z! g2 }" ~9 c( _4 }% f* \line(310,200,315,205);
    8 j8 I% u' z) N' l# K- G9 @, Jline(610,600,610,200);5 X% J: z& k/ N8 w* [6 M' {
    line(610,200,605,205);
    1 w9 ^3 ~" F# K' R9 f8 S- ~line(610,200,615,205);9 Q. P5 q' G7 Q) ~5 K
    line(910,600,910,200);8 O% _8 a& f+ {0 [2 h
    line(910,200,905,205);8 y8 y' a+ H6 E6 T. X
    line(910,200,915,205);//最高的长度400,宽度均为40
    . p/ c1 @! g8 ~8 k5 L; K  S* ~9 Gfor(i=0;i<5;i++)( B7 Y9 C, x8 D
    {
    9 `8 b4 I; R7 K  k8 q- f1 W" N4 Nif(inf.throughput>pos[0])* i0 w+ u1 s: `6 ^/ g8 y
    pos[0]=inf.throughput;
    % M+ ?/ w1 n# w4 s2 g3 ^6 ]if(inf.turnover>pos[1])2 {- }" G$ ?, W! b
    pos[1]=inf.turnover;
    9 H3 W6 v+ {+ ]1 D5 Uif(inf.wait>pos[2])
      j7 w9 G9 ?& ppos[2]=inf.wait;
    9 b$ P6 u! J5 Z# e# h+ C  r* E9 ~if(inf.CPU_rate>pos[3])- ~2 P7 s1 X6 K) O5 i* i
    pos[3]=inf.CPU_rate;
    3 o! c# i& {4 {5 y}
    3 b+ S2 v' Y0 M( xsettextstyle(30, 15, _T("楷体"));% Q1 Q+ o9 _% w& _4 m
    for(i=0;i<5;i++)( q- e5 w- l0 F4 x/ ?2 {
    {8 o9 c; |& M9 w- {1 T: D  E
    switch (i)$ I5 _% @1 \, s7 r5 Y" c8 U! V2 B
    {& S4 c9 H2 K7 `; a1 E
    case 0:
    2 \, k; Y( t2 N; `" f7 L# H+ X1 p, csetfillcolor(BLUE);
    ! W  y* v. M* wfillrectangle(100,50,150,100);: \2 y  T- a- }/ I# i
    outtextxy(160,50,"FCFS");
    % P, e" X8 j* _* O' D+ s$ Vbreak;
    1 i& {9 M) D2 o( c  Z' r: Ncase 1:
    % S0 U8 }" c1 Vsetfillcolor(RED);) V9 m7 Q# W% `+ l) Q: O. [! e
    fillrectangle(250,50,300,100);8 T7 {! I6 ^7 x0 t! s5 x% ~. [1 d
    outtextxy(310,50,"timeTurn");" {( d" v# y/ U: U; F7 P9 F/ N
    break;
    % O' {4 a  e  ~& o  m9 `, a" hcase 2:
    ! S5 w( g. H7 N7 w" Nsetfillcolor(YELLOW);
    ! ]) o# K: N- I" Z) c% y. Jfillrectangle(450,50,500,100);
    1 g) _7 T4 k0 s4 touttextxy(510,50,"SJf");+ s. k* a$ I0 o9 `4 d
    break;
    & q3 i" P" F/ r5 ycase 3:7 C+ O" C* F1 m3 W& U2 a
    setfillcolor(BROWN);, u3 }% X* H% k
    fillrectangle(580,50,630,100);. j( U/ M& i5 H9 A+ b( e7 M
    outtextxy(640,50,"PR");
      i# o1 m+ M! r4 S" q/ `$ H4 \* vbreak;3 s5 n: R9 y$ r: \
    case 4:+ V$ v- @- w# B
    setfillcolor(GREEN);
    ! z0 I: w* P' e+ Q8 ~fillrectangle(690,50,740,100);
    , l' o4 J, J6 {% @1 D/ |) d7 Jouttextxy(750,50,"HR");9 F) H8 M4 s1 J9 |* ^5 C
    break;+ r1 e- b# ?+ L5 L( p
    }9 M$ Z5 k7 g; _& R
    fillrectangle(50+i*40,600-(int)(inf.throughput*400/pos[0]),90+i*40,600);% A# B3 d* S+ m! o7 v
    fillrectangle(350+i*40,600-(int)(inf.turnover*400/pos[1]),390+i*40,600);
    + u& u! H$ l& G9 k% kfillrectangle(650+i*40,600-(int)(inf.wait*400/pos[2]),690+i*40,600);
    % h2 o- z: D$ @fillrectangle(950+i*40,600-(int)(inf.CPU_rate*400/pos[3]),990+i*40,600);, T. [: [$ o% r% `* _( g
    2 w+ {: Y7 k. g+ p6 U
    : P$ d9 Q* J+ w6 g1 j
    }6 W1 ]" }4 N- P
        outtextxy(100,150,"吞吐量");% G( z% G; r: s6 t5 E$ g
    outtextxy(350,150,"平均周转时间");' c+ [. ^& B/ Z% @- O8 Y( `3 B
    outtextxy(650,150,"平均等待时间");; p9 F% Z% E; B! E$ W
    outtextxy(950,150,"CPU利用率");
    & p( h% f& B' V" G* I# |9 preturn 0;+ L- w$ J" @# I. x6 z
    }
    , C/ M* U# U6 j1 Eint MouseListening()' N5 r& [7 f. x  _# V' A  V" k0 p
    {0 T; Q# z* S0 u5 H) F0 k/ [
    MOUSEMSG p;8 \2 z+ F* a0 p1 @8 ]$ z
    if(MouseHit())
    0 A6 ^+ o. _5 y" z" d{( f" h# [4 ]/ ^5 A0 j
    p=GetMouseMsg();# Z  `/ ?+ l3 e, a- P
    if(p.mkLButton==true)0 `0 x6 n; E0 `  q: {: P# j
    {
    . q5 `# c, d, R+ ?+ bif(p.x>0 && p.y>0 && p.x<400 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)
    ; n8 ?" b! V3 f+ yFLAG_FIFO = 1;
    - w- }2 e+ s7 Pelse if(p.x>400 && p.y>0 && p.x<800 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)' p( s5 U' P4 F( ~0 A: d
    FLAG_TT = 1;' c8 x9 Z' o6 G) z& O
    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)5 n) C' e" ]& H, c5 p
    FLAG_PF = 1;# a& |- M' A4 z
    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)) M- U* X* V; L
    FLAG_SJF = 1;+ t: J9 a7 x- Y
    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)& U+ {: ~0 J; e% W- K6 N7 R+ M% H# `) d
    FLAG_HR=1;
    1 W, A: Y- F% I1 {( e, `else if(FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO >0)4 p) F& k& Y$ y  P. e0 F) T
    {
    9 N6 M$ x4 }. M9 A" |( K0 ~/ K6 @FLAG_HR=FLAG_SJF=FLAG_PF=FLAG_TT=FLAG_FIFO=0;
    9 _' l7 ^0 ~4 K" [" |9 fclearrectangle(800,325,1200,650);' A! Y2 ?1 m# Y" o4 I' ~0 L! c
    }* ~. J- R" F/ ]# ]* Z
    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 )
    , K6 a- I; o+ E: c/ i{: K3 |$ g5 S$ W) M3 i& H
    FLAG_show=0;
    / x( N6 h* t- ?/ K& ncleardevice();
    ! `* f3 {* S# L) n  @$ p& Preturn 1;% _% J; ~6 O' R9 _9 M
    }
    ( M7 I6 |1 v; q8 j) P}# J8 P* S3 H+ V- {& N: R
    }3 |  P' D; ?3 V: h- Z( m) a
    return 0;
    ! h" u$ J6 n% B0 G- {2 o3 ]; G}
    + C/ P2 E( q7 ^, {7 q! Z# Yint MouseListening2(int *flagShow,int * showTime)
    . _/ S% B5 Y# g) d' z. F9 S{: C/ |& L6 G) R' s, l
    MOUSEMSG p;
    - c/ N# \; {( ]" u! h5 d/ x1 J* prectangle(1150,0,1200,50);7 ~/ ^+ d' l6 z: V
    outtextxy(1160,10,"X");
    2 x8 R( @. I6 k$ s/ v& y7 D8 wwhile(1)6 q# S& z. \5 N0 }/ E2 K9 q
    {
    $ B( [9 G8 L) @& V  M' Uif(MouseHit())" F5 q) `/ j& j5 a4 ~" P# C3 h, y
    {
    + C- n% q! ~* S9 Zp=GetMouseMsg();
    2 A6 x- K) L% F0 \0 `2 rif(p.mkLButton==true)6 ~- f/ c  I8 f5 n
    {; s2 v5 I3 k( m% |) \% @( u
    if(p.x>1150 && p.y>0 && p.x<1200 && p.y<50 )
    # h2 ~- @4 s" E{- ]& v- V5 Z1 b" I9 ~9 G; c4 }+ {
    (*flagShow) = 0;
    - F  R2 n, s  b2 L4 o- Z4 W2 n$ Y(*showTime) += (*showTime);8 ]9 r+ m1 ]: M; @# T6 s* H& P5 Z
    FLAG_show=1;6 C/ m4 h  p  _
    break;
    . j6 F4 a  \3 C3 q- p# Z& Y}, f# e" \0 [$ W+ A/ n& ~
    ! C# V, |5 G# S! V; ?' ?# Y" [
    }
    6 v$ Z' G: Z! j( N- q* H9 U}6 F% X, X+ l+ }4 }
    Sleep(20);' G, p3 f, d! e  ]4 d( V* Y) [5 K
    }% ^0 L( C% k# B& M- e1 a/ i7 K
    cleardevice();
    ' t  H) W8 q# m/ y; ^return 0;
    2 @8 k* z# J4 t+ D4 q7 R}# y& X" U0 o- b9 H0 ?0 Y* {
    int drawPerformance_FIFO(int x,int y,int memorry,int com,int wai,int cha)% k  ~$ ~2 Z5 m/ A3 ?7 j
    {
    9 z0 d( Y& S/ P' O- p# nstatic int info[11][3],num=0;
    ( y  x: V8 w* `" ~, Q: _int i=0,j=0,pos[10][3][2];
    : a5 {: e. K( N: q% D6 @$ Wfloat temp,t;. h3 ~% P" h, p: l
    //画按钮,不属于FIFO图的范围
    / o. B1 W  W* x, T5 f4 L: pif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0 && FLAG_show==1)
    0 ]. n) |  z& A+ ?5 J5 R{: P( ^% J; W4 {4 r0 t
    settextstyle(30, 15, _T("楷体"));; e) V" Z3 ^! M4 V
    rectangle(890,455,1110,510);
    # [, u% J9 i  d& P+ A4 }* brectangle(900,465,1100,500);% x( N* @: Y1 e! U/ m6 A
    outtextxy(910,468,"查看运行结果");- Y0 B; N, y& l+ }# @0 I% ~* P
    }* o; ~  D: \' C* i) q7 @
    //结束画按钮' N- {% X6 O7 |3 n+ J8 S) W0 Q
    info[num][0] = com;
    / L, d1 w6 z4 O: Y: U6 ainfo[num][1] = wai;! B& i7 @( G2 U7 B6 ?/ B
    info[num++][2] = cha;, o( ~" ?0 r% w
    if(num>10)  //存储10个点
    " C8 T1 c9 ^! b. X: {{' n$ p4 i8 y6 q7 c- g9 ^6 [) U
    for(i=0 ;i<10;i++)
    + f. |! P: R, I  R2 q! T* A{
    * @1 w/ U+ U- B7 U1 `; w, einfo[0] = info[i+1][0];0 @+ c) e' i" D1 R. Z4 u  |: E0 v
    info[1] = info[i+1][1];
    5 {+ @3 ^) M8 `/ j& f, H& U# ~* k) Dinfo[2] = info[i+1][2];9 I" I6 j8 }6 R/ _* `
    }
    , I' t8 C9 c# s: d3 t# V* \4 o/ \num--;
    ! q" W, [+ U/ _! Z  `+ P2 \}
    5 \3 G6 h5 i0 Q% `if(FLAG_show==0)
    ; t, H* s4 s1 c' `4 sreturn 0;& w$ k5 e7 z' D& C5 |+ C
    for(i=0; i<num; i++)# n1 m; K, Z, L% @5 F: _: B
    {
    % l0 g, D+ W) w: _3 Gt = (float)info[0];
    9 @+ _0 J9 v1 c/ x! `temp = (t/101)*90;  D# v0 N3 E. Z+ b- k) E: ]
    pos[0][0] = (10-num+i)*25+x+100;( b# b" F' m. l4 k) g5 H2 S0 h$ Z
    pos[0][1] = y+110-(int)temp;$ Q3 Z4 A+ `* I5 F3 I
    t = (float)info[1];" i- K% c3 \* C$ @0 A
    temp = (t/101)*90;
    . Q1 Y0 P9 I! \: x9 Kpos[1][0] = (10-num+i)*25+x+100;- Z' ]6 L, o5 c9 U4 W
    pos[1][1] = y+210-(int)temp;" ^* z* F4 `6 ?/ j
    t = (float)info[2];
    9 J% P* r  X, |8 stemp = (t/101)*90;
    : ~/ V! T+ Z- |. \7 r9 O& }pos[2][0] = (10-num+i)*25+x+100;
    - o! j: i1 I: Spos[2][1] = y+310-(int)temp;
    ! S# ]! m1 u8 X3 k# X5 D! u& f" X}- x8 l: j" y: W/ x9 c2 c" F
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
    ( U+ D9 z2 E0 H& u0 G- {  X& I# U{
    ( I7 Z1 @( R% |clearrectangle(x,y,x+400,y+315);
    + M3 O5 o* a; x6 }settextstyle(20, 10, _T("楷体"));/ ^9 Z/ V9 _8 @4 _/ C# x2 [
    rectangle(x,y,x+400,y+325);
    ( U  o. z( q: Pouttextxy(x+40,y+10,"CPU");       //画柱状图
    % @8 N( N; }' t6 b3 R* _outtextxy(x+45,y+10+100,"IO");% Z! Z) i( g- W0 ^: R! Q  Z+ p
    outtextxy(x+40-15,y+10+200,"change");
    * a+ ~: }9 u: h7 g. Z1 drectangle(x+35,y+30,x+75,y+110);
    ' d% u4 \, i. @4 nrectangle(x+35,y+130,x+75,y+210);
    ; ^1 I7 z/ O+ z" m5 z$ Arectangle(x+35,y+230,x+75,y+310);. ?# B1 p2 _  k: m  c7 w8 g, d: F$ G
    outtextxy(x+180,y+310,"FCFS");# l$ g3 M& f: p- A; d
    t = (float)com;6 w  r+ `* M' z( o3 t
    temp=(t/101)*80;! t/ A& U" E( @/ V2 b4 }
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);( \; P! P" r- `" A
    t = (float)wai;
    ' |. r4 E6 t; X! t1 s% z5 k& Wtemp=(t/101)*80;4 f0 P2 m1 ]. C; Y
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    4 l; |1 x9 J2 w# n& wt = (float)cha;
    ! r/ P3 m; [: B" ~9 w8 vtemp=(t/101)*80;" D6 r! T5 @0 \# z6 I0 X" |) Z# c
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    ' c' R. ]3 a! z& u( M) P; z" g  lfor(i=0; i<3; i++)   //画坐标   high=90,length=250- r9 ~1 ]6 P& n9 L* v
    {
    - C/ z7 N# s/ k. Xline(x+100,y+110+100*i,x+350,y+110+100*i);% `+ s4 E- B1 B: }& }0 M
    line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);
    , X: {6 s- p% I& h# Wline(x+350,y+110+100*i,x+350-5,y+110+5+100*i);* J9 N# U. n7 z  I. E! N
    & a% t+ D5 G$ K" z
    line(x+100,y+110+100*i,x+100,y+20+100*i);$ k: ^$ T7 ]  u: k6 Z
    line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);# z6 r5 k: Z* e
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
    # J8 s4 I# C6 Z+ u1 }( Ffor(j=0;j<num-1;j++)
    * @+ I" Q* F4 s$ Y4 w{4 {! o/ d# B6 t
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    ' t" e1 a- B! F3 D) `% Pline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    $ [4 s3 V0 ^/ ^( }line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    * e- {3 ?* L( O5 [& y5 e. `}0 T. p5 [, L: J8 j
    }  D9 r& W2 x: I; U3 r
    }! V( @2 [6 P5 a  M4 L
    else if(FLAG_FIFO==1)  i1 K7 f$ A# }, u. S) `' n
    {
    8 ]/ G9 n) }! j6 R6 @x=0,y=0;
    ; ~) Q* t0 h' ]# S2 Jfor(i=0; i<num; i++)
    / w# S+ W0 k: M' ~{
    7 L6 R4 E0 I- ~  St = (float)info[0];
    ( X  m  V8 T( r# _3 G( C/ a$ Stemp = (t/101)*180;" Z: V% @8 A' U: l2 V0 B! Q
    pos[0][0] = (10-num+i)*50+x+650;, U8 }3 B* p+ d) c/ E
    pos[0][1] = y+210-(int)temp;0 {: O( U6 w  Y3 m
    t = (float)info[1];% S/ n/ h9 \. p# u% u) h
    temp = (t/101)*180;5 j5 r7 J) W$ w5 _' \+ y
    pos[1][0] = (10-num+i)*50+x+650;
    - m$ G. V* d, ~6 _8 ppos[1][1] = y+420-(int)temp;
    5 E+ j. J1 T' lt = (float)info[2];
    ; T2 K3 J) N+ otemp = (float)(t/101)*180;1 y8 n" m: F9 q2 u3 H  i! l% P
    pos[2][0] = (10-num+i)*50+x+650;
    4 O8 }8 e2 ^$ ~pos[2][1] = y+630-(int)temp;3 U8 Q9 T9 C1 ~' C3 U% H
    }9 \" c, a4 \  C, U
    clearrectangle(x,y,x+1200,y+650);
    1 W: t# G; m) n! r  ~: B5 T3 Dsettextstyle(40, 20, _T("楷体"));/ S) n9 ?- }0 F, O
    outtextxy(x+50,y+50,"FCFS");' p, ~% \/ O/ f  O, U4 Z% c' a
    outtextxy(x+280,y+20,"CPU");       //画柱状图
    0 B7 E0 |  {1 f% s0 fouttextxy(x+285,y+20+200,"IO");& [' ?5 m" r$ v" p4 ]
    outtextxy(x+250,y+20+400,"change");
    & a7 h8 ~- N9 s2 Yrectangle(x+270,y+65,x+330,y+215);
    3 q8 V* h" h/ C) |rectangle(x+270,y+265,x+330,y+415);
    4 r* i) \) a3 L( u( Orectangle(x+270,y+465,x+330,y+615);6 C4 ~9 \# j8 c! b9 u8 d6 ^( R
    outtextxy(x+290,y+620,"TT");: I9 c1 h5 [& v9 r! N2 |
    t = (float)com;
    5 T1 O7 c% T+ h8 s2 ^temp=(t/101)*150;! Y+ o3 _' M0 O. Q
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);
    & M/ q) E  @3 t2 }: p# ct = (float)wai;! Q# Y) V8 f$ i! p! ]% t* i( h
    temp=(t/101)*150;
    0 ~5 f. K; ^: _0 o8 V0 b9 Z8 A# H  kfillrectangle(x+270,y+415-(int)temp,x+330,y+415);
    ; I3 }; S* _& S. F( f! \t = (float)cha;
    . \% Y7 X- r9 ~8 }7 [4 I4 stemp=(t/101)*150;
    % m! V( W8 f/ i0 v$ R2 v0 Gfillrectangle(x+270,y+615-(int)temp,x+330,y+615);( P1 o* D7 C1 v5 n. y+ m
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    ; ~$ s' ~3 v. O. A) }{7 ?) {+ {8 h% y8 C0 s0 b2 Y- |0 H' q
    line(x+650,y+210+210*i,x+1150,y+210+210*i);
    " B1 K( A. {$ R" o4 |9 V, i8 uline(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);  {# }; P! Z  X% l
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);9 C' o& G! @' B' v

    7 P5 b" a- p! e, [5 ~3 s9 p& sline(x+650,y+210+210*i,x+650,y+20+210*i);
    1 X" d" c; u: T, T9 c8 [0 b1 @& Jline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);( F/ S$ O/ m% W) L) Y
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);* R5 b" l: l$ `1 N
    for(j=0;j<num-1;j++)
    * k  N0 t# X5 D2 q. I3 ?{
    8 h2 j( F3 @, D7 h% r* p) c) u0 [% wline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);; {0 G, ^! `% p% W* N
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    3 W+ B  ]7 I+ q2 aline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); + l* f! N( {6 m( k9 Z
    }9 F1 ^5 s) x5 E3 b5 S
    }4 b& d" E  q: \2 B, P$ p
    }
    3 L! a( R  P* `' B+ ^0 y- Q' T, J8 w4 M* l
    . }9 y( r' R; j% S
    return 0;
    9 D7 M3 H- N' L+ q}- z2 q/ C" E4 k
    int drawPerformance_HR(int x,int y,int memorry,int com,int wai,int cha)2 P4 Y8 Y" ^, o4 L0 J
    {1 V( o, U6 ]) R
    static int info[11][3],num=0;' \4 k/ n# I. X" X; b
    int i=0,j=0,pos[10][3][2];
    1 P2 X# F) @; j1 e5 C% I) w" [  s% hfloat temp,t;
    % Y% q. x+ ^5 C8 k" G* x! b9 Cinfo[num][0] = com;- a- }2 A( A& A% |6 A2 g
    info[num][1] = wai;4 a2 N/ O1 c% s* C( S+ c! P
    info[num++][2] = cha;4 Z$ k% n5 {( B, u* x
    if(num>10)  //存储10个点; f' C9 R5 |$ k/ B! j- z
    {: l# \# I: Y4 @  [8 g$ i
    for(i=0 ;i<10;i++)& M! k0 K2 _' @6 W5 {/ y6 K
    {
    9 p7 R% m, o  k, w5 Dinfo[0] = info[i+1][0];9 ^' G7 b% z4 I/ B6 W" h6 J; }6 c- q
    info[1] = info[i+1][1];" H% A8 T! P  U' j( |
    info[2] = info[i+1][2];
    & Y* p5 y. Q2 k4 {}% w. Q% n  M& O5 j8 Z3 G5 N
    num--;
    & |0 L7 [& X7 ?* p0 z5 }: h}+ O: ?) b+ B8 j" }5 \; S2 m1 d
    if(FLAG_show==0)
    0 V  B$ g1 `; s( `1 Rreturn 0;* _% m0 W3 O4 Z' P  ?* L
    for(i=0; i<num; i++)8 ^- a0 D2 i+ D  c0 i9 y, S
    {
    0 h2 c1 p; T( Z9 B: p& _/ mt = (float)info[0];
    8 @8 n6 C/ \) |3 L7 ttemp = (t/101)*90;
    / g8 z  c2 z# {! d6 spos[0][0] = (10-num+i)*25+x+100;) H* z& d- ^) ~2 h8 n
    pos[0][1] = y+110-(int)temp;1 O$ M0 T9 R" _* k* j
    t = (float)info[1];
    9 M4 p/ a  O) G, Utemp = (t/101)*90;
    ' O9 h  q0 |2 npos[1][0] = (10-num+i)*25+x+100;" F+ P2 ?* e" m1 P
    pos[1][1] = y+210-(int)temp;
    . S7 S! `2 G% a) k" x7 H; g4 Jt = (float)info[2];
    4 Y4 h: F) O1 m/ e! j0 v7 }7 x: J, [temp = (float)(t/101)*90;& b# e# ~( b& [3 u0 ^6 {
    pos[2][0] = (10-num+i)*25+x+100;
    9 ~, T8 T7 r( F0 l" y, M! ]5 a- s5 {$ q1 ]pos[2][1] = y+310-(int)temp;8 x9 f% x3 T4 B: v0 q  A& C
    }" h3 f; R6 z% H6 B, y" C
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
    & a* d; P! g  G7 ?$ x" z{
    ; _" f$ X+ `- |& Uclearrectangle(x,y,x+400,y+315);
    3 q' y! I, K# a5 Jsettextstyle(20, 10, _T("楷体"));
    % L$ T8 C" B2 @, j, nrectangle(x,y,x+400,y+325);. Q$ j1 Q: j% c
    outtextxy(x+40,y+10,"CPU");       //画柱状图
    # o, B' I6 x4 K: ?1 s5 douttextxy(x+45,y+10+100,"IO");
    / Z2 Z: e( E) N2 a& Louttextxy(x+40-15,y+10+200,"change");
    % ^0 q- r/ L3 J2 Srectangle(x+35,y+30,x+75,y+110);2 L8 V! L) _) x" p) b5 x- T
    rectangle(x+35,y+130,x+75,y+210);
    & f* V/ K* b/ F) m' qrectangle(x+35,y+230,x+75,y+310);' j: C/ b9 A' g( R! m
    outtextxy(x+180,y+310,"HR");
    4 B4 D( u7 ?+ \t = (float)com;
      G, w" X7 C9 f6 k. @% v/ Xtemp=(t/101)*80;
      D; G" I2 f7 o2 sfillrectangle(x+35,y+110-(int)temp,x+75,y+110);; d* A- f1 Y% Y, w
    t = (float)wai;" c0 H6 V& p/ l6 Q" |
    temp=(t/101)*80;
    - |8 w7 ^' ?0 z+ ?fillrectangle(x+35,y+210-(int)temp,x+75,y+210);/ v" Y5 G* [# p
    t = (float)cha;
    6 C, a" ^" |5 V) l, ztemp=(t/101)*80;/ |( ?1 L; ]  g! W8 Z
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    - L% r4 R* }; a& yfor(i=0; i<3; i++)   //画坐标   high=90,length=2503 H4 J' K. C9 K: A" q  C9 O& r) B
    {; h# f7 b/ f' W6 m
    line(x+100,y+110+100*i,x+350,y+110+100*i);
    * q9 ]8 I2 M5 nline(x+350,y+110+100*i,x+350-5,y+110-5+100*i);
    9 X; F& u: m+ R. \# f9 Fline(x+350,y+110+100*i,x+350-5,y+110+5+100*i);
    6 l6 Y3 F0 r0 t( \# Q9 |0 i: ]$ J( D; s5 f4 Q: V, v
    line(x+100,y+110+100*i,x+100,y+20+100*i);0 {1 i0 [- Q6 l
    line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);
    ) m, y9 _% ~+ y- w6 B. d+ I( t/ y$ Aline(x+100,y+20+100*i,x+100+5,y+20+5+100*i);6 ]% i6 f- C1 a/ Y; B4 u" v' U0 O
    for(j=0;j<num-1;j++)7 A2 D) U+ o7 [9 N& i, z
    {
    ! F  ~$ q" E* N$ d4 }line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    # \3 ~8 }( z* @. _! \; Y- E$ ]/ @6 {. Pline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);( O- d+ m2 A9 \/ E" E
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    3 E2 C/ Y* V! z/ G$ U}
    . w0 \4 o1 ?, ?% J' C% x' z9 o}
    6 ?7 O/ H5 c! S}
    + m3 V0 |* f0 `% E1 r8 ~( A/ yelse if(FLAG_HR==1)
    9 H" \9 j4 X" x" [! l{
    ! g; b. j; z, l' j7 Ux=0,y=0;
    ! ?0 C" r8 O9 u6 yfor(i=0; i<num; i++)
    ! G. H- Z; l* B8 J{! H/ R* d4 T& g3 X$ L
    t = (float)info[0];
    ' E- J' ~6 ?3 h! I3 Btemp = (t/101)*180;- G/ E3 A# |" ~) p: |6 _9 c
    pos[0][0] = (10-num+i)*50+x+650;: Z/ C- s; U8 ~4 ?( F
    pos[0][1] = y+210-(int)temp;" n$ ?2 ~- }3 g
    t = (float)info[1];
    4 N- ]  w  @" Q% H8 ?" l$ otemp = (t/101)*180;, z- d( T: C+ F, Z& g3 f% H
    pos[1][0] = (10-num+i)*50+x+650;9 v( p  s* {' X/ l
    pos[1][1] = y+420-(int)temp;1 A9 ]& l/ j* p( c* X& D2 \* s: h
    t = (float)info[2];5 J3 j9 s4 R8 |# f2 i8 x$ a3 \
    temp = (float)(t/101)*180;
    ' f3 s: L  f6 c" h9 r; Epos[2][0] = (10-num+i)*50+x+650;4 d8 Z: h: F- \
    pos[2][1] = y+630-(int)temp;3 H% W7 k" H! X9 }( S- w7 a. J
    }
    , W+ [4 ~$ j7 V8 F5 qclearrectangle(x,y,x+1200,y+650);$ c4 G7 H5 F7 J' v" K. B
    settextstyle(40, 20, _T("楷体"));, ?  H! [5 C" S3 |/ C; B, V
    outtextxy(x+50,y+50,"HR");5 }, T8 b% w2 b. E9 B
    outtextxy(x+280,y+20,"CPU");       //画柱状图
    # ]. ^# }) _( A; c( B1 zouttextxy(x+285,y+20+200,"IO");
    : {! L- z* R: x! j5 Zouttextxy(x+250,y+20+400,"change");% G5 S; J2 U5 _0 c1 u
    rectangle(x+270,y+65,x+330,y+215);) ~- |! ?" ~$ \7 n6 H$ M' r% C
    rectangle(x+270,y+265,x+330,y+415);: T& `' w7 I+ ?
    rectangle(x+270,y+465,x+330,y+615);
    + F) V& `* L( x0 L3 _$ R% }outtextxy(x+290,y+620,"TT");
    8 i& i# d7 }! p( Z. Yt = (float)com;
    ) s8 F  o* y/ j8 gtemp=(t/101)*150;
    & u) P7 E" a$ ~$ |* ^& r9 gfillrectangle(x+270,y+215-(int)temp,x+330,y+215);
    0 {$ A/ a4 }. x2 O: P) D8 h1 w3 st = (float)wai;+ H- g/ v) U. ?7 N. w# w
    temp=(t/101)*150;
    # k0 b! ]& C) p& ]1 Ofillrectangle(x+270,y+415-(int)temp,x+330,y+415);
    # R+ r5 f: `9 P- `t = (float)cha;
    7 H. i( n" h! k7 v) Y/ ftemp=(t/101)*150;3 h1 M" }+ S- [5 W' H7 d5 W
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);2 I0 W5 r. d. W
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    ) C8 M9 U% r6 o( e. _9 r{: q  _/ |  f  Y% R2 A* Q# v' v
    line(x+650,y+210+210*i,x+1150,y+210+210*i);. G6 I2 ]$ I  w% [
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);0 _4 \1 V3 e! ^+ B9 n1 T+ B& }( v
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);
    * a% l/ i' D7 O, Z) C8 G! U$ |, y$ }$ M! r
    3 W' I# F' n: y/ {line(x+650,y+210+210*i,x+650,y+20+210*i);; K' [2 K& P  K/ ~+ l1 f
    line(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
    6 }0 O, U1 e) P, h. E4 _% q& O) zline(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    8 y4 E8 v$ J* d3 R/ dfor(j=0;j<num-1;j++)
    / A2 |: S1 E# `8 I' }{" j% u6 R# U1 v, R
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);" d! \. C- J' E9 b9 t9 C
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);( |: ]$ a- O3 N/ J
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); % l+ v  v! Y# O+ W( s
    }" f: w% G+ I, J6 h+ U0 Y
    }
    & T- b/ \- S4 m}. `8 ~1 n9 ]9 I
    # |! ~- e2 e* T

    6 f& D$ _. w# J% Jreturn 0;
    / }: x9 c1 W. D+ F1 l$ H}
      G% G/ x0 q. Xint drawPerformance_TT(int x,int y,int memorry,int com,int wai,int cha)" L# D6 f% i, I" A1 P, D
    {+ T& B3 Q$ ]$ J
    static int info[11][3],num=0;, U* n% M, ~3 L' v2 {; K) M
    int i=0,j=0,pos[10][3][2];
    . h9 T& N4 B; H8 ~2 x3 i% k9 J: ffloat temp,t;
    ' ], r8 f" t0 v% v" J& F! Y% z; ?info[num][0] = com;
    9 ~* a# H* I/ q) X0 s: cinfo[num][1] = wai;
    ( i' ^3 W# s. t3 B0 x0 X; H% |/ u+ S" kinfo[num++][2] = cha;8 Y  H0 x5 M# B2 U0 U
    if(num>10)  //存储10个点
    $ q' W- v* \6 w{, E6 ^& v! c% V" j1 s
    for(i=0 ;i<10;i++)6 ?; y8 Q$ R. |( ~
    {+ C& h0 `1 ^) H8 N
    info[0] = info[i+1][0];
    - e! ]% _2 q+ Hinfo[1] = info[i+1][1];
    ! H' q* ]# k: H* n( h! z: Kinfo[2] = info[i+1][2];
    / K7 V, M; \0 u+ W}
    ( ~5 E* A  [2 rnum--;
    ) V7 F# A$ I' j8 V# i  I) M# J}
    ; Z0 M( _9 F2 s" ^9 O) Oif(FLAG_show==0)
    / K6 K( g6 ]$ Q" o* R- r1 {return 0;
    6 S4 ?0 L+ d: y$ k7 gfor(i=0; i<num; i++)3 L9 r+ I( l9 v  i' f7 n
    {+ E, e0 }/ K$ x! B8 g
    t = (float)info[0];
    $ v& Z2 Z1 ~# }temp = (t/101)*90;2 _9 _9 c! Y, }8 a3 v  \0 x$ Z# \
    pos[0][0] = (10-num+i)*25+x+100;
    9 R% p4 I( q) ]+ o; Npos[0][1] = y+110-(int)temp;
    # l/ ?3 r0 s" wt = (float)info[1];
    5 R# y) t% b: s1 R5 itemp = (t/101)*90;
    ; I& T+ W  m: B& T# Fpos[1][0] = (10-num+i)*25+x+100;
    . \. D, }7 m- {% t6 V: @pos[1][1] = y+210-(int)temp;
    : {- F! F- j% yt = (float)info[2];
    % t8 J; F( @6 ~# U. n2 g. R% ?temp = (float)(t/101)*90;/ i& @$ p) Z' }6 E. E& o
    pos[2][0] = (10-num+i)*25+x+100;- U4 y0 Y% c7 S  M$ c8 Y( }
    pos[2][1] = y+310-(int)temp;
    / G* P5 m; O+ b0 M6 {7 y9 n0 Y% J}& [9 q8 w3 U# G0 X- b* r* b7 Z
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)( `0 C% b% f& o* A# x* T' ]4 B
    {. k' f) p' @- t; h
    clearrectangle(x,y,x+400,y+315);" C% g5 P! Z" [3 W4 o
    settextstyle(20, 10, _T("楷体"));0 [: e, Z1 S. K) Y5 K
    rectangle(x,y,x+400,y+325);  a) n% |& c; A0 V
    outtextxy(x+40,y+10,"CPU");       //画柱状图
    $ r) b; z8 g7 q2 Gouttextxy(x+45,y+10+100,"IO");# w0 e! G# X- t5 K) [5 |1 W" b% h
    outtextxy(x+40-15,y+10+200,"change");, o8 C- d. R! u6 E
    rectangle(x+35,y+30,x+75,y+110);
    / H& t; Q, ~$ p& Orectangle(x+35,y+130,x+75,y+210);7 q$ q( Z7 U/ o+ d  j- J! {' C
    rectangle(x+35,y+230,x+75,y+310);
    $ K1 X  @8 l5 Oouttextxy(x+180,y+310,"TT");
    ; p3 Y* l& i- N9 k0 d9 }5 z* T1 A& zt = (float)com;
    ; z2 k- x9 _7 Etemp=(t/101)*80;, ~$ L8 Q5 J8 ^& ~% i6 d! l' u
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);, f- d9 g+ s3 f0 N7 T5 o
    t = (float)wai;
    ' j3 c& r0 ]  l; a. jtemp=(t/101)*80;' l5 g& O1 Q" H/ O0 K* |
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    % B8 d" ~8 q  I0 l1 Yt = (float)cha;4 A( ^) D; G* I2 M/ {* a
    temp=(t/101)*80;
    * ~* ]1 w0 p  Y( N0 q3 ^fillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    ' @0 f) M( ~# K! j, _! _for(i=0; i<3; i++)   //画坐标   high=90,length=250
    " K. x7 Q: l4 [{# E$ [+ F3 S, s. k
    line(x+100,y+110+100*i,x+350,y+110+100*i);
    ( I" o) r* V( j$ z* @/ G# s! tline(x+350,y+110+100*i,x+350-5,y+110-5+100*i);5 ]8 Z4 Y9 W- k
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);
    + V) H7 x3 ]; y: ?7 j1 m1 o  W5 W' a! I8 J- C) `1 {. C+ w: f: p  f
    line(x+100,y+110+100*i,x+100,y+20+100*i);% p! q8 k* [$ V
    line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);
    ' ], L3 T$ M' c8 W. [6 }line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);* h) y' o1 s* A' y* a
    for(j=0;j<num-1;j++)
    1 i4 K+ A3 v+ U4 n{
    9 [7 a! Q& C/ C4 ?" R' jline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    ; |; r5 c' Z9 [; V, g; o9 |line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);0 Y& {+ \( r  }8 E
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); # n. |0 d: z5 U' M; p, M5 n
    }
    3 e& x: b, p  y7 @- @8 `. k8 H' V2 F}" a0 G  ^8 B( k  V  Q! D6 N! b
    }
    / x8 n1 I1 m3 F3 W! q8 @. Velse if(FLAG_TT==1)
    3 O) H8 B: \; k& b! I1 j* v; @* n7 z{) ~; {  o) S* R: @
    x=0,y=0;  R# {7 B2 [1 b' z) r
    for(i=0; i<num; i++)
    7 j$ q- |* \+ m{
    4 g" L5 Y7 L8 gt = (float)info[0];
    ' ]; s% W4 [  w8 o$ U  ptemp = (t/101)*180;
    : J) r) G2 k0 a9 a* b. H) M0 |: Xpos[0][0] = (10-num+i)*50+x+650;7 L0 s+ s) N+ P
    pos[0][1] = y+210-(int)temp;1 ~5 E- B$ I  a. x' }
    t = (float)info[1];
    6 ~- t" E) H% ?temp = (t/101)*180;" V) U" Z: U( ]$ N8 |5 ~' Q
    pos[1][0] = (10-num+i)*50+x+650;
    3 |1 d6 |. T( A1 X2 kpos[1][1] = y+420-(int)temp;9 i, f' @* D3 D2 M
    t = (float)info[2];
    , M  g0 G* E* U4 \' K# O' {$ [1 stemp = (float)(t/101)*180;2 P# ^- c7 P* F9 g% _, f$ {
    pos[2][0] = (10-num+i)*50+x+650;8 r& a9 I8 F8 h& k/ }
    pos[2][1] = y+630-(int)temp;( v# `! L: z& l+ v6 l
    }' a: N+ W- Q! H: S6 ?8 x8 {9 Y' s$ `
    clearrectangle(x,y,x+1200,y+650);5 T4 {2 _% G! B
    settextstyle(40, 20, _T("楷体"));5 B  M3 |- s- j% p) G! O
    outtextxy(x+50,y+50,"TT");
    0 _3 f% p2 e7 r5 fouttextxy(x+280,y+20,"CPU");       //画柱状图
    - a) S0 V% F" M$ g2 i: W8 B; Aouttextxy(x+285,y+20+200,"IO");
    9 ^  T- \0 U4 B/ M0 a$ M$ |outtextxy(x+250,y+20+400,"change");- O, N- F# ^8 X
    rectangle(x+270,y+65,x+330,y+215);
    5 J/ B7 s% m) g- O  c# prectangle(x+270,y+265,x+330,y+415);' b4 j( `  U  b* M$ F; M7 T% v: ^5 H
    rectangle(x+270,y+465,x+330,y+615);
    2 R8 u3 W! G' u) ^$ U6 zouttextxy(x+290,y+620,"TT");
    % q5 M1 l2 T6 x* e- yt = (float)com;
    ' L0 N8 K1 E- Utemp=(t/101)*150;" S2 d3 x0 q9 z5 q/ @
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);# Q- N  L. r: L& |  ^
    t = (float)wai;" o/ b; j4 Q# D3 d$ j
    temp=(t/101)*150;
    2 x+ E+ Q7 K% z6 f7 w$ Ufillrectangle(x+270,y+415-(int)temp,x+330,y+415);
    + K  j  Z/ e6 r1 k; ^, P% V( B% n, Jt = (float)cha;
    6 t& ]' S. U( i' U* T. |temp=(t/101)*150;
    6 X( ^* e0 e8 V/ yfillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    % K+ e7 A/ v1 Z! ffor(i=0; i<3; i++)   //画坐标   high=90,length=250: d- s) j, G$ E2 @7 v
    {
    . }; e$ Q0 n3 E5 L% dline(x+650,y+210+210*i,x+1150,y+210+210*i);/ `8 a5 P$ \* |" o1 d" ]
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);- P$ c  G6 C- y  x" I- K- n
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);1 D4 a" D0 ]7 Y& M# }7 P# [

    0 j+ ~- X/ ]7 D8 Wline(x+650,y+210+210*i,x+650,y+20+210*i);. F( P& g& a- Z& s- ?! f  F
    line(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
      u) q$ H, w7 y  G* H, z) d& E. Qline(x+650,y+20+210*i,x+650+10,y+20+10+210*i);. Y6 E0 ]- _; e) G
    for(j=0;j<num-1;j++)
    - d0 s6 |  i; M: q: S6 ~0 V{
    ! D/ g$ G! L: c1 t; ^" f. n3 N4 dline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    3 e3 ^6 Z& F& l1 @line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    ( _0 l# D) f% \. m) F2 Uline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); 1 v$ C% B9 w( O
    }; x- _  |8 O2 N( N3 N# z
    }
    % F. f  T4 }1 ~% m}$ P3 P5 R' Z! Q/ ~" O; _# Z
    ' @) c: }; p3 R% ~# B0 O+ @

    ( {& X# `5 t- W- F9 lreturn 0;
    ' t$ c- z8 b( o}
    4 j/ s) X# R7 Y- X* ?, Y6 Cint drawPerformance_PF(int x,int y,int memorry,int com,int wai,int cha)
    * a# B3 Q& Z7 P{- Q# ~) r" I. d1 m5 k" M5 a$ _
    static int info[11][3],num=0;
    , y  n" V: b) D7 d' n  x! v& xint i=0,j=0,pos[10][3][2];
    6 Y; Q) c7 _# J/ i$ ]float temp,t;
    ( x5 g0 I. v6 Y( M! e. Y6 s2 |info[num][0] = com;
    8 B" x: G  i4 u" S  k4 d, r* {/ Kinfo[num][1] = wai;
    4 G: q9 t$ j) Yinfo[num++][2] = cha;5 E+ r. x* k6 j) u: U
    if(num>10)  //存储10个点- G4 A( c  i$ \! C
    {
    - Y& L+ T2 [% D9 R  ?' Vfor(i=0 ;i<10;i++)1 M$ c; ]% z6 p5 _" L! m
    {- b. X2 r. {, [. V/ M; P* o
    info[0] = info[i+1][0];- ]  N, S0 V1 ^, k
    info[1] = info[i+1][1];% ~& P( ~) ~, L7 ^
    info[2] = info[i+1][2];2 x. x( q4 c! j6 {# r1 Y
    }
    ! m; K6 Z% }7 s+ W/ w9 }num--;
    ' {4 C# ~# W6 Z}* `% ^7 ]( Q7 M6 V+ u. ~3 Z
    if(FLAG_show==0)
    3 |! B( `* i2 `4 K% |return 0;
    7 Y2 ]. S0 V5 Y7 w0 Sfor(i=0; i<num; i++)
    4 @# C. T. ^+ \4 U2 s, D7 [8 O0 w: O{& D+ F8 y9 G) W' Z' d
    t = (float)info[0];8 f0 p3 Z) x8 u5 K* _7 F6 G
    temp = (t/101)*90;
    ( M% E7 v& R3 [- Upos[0][0] = (10-num+i)*25+x+100;
    5 x! A! k) @) l3 Q8 J. Rpos[0][1] = y+110-(int)temp;2 d! d* l6 z: `; u9 d. I
    t = (float)info[1];. @  y+ i1 Q7 ~+ C2 t, N
    temp = (t/101)*90;' V6 G) L2 c  ^$ t
    pos[1][0] = (10-num+i)*25+x+100;; Y. u" i) m8 z9 v7 K; n
    pos[1][1] = y+210-(int)temp;
    3 V. O4 Z0 b/ T. M9 pt = (float)info[2];9 ~5 A  {) I% P$ j
    temp = (float)(t/101)*90;
    7 l4 R) Z* _9 {; n6 N% c9 cpos[2][0] = (10-num+i)*25+x+100;
    4 I5 m* G- `6 s/ E7 Y4 }pos[2][1] = y+310-(int)temp;
    ) F+ ]( X& x' _5 D1 v4 u% ^* p2 l( G* _}
    9 y. q; o6 x- V2 `/ Mif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
    . T) A2 s( A& b  r+ R! q{
    , Z, I0 v8 A$ _- Kclearrectangle(x,y,x+400,y+315);
    7 m5 ]' s- \+ V# R' f* y8 g1 U. z7 Asettextstyle(20, 10, _T("楷体"));- `; n1 Q& Y5 Q+ a, J0 @5 m
    rectangle(x,y,x+400,y+325);
    ! t3 \5 ?" }% ]: a- Couttextxy(x+40,y+10,"CPU");       //画柱状图
    * x+ g- k: E8 |2 l6 e* ~outtextxy(x+45,y+10+100,"IO");
    0 Z! @1 L" `3 k5 wouttextxy(x+40-15,y+10+200,"change");$ M4 C4 f+ O& X; c  N
    rectangle(x+35,y+30,x+75,y+110);$ S* y9 i3 ?1 `! O* v* g
    rectangle(x+35,y+130,x+75,y+210);
    7 I, J7 J' i; v. Y+ B  F" _rectangle(x+35,y+230,x+75,y+310);4 k5 H0 [' b, T8 m
    outtextxy(x+180,y+310,"PF");
    2 [! Z! v0 [% L, R1 Et = (float)com;
    1 m5 M( A& |& s7 I& V* ytemp=(t/101)*80;
    ! }& P4 m. B! l! p- Ffillrectangle(x+35,y+110-(int)temp,x+75,y+110);
    1 \1 w, q6 F: ?5 f  x! u8 St = (float)wai;
    4 i# `9 h* `/ c! p0 Htemp=(t/101)*80;4 M" N4 ]0 I# p  B6 A5 d
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    7 M; [. v( J7 |' r, v! j& w# ?/ kt = (float)cha;
    7 _6 _- l2 P7 _& Q' h2 w7 O3 [temp=(t/101)*80;
    4 F! n1 Q7 k& bfillrectangle(x+35,y+310-(int)temp,x+75,y+310);
      [2 ?: u9 ?& }. d/ [/ pfor(i=0; i<3; i++)   //画坐标   high=90,length=250
    : p7 m& G4 F8 y# A. r9 k. @{; @. }% g3 ]9 C6 a: g. `9 o
    line(x+100,y+110+100*i,x+350,y+110+100*i);
    ' o# n5 a( @$ }5 r8 S# X2 Wline(x+350,y+110+100*i,x+350-5,y+110-5+100*i);* X9 v: m# p  i8 @" j
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);& s! s$ w( `0 ?. G, p) I
    + C, ~# v7 e! r1 p- t2 Q' m8 N
    line(x+100,y+110+100*i,x+100,y+20+100*i);
    4 ~* w2 m* r/ sline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);
    2 P  N, ^2 }: m  Jline(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
    , m8 o+ T0 ~) F  Y/ m  o+ efor(j=0;j<num-1;j++)0 h3 p: r# w6 M+ D
    {
    , Q7 s5 Z2 F2 ]+ t9 P3 u5 V. f, Uline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);& g7 C$ f0 c% R$ L7 j& L  W' Y8 V( `
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);+ Q: F# a- Y$ w- H3 G
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); + W: w; G- {! c& H
    }
    4 p+ W; d+ ~6 s, v) R0 ^1 V}# f$ C; ^7 k8 R% h7 I( V0 X
    }
    * i, B; N% ^+ R) u7 |else if(FLAG_PF==1)0 \% q5 e1 Z& O9 O/ j
    {7 j/ ?7 \& E: }8 Y7 a# ^
    x=0,y=0;; Q5 Q+ [( i6 A
    for(i=0; i<num; i++)
    , D$ Q2 G. H' k0 m2 @" W! R' O{
    6 \7 S8 y0 u$ l, V" vt = (float)info[0];
      A3 \9 u" I- y7 t) N& c6 Jtemp = (t/101)*180;
    9 x( e& p- \. J3 T- e0 Ypos[0][0] = (10-num+i)*50+x+650;. k1 @2 ?, w+ G. H+ z2 |
    pos[0][1] = y+210-(int)temp;
    2 r7 J) ~' C( x' ?* A2 X! yt = (float)info[1];) m& k0 X4 `9 z/ o' n8 R
    temp = (t/101)*180;
    6 a) s/ ?7 \' D3 k" y5 dpos[1][0] = (10-num+i)*50+x+650;& w' N; L* P- K! m) g9 S
    pos[1][1] = y+420-(int)temp;$ q1 F: J9 P1 k. i9 u
    t = (float)info[2];
    - x8 G/ c+ a* o; ntemp = (float)(t/101)*180;+ R9 Y! {& B5 G2 [
    pos[2][0] = (10-num+i)*50+x+650;& d- s9 D6 w1 X* m$ G
    pos[2][1] = y+630-(int)temp;
    ! E+ U* _' C# Q/ q: r}# A  \1 C0 v* Y# O/ d& M  @
    clearrectangle(x,y,x+1200,y+650);
    1 M0 S0 H4 Q8 Rsettextstyle(40, 20, _T("楷体"));
    ; I5 V0 i6 S4 k2 @6 xouttextxy(x+50,y+50,"PF");
    & a" x1 {) H& b9 ?( ]1 d: zouttextxy(x+280,y+20,"CPU");       //画柱状图, O4 C  B1 a( F; P3 Y$ s9 a) y1 `/ t
    outtextxy(x+285,y+20+200,"IO");! B. |% n! g8 l" {! o/ Q2 Y
    outtextxy(x+250,y+20+400,"change");
    4 b* H  G# r# I" B* q7 crectangle(x+270,y+65,x+330,y+215);" \. P0 F  u5 ]1 H- B) Q0 B7 \
    rectangle(x+270,y+265,x+330,y+415);
    # t7 U9 h* E6 m) c1 L( L4 t2 N# O9 Krectangle(x+270,y+465,x+330,y+615);" G7 u2 T1 E# _, i
    outtextxy(x+290,y+620,"TT");
    - U. z0 B- S, o3 G5 nt = (float)com;( e" L/ v. V" J" l/ h. c
    temp=(t/101)*150;4 D& _/ L  x, [2 U( i* p0 A
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);
    0 Z* v, T$ d: `7 k5 m/ xt = (float)wai;& Z* _' q  X& U9 L. H3 F
    temp=(t/101)*150;
    5 G4 l/ _' B% ^9 c0 c3 A+ M9 ~fillrectangle(x+270,y+415-(int)temp,x+330,y+415);
    ! g1 l% R; d. @/ c* ^t = (float)cha;
    % f2 D, `8 K7 z' jtemp=(t/101)*150;
    . X! U5 |7 y  V- T# D- Ffillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    : a8 J4 Y' o3 k9 x* Kfor(i=0; i<3; i++)   //画坐标   high=90,length=250
    ; Q3 h& d5 J) `, J% I{. }( J4 U; T( {: _( |
    line(x+650,y+210+210*i,x+1150,y+210+210*i);3 {! n, J. z7 f! E. G
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    3 M& Q% L3 x/ K7 R5 e8 \line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);
    9 H! Q- M# ^. \
    , ^' a0 i# d/ f+ b3 ~; uline(x+650,y+210+210*i,x+650,y+20+210*i);
    % Y1 f) Z& y9 ?( v* l. }5 f7 Yline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);% ^8 }4 L, [& a; i- c  e
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    " r3 z: o; ^" Z$ J9 ifor(j=0;j<num-1;j++)- c" n6 _) M9 t
    {( ]$ r; b8 w9 \7 [
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);% e- {6 I0 k6 O0 }+ K
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    0 y# I$ D" k7 N4 T% d& ?7 Aline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); # w+ |3 [  F) [3 c' b+ A# ?2 ?4 A  c( a
    }8 q8 a. t) D" R( P' `
    }7 }- K- k0 M; W6 g+ G) ~
    }$ i9 O8 u! y# K) m0 t
    return 0;6 f. \5 M/ K& {8 ^+ H4 d. t( f$ ~" ]
    }! R1 s; z. ^8 q- |# b
    int drawPerformance_SJF(int x,int y,int memorry,int com,int wai,int cha)
    2 T" q2 ~7 r& j2 H9 m7 Q{
    * f8 Q0 J) @  X, U# Z; _static int info[11][3],num=0;. d7 z  C- q! v9 ]! H8 c
    int i=0,j=0,pos[10][3][2];
    ( P& w2 V) n% h7 P! U6 R! lfloat temp,t;/ I+ d' H" r- \' F# q$ d1 `6 k+ W
    info[num][0] = com;% n' z' v2 v8 a; E
    info[num][1] = wai;
    4 C7 a( r* V. Q- t" p5 f8 Linfo[num++][2] = cha;
    " m5 A9 Y3 b6 `2 k+ t( z, gif(num>10)  //存储10个点
    8 z" [6 l6 A+ i5 h- f; N0 k{
    $ v% w4 b7 j( v7 `0 Hfor(i=0 ;i<10;i++)
      i9 w/ P+ b7 Y0 ]) A7 K{
    : Q& Z  M. V8 linfo[0] = info[i+1][0];+ O, q# d& g. T& K
    info[1] = info[i+1][1];
    + c/ l, K* b0 H8 sinfo[2] = info[i+1][2];, B" F: |2 Q0 @9 l  \7 E& F* c
    }
    $ Q2 `. K0 V5 E# cnum--;3 t5 I- q- o) h. L
    }1 C5 f! Y# {  O/ l* ]/ o1 f
    if(FLAG_show==0)
    0 [* V6 X. v4 E1 f- \return 0;5 E$ [4 x9 I# r5 A
    for(i=0; i<num; i++)0 P# `$ p0 l. d+ l5 f$ e
    {
    8 C5 F8 b  l+ Lt = (float)info[0];
    0 Y  r; g) E+ q; D( atemp = (t/101)*90;
    & b8 C% r! L5 w8 h' dpos[0][0] = (10-num+i)*25+x+100;, H8 Z$ p$ W# p+ k
    pos[0][1] = y+110-(int)temp;# E! T# b6 p8 M: _  Y( X7 T
    t = (float)info[1];
    ! N3 M# C; `# r* \: ?# |. Itemp = (t/101)*90;( X' s! v; e$ z' ^6 H8 }
    pos[1][0] = (10-num+i)*25+x+100;
    & b6 P; w7 r+ Gpos[1][1] = y+210-(int)temp;
    & }/ K# C& |3 s; Rt = (float)info[2];/ d9 P0 c1 m$ `* ^0 ~0 F* d
    temp = (float)(t/101)*90;
    . Y3 n$ F6 q3 C/ j; J- U/ f1 H' |* ]pos[2][0] = (10-num+i)*25+x+100;
    " u6 D& P7 j2 V5 r' k) z0 \pos[2][1] = y+310-(int)temp;, i1 U$ I" e+ H6 Y
    }
    : D7 n! B5 S& Nif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
    ) T) K! s3 @: v5 u{ : ~+ }+ ]% j" H9 @# U3 `7 m
    clearrectangle(x,y,x+400,y+315);: w, y  L% r& W( c) W
    settextstyle(20, 10, _T("楷体"));* `" k; L# K3 V& n" ?
    rectangle(x,y,x+400,y+325);
    * A& _( g! _" M% j0 |7 R- youttextxy(x+40,y+10,"CPU");       //画柱状图
    " r2 E7 y, P. r, s3 q$ Zouttextxy(x+45,y+10+100,"IO");
    : P! N7 ^4 ~; n( Iouttextxy(x+40-15,y+10+200,"change");
    1 v6 ^% w5 q$ ], Xrectangle(x+35,y+30,x+75,y+110);2 y2 {: Q( d% y
    rectangle(x+35,y+130,x+75,y+210);( a; s3 R' h  I/ w/ q; `: L5 L
    rectangle(x+35,y+230,x+75,y+310);
    4 J, r: c* g  J; souttextxy(x+180,y+310,"SJF");
    + s8 _, }1 d& s7 c& B8 j) X- |. \t = (float)com;
    ; ?5 h4 V* q- g" W9 L, mtemp=(t/101)*80;" L2 p1 }5 i* l+ a9 R% {9 F8 G
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);9 w: S- j! ?; }$ Z6 b+ F
    t = (float)wai;
    : v6 ]2 g3 v% K$ B& t! Ptemp=(t/101)*80;6 t3 |! ?% X3 g. M
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);9 T7 f' {: V" J' `  D
    t = (float)cha;
    & ?% M& q+ O2 w1 D8 G8 Ytemp=(t/101)*80;1 i1 F9 M4 {3 G$ o) J% a, g( e8 u
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);" ^& C3 b$ ^0 D& U2 Q
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    * H2 p$ ~" {% t8 d8 y  c% [( B{
    1 D, X* d# x" ^3 Y1 I+ V. e! R6 ~& L2 g. gline(x+100,y+110+100*i,x+350,y+110+100*i);' U7 Y! h% F0 e
    line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);
    + d7 S# @$ w' D9 V7 Tline(x+350,y+110+100*i,x+350-5,y+110+5+100*i);6 d6 Q7 z* L1 `

    * V& I' |  ^" Z  Q' n0 tline(x+100,y+110+100*i,x+100,y+20+100*i);
    & O3 g' v% }+ ^0 `' Dline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);
    / o' x- [% m$ q) O: X0 c( uline(x+100,y+20+100*i,x+100+5,y+20+5+100*i);) r! K) N% Q" ~: _
    for(j=0;j<num-1;j++)4 L. [3 J3 S( q: a' f; w- ^  o
    {
    ! s/ p  ?2 ?7 F5 yline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);% N4 C# p4 z3 E. m! @2 _: U+ U, L
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);$ t6 Y: b- ~" T) B; ]; U
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    * W- N+ f/ F0 d3 T}
    1 B( P& X, V" k' E3 p+ s0 P5 O" I}9 a, u; _% i1 b5 I+ t
    }0 T) m0 \. i7 |/ v
    else if(FLAG_SJF==1)
    7 g$ f3 T+ y8 q9 U6 m{6 {7 [  n! f3 |3 M! [2 J
    x=0,y=0;
    # V/ z/ k: S% N8 ^5 A  P4 x+ wfor(i=0; i<num; i++), A3 ^4 ~8 n0 J$ s9 o
    {3 _% J! e9 N% J, J* a  E4 |4 {
    t = (float)info[0];7 h' P, O6 @8 s9 h
    temp = (t/101)*180;+ m9 E' Z/ \- o7 m5 J% I
    pos[0][0] = (10-num+i)*50+x+650;/ N9 I8 q# N& p. @: f. e
    pos[0][1] = y+210-(int)temp;' Y" w7 ]' L7 |& p
    t = (float)info[1];
    2 P+ \; R" ]2 O$ B: l! O. N* Utemp = (t/101)*180;; o* _$ J: ~, ^1 H: m9 d2 q) _. z
    pos[1][0] = (10-num+i)*50+x+650;. Z+ a6 u* X; R5 }" Q
    pos[1][1] = y+420-(int)temp;( u$ B1 N$ r& T# ^+ @& N
    t = (float)info[2];
    * ~1 B) E3 M# L3 O( t7 Utemp = (float)(t/101)*180;+ {/ c% d# y' P0 |7 ^! G6 _4 }" R
    pos[2][0] = (10-num+i)*50+x+650;
      c( J# V% T2 C6 i0 ipos[2][1] = y+630-(int)temp;4 p! m+ x8 P! s/ v7 e) ?$ i4 o
    }
    * d* t+ U9 P' ?3 p# `8 Qclearrectangle(x,y,x+1200,y+650);2 U0 M2 }) q, M3 X* k( K: G
    settextstyle(40, 20, _T("楷体"));
    ( ]. @8 u7 m& Louttextxy(x+50,y+50,"SJF");
    9 F0 L$ ^1 q2 `outtextxy(x+280,y+20,"CPU");       //画柱状图% r9 T$ b8 r$ m3 u5 }- B. i
    outtextxy(x+285,y+20+200,"IO");, G+ r) U: _- V: I
    outtextxy(x+250,y+20+400,"change");% N. [' w- Q7 R4 H$ h2 p6 R
    rectangle(x+270,y+65,x+330,y+215);4 z: F) X$ q6 n1 {( j1 X; ^& g
    rectangle(x+270,y+265,x+330,y+415);: e& f- M1 B! n$ |, E' v) S" @$ Y1 s
    rectangle(x+270,y+465,x+330,y+615);, e5 a0 Y! v3 a
    outtextxy(x+290,y+620,"TT");
    4 x6 O' L4 O! K# R% T! Ft = (float)com;
    2 R) p  t% {; h. f: m9 \0 Utemp=(t/101)*150;0 I) S2 g' N3 y, s% K: ^! _2 c% H4 i
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);9 W/ B2 J  s, O/ {& p3 z
    t = (float)wai;: q; a' k$ U- k; X3 I, G8 l0 k2 c
    temp=(t/101)*150;+ g: ]/ d3 z; ~" {
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);% d- o; B6 ?+ m
    t = (float)cha;/ s" J4 t% Y+ J( t$ _5 O- x6 h6 ~& W
    temp=(t/101)*150;" t, j0 w7 k8 J6 |
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);' V9 |; W% ~7 e
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    0 K1 z9 {* k9 j0 G{
    1 l' `0 G% R9 f( c( Zline(x+650,y+210+210*i,x+1150,y+210+210*i);
    $ x" t# i6 H: w" v6 e: ?$ Mline(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);1 u& ~( F3 o1 c3 b+ b7 r
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);2 ~; x8 n+ k% m) [* j  K9 ~5 \% f
    ( [5 }; M: a. g. I. H
    line(x+650,y+210+210*i,x+650,y+20+210*i);
    5 S- G/ ?: ~( F; y' K* e" U$ Hline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);6 n2 I1 I! t  a) M
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);+ e- H% t7 J& ]) A( @5 I
    for(j=0;j<num-1;j++)
    8 f" R+ h! f, A, ^5 ?6 |  b; a{
    2 G- T* d$ u0 v* B6 A- Q$ Qline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);, Q2 X: s+ M* I: o. q4 \
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);' H  d) r/ G/ k9 @
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); ' {: s% c. `3 g" z! [9 x
    }. Y  i5 ]( w  b) m
    }0 z7 N* C$ {6 W; U
    }$ U# W2 y7 e7 k8 j; p: ?
    return 0;
    . k3 X. s( Z. d3 C$ G$ z2 g* ]}
    ) d& v6 e& q" N& x5 n3 y# Hint High_response_ratio_dispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)
    * {9 @1 e% d; g9 y& @# o{, y7 C( e' |2 O6 M
    static int compute=0,waitio=0,change=0;9 {* v% i) k% T
    static int computeLast=0,waitioLast=0,changeLast=0;, I2 @  P- \- e4 e" ]9 l/ P5 n3 Z
    int i=0;' n' o) d' l1 {- O6 g8 _& P  n
    if(draw==1)  A0 t3 I7 s0 f: a5 `2 F
    {3 @$ b8 s- J3 _( r8 I; `
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);9 }% e& h1 H( V! S0 L* x7 O
    drawPerformance_HR(400,325,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);5 O' [. s. w# N9 W8 c, \
    computeLast=compute;0 n. X2 k$ N+ R& h
    waitioLast=waitio;  o7 A1 q, y/ f5 e8 K
    changeLast=change;' C( n$ V( f3 |
    }
    / j: @! M8 C+ g7 k  E$ qif((* memory).p[0].flag==ready)
      _' e' f) b  i(* memory).p[0].flag=computing;; f$ c, l7 s# T7 P% O1 E4 a/ @4 k
    if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)  Z  o7 [& a+ o
    {
    , ~# ]5 F& g6 m, T0 Z! k1 ?i=(*memory).p[0].computeNum;$ C2 l& U; L# R9 v8 L
    if(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed, `! E% L; `) d* m3 e9 H! c7 K
    {! {# R% y! V$ H9 j. i  G
    (*memory).p[0].flag=IO_waiting;
    ) e9 \7 Q/ X; P+ _9 a& Q3 L4 j(*memory).p[0].computeNum--;% w) q3 r9 D1 t% W7 x8 C. B- I
    change += exchange_IO_Compute;4 Y6 \: F! `. N/ [) t
    compute++;
    8 }4 p6 M5 ~: D# @- T}3 U# o$ T' Z" R1 I0 U+ J
    else
    4 j$ m  X( [' w' i" [/ c& k  T7 G: l{
    $ m' z- v2 N, S7 G9 F+ icompute++;1 k4 M" ^+ D: w, `+ T6 Z+ q9 ?
    }
    3 v: `+ L% G6 }% K}
    6 c- [6 M3 k* t1 D" X) }0 Pelse if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)
    ( Q3 y: r0 [9 H+ u  t{; }0 {- u/ X+ G# z5 v5 ?

    ' V) b% b% j* {* si=(*memory).p[0].ioNum;
    + y8 ^# d/ {: P/ T" x& L1 Tif(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed" @" j" J$ k& [5 V
    {
    + ~( S% T% H7 x(*memory).p[0].flag=computing;
    4 ]/ P$ K0 P6 q' E' Q- K(*memory).p[0].ioNum--;
    , E$ C/ o8 g/ u8 ichange += exchange_IO_Compute;
    5 z9 b4 K* v4 y( J  g% ~+ Dwaitio++;
    1 j9 n" z: W, v( i) w}  h$ O1 P9 @+ D+ B. y
    else
    * `! M3 v' Z: L- a" _1 o{
    6 i6 X% I3 h' o- c1 |waitio++;/ T* k& e* x$ q3 J8 H0 C6 Y/ }
    }
    ( a7 p7 p) |) l( P# y, m}5 I8 i! j8 P; A
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)
    1 d  P7 @& g" ~{5 L, W" B, J* F; d, T
    (* memory).p[0].flag=IO_waiting;% }! e8 T- K( a1 b9 V
    change += exchange_IO_Compute;
    , ^4 O+ i, S% S% g0 j9 Z4 o3 x" [}8 B5 s" E3 N( D/ e! _
    else if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)2 l5 Y, i- q% n9 c* i
    {
    / @4 V9 r/ z% M! n8 A+ R) L6 |8 Z9 q(* memory).p[0].flag=computing;! K# g. V( O- p0 S. c  D9 ]
    change += exchange_IO_Compute;/ k, ~- W# y- [/ m. f
    }
    2 S( R. \; z8 G) }% B/ Eif((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成; D: y; ]  o4 e; v) s3 j
    {* g& e6 v) X) N3 ]! Z
    (*save) = (PCI*)malloc(sizeof(PCI));
    & i5 X+ I: D% H(*save)->next = NULL;
    1 r& F( M5 H) b: Q+ @# i% |(*save)->processID = (*memory).p[0].processID;, w. T# Q! @3 }. t
    (*save)->comeingTime = (*memory).p[0].produceTime;; ^, l) ~) H/ j9 @- _- W+ o8 D
    (*save)->askMemory = (*memory).p[0].askMemory;, n) K' c1 I" ^, U$ o8 N
    (*save)->compute = compute;
    $ l; ]* e) S- d; S* u  q8 K& e% ^* ~(*save)->waitio = waitio;
    * K+ S, y8 A* p  A, w, o(*save)->exchange = change;; L& ~1 r' n5 n& a
    (*save)->completedTime = systemClock;4 M1 O. h% j6 B7 k' s5 @
    (*save)->runningTime = (*memory).p[0].runningTime;1 k: J/ f. ]' z  M# u/ F/ Z0 f0 e
    *spareMemory = MAX_MEMORY;         //*spareMemory + (*memory).p[0].askMemory;* [4 G3 k0 f. B5 ^: V
    compute=waitio=change=0;$ m8 |9 q* _$ w6 d0 r$ E( P
    computeLast=waitioLast=changeLast=0;
    ( ^8 d5 `1 j' gHigh_response_ratio_s_to_m(&(*storage),&(* memory),&(*spareMemory),1,1);) C( K+ S: @) T( g6 y
    change += exchange_process;' ]/ c7 [) Q! X) L/ W
    return task_completed;
    / n7 R: r  I7 T# z7 _}
    # H- n- t' d+ u2 ~8 k9 Xelse
    * h. u. G4 e. e8 oreturn task_not_completed;
    9 N7 c8 P) z% k" `& b; v  X}# a6 A7 @) |! g5 a3 C7 @
    int High_response_ratio_s_to_m(processPool *storage,processPool* memory,int *spareMemory,int flag,int dispatch)
    / b! E1 N& }$ a3 {/ x: G/ M{
    6 K4 `7 U. ~6 v: S, d' jstatic int waitTime[initProcessNum],i=0,j=0;
    & B4 |" o7 T: }4 `4 p' E: nstatic double HR_ratio[initProcessNum];
    7 ]  B- s3 `2 ^1 Eif(flag==0)                    //初始化数组
    4 ^- G/ P7 I$ {! B( c3 g- h{
    0 v! T! S) A+ c: r% sfor(i=0; i<initProcessNum; i++)* \# x# [- E1 I# t9 s8 ~4 Q
    {
    " }+ R9 a+ g( @8 p7 H1 e3 Y/ kwaitTime=0;
    ; y& D  N* C, Q9 A* K3 e8 s; X4 L4 VHR_ratio=1;  o" y, h7 D  \1 b7 f- X0 I
    }
    : T5 J# k7 m& Q$ D  M* R: U}8 p# R* @/ C5 h  t4 w) @4 U
    for(i=0; i<(*storage).proNum; i++)  //等待时间增加,重置响应比
    6 u  a5 a4 j! K4 `" p9 M6 W2 M{
    0 Z) U! x; p0 e# swaitTime++;+ J5 U. P* h$ i$ t4 P
    HR_ratio = (waitTime+(*storage).p.computeTime+(*storage).p.ioTime)/((*storage).p.computeTime+(*storage).p.ioTime);
    ; {+ c/ P6 B( W7 W; x5 n1 mif(HR_ratio > HR_ratio[j])
    1 m9 S3 k* z; i! ^) q  bj = i;
    4 `8 V' u+ x. r+ ?}
    7 ]+ y- f' h+ w) h' u$ k+ kif(dispatch==1)                    //需要调度一个进程到内存中执行6 H9 h( [9 R0 n% P  c* g
    {
    ) s8 i$ \" e& T; jif((*storage).p[j].askMemory < *spareMemory)$ g( m: \& b4 I# z: T4 ]
    {9 g$ W" G, \! K% J) C2 K
    (*memory).p[0].askMemory = (*storage).p[j].askMemory;
    / V3 d" a$ O; R$ L# K, t(*memory).p[0].comeingTime = (*storage).p[j].comeingTime;3 d* Y! ^' U9 J" D- \8 ]
    (*memory).p[0].computeNum = (*storage).p[j].computeNum;+ f% ~6 ^5 V: T5 o3 g  A$ c3 F* @) N
    (*memory).p[0].ioNum = (*storage).p[j].ioNum;
    4 O/ o9 ]' b$ O3 Q! S(*memory).p[0].processID = (*storage).p[j].processID;' k0 h$ H% g3 I5 G
    (*memory).p[0].flag = (*storage).p[j].flag;7 [# H: y+ o4 _: K2 H- [9 ]0 V0 _
    (*memory).p[0].ioTime = (*storage).p[j].ioTime;! z$ k2 z! x  l! a! A& m5 Q
    (*memory).p[0].computeTime = (*storage).p[j].computeTime;
    * o. u% Q3 o' C+ C6 O7 G(*memory).p[0].runningTime = systemClock;5 p! W* v+ h% U9 m
    (*memory).p[0].produceTime = (*storage).p[j].produceTime;
    0 c5 o5 n- s/ \) M5 d7 ]3 Cfor(i=0; i<(*memory).p[0].ioNum; i++)
    2 ]6 d8 S* w) i(*memory).p[0].ioClock = (*storage).p[j].ioClock;$ w" T# X1 o5 D. `
    for(i=0; i<(*memory).p[0].computeNum; i++)( r$ J8 `: S7 X' l' S
    (*memory).p[0].computeClock = (*storage).p[j].computeClock;- P# P, \( U! n7 R: F  Y( Z/ [& l
    (*memory).proNum=1;6 U" t, _( y/ a. o
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;1 t5 g# C: \$ w% t& T% K
    produce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程9 S* I9 c+ t8 i& Y
    (*storage).p[j].produceTime = systemClock;' W9 }: b9 f* T
    MAX_COMING_TIME = (*storage).p[j].comeingTime;6 \% f6 }  ]* i4 m/ m8 W
    waitTime[j] = 0;2 b3 i0 ^8 O9 j+ r3 Q7 n
    HR_ratio[j] = 1;7 K; R* N$ w& I2 K8 |( a7 ~5 U# W
    }
    1 N! F( Z. X/ r! @else7 [( _/ X' g* F+ y
    {+ o9 T+ N( }9 M1 E8 ]( J2 ~& b) P
    printf("A process ask for a memory overed the system capacity\n ");
    " L# P3 f3 T' |& Q: A& a! o6 vexit(1);
    * m" X- P/ o0 ~8 s4 r- s}3 E$ A; I: c- M3 i3 q5 k7 K. u
    }/ \, o8 C# w( \, U, X7 o% U
    return 0;" {! K, o1 D% k0 y* E# N" \
    }* R& H; W' E0 s: L. @. t
    int PriorityDispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)) n' C6 j+ v. g. V
    {
    : D7 c4 K7 [" C8 W! C9 F" `static int compute=0,waitio=0,change=0;# D+ T% W1 A7 N: ]3 [
    static int computeLast=0,waitioLast=0,changeLast=0;
    8 \: C& v9 v! X- _int i=0;( b- m$ ?: v' n: W$ o% d7 l, V# A
    if(draw==1)3 N' x8 z+ z% L3 L0 O
    {
    5 L* o0 ]8 ], G* E' ~; @//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);: j+ _% l8 f5 Y5 R& n! g
    drawPerformance_PF(800,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);5 X( y% K2 G& z) T' X. e
      ^; U5 O3 n' x! W' o
    ' {% R6 H$ d+ }! V9 P# Q
    computeLast=compute;% g/ I5 t0 M/ ?- R- {
    waitioLast=waitio;
    . Z7 V9 ?, l, t9 u6 M: @changeLast=change;7 i; k; N/ u( B6 S+ W& G9 m
    }
    , Q' T6 L3 t( V7 C2 A( Nif((* memory).p[0].flag==ready)
    % {3 ?7 p3 F6 \' ^/ a(* memory).p[0].flag=computing;
    7 ~% b, W/ r0 I- }) |, ^if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)( t6 ^7 |* X( H
    {2 q* ]2 Z5 E4 _7 [5 b& F2 `4 p4 B9 e5 C
    i=(*memory).p[0].computeNum;- v  h' p8 f/ j. b9 ?
    if(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed
    ; t* `6 v8 d. \% R; D! K{
    * F2 B3 s  T* o4 t6 m* }: r) N(*memory).p[0].flag=IO_waiting;9 Z! l' q. q4 z0 `6 [5 ^6 E' s/ R
    (*memory).p[0].computeNum--;
    ) `+ l" X2 Y) O& Achange += exchange_IO_Compute;
    3 d' c2 o, x# P* R, _. K2 X) Jcompute++;
    * l* C2 e0 }$ Q3 X/ V2 x; E}8 h, y% C" E* {
    else" O. g6 H. f2 u( [$ K7 t$ t
    {
    5 X5 t' f4 V) q) g6 zcompute++;8 T: n. C! ~% H
    }1 s: A) _! `, w. b
    }
    7 n  f/ l2 x  O+ }+ helse if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)
    $ f; Y+ o8 u+ v8 s. o{  a# D3 }+ f2 f( ^5 p. d
    4 `3 U/ D8 v' o  b
    i=(*memory).p[0].ioNum;
    : Z6 J) [# v( z: Q* Vif(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed+ n& `* Y3 R3 H* H# ]6 ?4 y
    {
    ( }# Q8 u) k8 X5 }+ c6 `! p; y* L* \(*memory).p[0].flag=computing;
    / {) f8 o1 g: D7 D  t6 N(*memory).p[0].ioNum--;
    3 o8 z6 `3 e0 X7 H% Cchange += exchange_IO_Compute;
    6 K( k, P' z- G5 a/ n' B& q5 ^waitio++;7 @9 B9 h% Q" }  e, [
    }& V. h  X: h8 I* [" D% N
    else% [- e' n3 R# `7 r( P
    {
    6 R9 i1 R) O$ g, g- ]7 Z5 pwaitio++;- Q0 ^, Y' u; N8 T
    }# v- M0 m8 [- U
    }" l* v0 l' e5 W* l/ P
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)0 B$ Q* s6 X' @5 X  Q
    {
    ; L5 G/ N  j: b5 V2 [8 o, E2 U(* memory).p[0].flag=IO_waiting;) t9 }& f9 [8 a9 E5 h- K
    change += exchange_IO_Compute;  e5 [1 E5 ~# Y7 h) B7 X
    }! o+ C! [3 v) G4 [# A
    else if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)0 Z$ u3 Q+ f( M9 j+ c# U
    {
    3 k* M* e4 Y+ z0 N(* memory).p[0].flag=computing;
    * t' ?4 K3 J. Rchange += exchange_IO_Compute;
    % l" p+ X) x, F* j, l- k: F}% t* J. U( F/ y) L1 U% L3 g, x4 Y9 y
    if((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成
    # i$ }5 T3 U6 O5 a5 l$ M{$ O$ Y! `) W4 y0 k! }1 W$ h
    (*save) = (PCI*)malloc(sizeof(PCI));
    0 K* x( }" N2 a  z0 p0 e(*save)->next = NULL;
    3 Z1 l3 s( E8 u(*save)->processID = (*memory).p[0].processID;
    3 v2 _' u. J! J# Z- H(*save)->comeingTime = (*memory).p[0].produceTime;  V4 ~# E! d% [5 o/ w
    (*save)->askMemory = (*memory).p[0].askMemory;
    $ o1 s9 O$ z6 O: V* x: G(*save)->compute = compute;
    ' K. n/ |7 D. P- @(*save)->waitio = waitio;8 C$ c& t9 h2 L2 e) P  I: a6 j; j
    (*save)->exchange = change;
    - i' T( v. Z; J$ P; W* M(*save)->completedTime = systemClock;
    / Y% Q; `& t: b0 _( n$ G9 {(*save)->runningTime = (*memory).p[0].runningTime;
    ) S4 C, _& g* m*spareMemory = MAX_MEMORY;      //*spareMemory + (*memory).p[0].askMemory;1 p$ Z! X$ E/ ]: Q) {
    compute=waitio=change=0;- g" n: `0 A% W; R; g+ ]% ~* u, X
    computeLast=waitioLast=changeLast=0;; R; A, A  f! z: E' D
    Priority_storage_to_memory(&(*storage),&(* memory),&(*spareMemory));
    # L& w$ d$ _4 s/ W9 g. echange += exchange_process;4 K) \8 W1 X8 z6 {) `
    return task_completed;
    - g! z3 ~0 I, f: ^! y: J}
    " R6 T4 Z* q% q& o, I. Pelse. [. H; C7 g* W
    return task_not_completed;/ e( [8 ^$ B/ X2 ~3 \& T: _
    }
    - z$ Y: E' D7 g& D7 v2 Y# `int Priority_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory)* z9 p1 E! X* T) X7 t
    {0 ]& v! j3 o' j( A( `
    int priorityNum[initProcessNum],i=0,j=0;% P$ g1 y/ i8 Q; U$ e4 _4 @; {
    double temp=0;) x( g7 |" Z3 Z1 \4 t9 \) Z
    for(i=0; i<(*storage).proNum; i++)    // setting priority to each process
    % [# T# w; v4 y+ U{
    8 L$ ^% ]) s/ O7 O  Wtemp = (*storage).p.computeTime/(*storage).p.ioTime;
    # ]* S7 r2 s, W* B/ p! \if(temp > 0.8)5 q3 E* J2 A! T+ v, _' y
    priorityNum = 6;
    " I! s- i% _% Q: l+ I# Nelse if(temp > 0.7)1 M. Q2 f" b* W8 C9 I
    priorityNum = 5;2 T7 T0 Y, x+ o) E/ c
    else if(temp > 0.6)
    % W7 n5 \7 p4 m6 c. UpriorityNum = 4;- U* d9 f$ D( N7 k  P8 k: a
    else if(temp > 0.5)* k! }) S" {6 F4 ~+ B
    priorityNum = 3;
    * @# y2 J% v6 {( |- Welse if(temp > 0.4)3 v) a. `) Y4 H$ x: ^( R4 Y8 d
    priorityNum = 2;
    % `- W% K# }; Y; M" Delse
    0 u; o# Y% a5 N3 Q& M; g. cpriorityNum = 1;% p. u7 X" {6 Q2 J
    if(priorityNum[j] < priorityNum)
    4 V7 Y' ^6 h( uj = i;
    ! Q% }) n( v" T! R}5 z* ~1 J; h; u
    if((*storage).p[j].askMemory < *spareMemory)
    ( S* Z% J3 f9 J{( W4 d/ b4 d8 T/ e* q! b
    (*memory).p[0].askMemory = (*storage).p[j].askMemory;$ d) Y3 f9 U! M/ c( w
    (*memory).p[0].comeingTime = (*storage).p[j].comeingTime;
    : G* }/ Z- i# [. ?" S(*memory).p[0].computeNum = (*storage).p[j].computeNum;
    $ \# v8 e9 n* a* x- d: T# H% h$ w(*memory).p[0].ioNum = (*storage).p[j].ioNum;3 ^3 P; \% \! T. M5 ^% `) K9 e
    (*memory).p[0].processID = (*storage).p[j].processID;
    % Y, B( S# f5 Y6 B- @2 s(*memory).p[0].flag = (*storage).p[j].flag;5 h$ K- o  N1 D
    (*memory).p[0].ioTime = (*storage).p[j].ioTime;  T9 E" e% U7 \, S, L, @
    (*memory).p[0].computeTime = (*storage).p[j].computeTime;
    4 |4 q; _0 y; D3 c1 _3 M(*memory).p[0].runningTime = systemClock;$ a8 L# J; s, {+ S3 r
    (*memory).p[0].produceTime = (*storage).p[j].produceTime;; d& m; F* s, F# e$ G  f, l
    for(i=0; i<(*memory).p[0].ioNum; i++)
    ( M8 h) N& v$ w(*memory).p[0].ioClock = (*storage).p[j].ioClock;: i1 a) i$ h1 o/ X
    for(i=0; i<(*memory).p[0].computeNum; i++)2 U' e% T; s9 E% K; V7 }
    (*memory).p[0].computeClock = (*storage).p[j].computeClock;
    3 C1 R  P/ C; n5 v& J6 y2 m' ^(*memory).proNum=1;
      G5 `2 c- J/ L+ ?9 @, I*spareMemory = *spareMemory - (*memory).p[j].askMemory;+ _) r- w, e; }& [+ t) j9 t
    produce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程
    : g' N/ p! Q) ?6 p' R! _% nMAX_COMING_TIME = (*storage).p[j].comeingTime;' \8 B( \: D$ n  t% G
    }
    . Y$ r  P6 D9 delse
    9 r) T( j  N7 p/ A, P& M{* H3 N4 S9 s& o0 S, D8 b# H
    printf("A process ask for a memory overed the system capacity\n ");1 E: o- w" }6 k% H. b
    exit(1);
      x' X+ P. g+ s3 I* R}
    $ _7 K- ~+ i) K4 @( R4 freturn 0;2 r! d- e+ b( s' V/ y7 w
    }2 I/ O# |  T% ]
    int ShortJobFirst(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)% u' D$ Z# b4 B. k6 x3 u4 y% x
    {  a% Q. f& B4 \& ]" r& |
    static int compute=0,waitio=0,change=0;
    / I) i! S& j. n' y! }) h5 O" bstatic int computeLast=0,waitioLast=0,changeLast=0;
    $ h0 U. r8 f) ~8 W9 jint i=0;
    - ]3 J8 D3 k4 v* ^6 n5 t% N5 Cif(draw==1)
    & {# v. c+ v' L0 r0 n$ ]) i4 n- k{+ \& ?. y  M% x5 K2 }4 Z. Y
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);+ }3 S+ _* I+ b
    drawPerformance_SJF(0,325,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    1 d! o; o/ s7 ]% F" i; @$ V; r/ Q0 Y

      U) \1 n+ W% A& o8 xcomputeLast=compute;
      o6 y8 `$ M% r0 SwaitioLast=waitio;- R2 Q" O! T! b
    changeLast=change;
    6 A/ F1 U" r) ]: N5 h}
    $ M4 n! s' [, H! `! n2 Dif((* memory).p[0].flag==ready): f5 g: C6 N& }) w
    (* memory).p[0].flag=computing;2 s# |/ F  o( d, U$ S5 U" s+ n( P
    if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)0 V: W  Y. Z5 K$ l; i0 i
    {6 u% e5 o/ ^0 h# S* t& U7 B: M8 g, u
    i=(*memory).p[0].computeNum;
    $ W' W: @, M0 j7 dif(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed
    6 [) u6 z/ ^( l- a. b5 X* Y{
    5 X3 v! ]. \2 e(*memory).p[0].flag=IO_waiting;
    , {" b' B: U6 X/ T2 v+ Z(*memory).p[0].computeNum--;' W# Q# [% i; h- @# Q6 A
    change += exchange_IO_Compute;
    5 b; Z$ Q9 l7 l$ B2 N1 p+ V- |compute++;9 I+ n; @6 N" C2 @( f! v
    }/ V: z( y, r- y; U2 h
    else
    8 R1 |$ w  v0 c/ J{1 \8 e$ J/ ]/ C2 s* K6 M
    compute++;* a7 ^7 a$ _/ c: Z; _
    }
    + F- z4 Q: A$ M1 x5 M0 X7 b}/ a! d2 L* P2 ]7 w2 n/ O
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)
    ' S. p6 Y  w$ j* G  R{
    5 i/ Z6 u# t. H8 Y" j0 d- U  C3 {
    3 M4 ~% m9 d" s* Ii=(*memory).p[0].ioNum;
    $ L& m4 t$ C/ y6 ^+ l1 `9 H2 `if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed& T+ Y1 w" c/ {5 d7 |5 k( C
    {8 d; W$ N& I. `' |, ^5 j
    (*memory).p[0].flag=computing;
    * z3 ~1 b7 u2 M. |/ h% ~(*memory).p[0].ioNum--;  P; k- }+ w) ~1 e  x& Q  g: ^: d7 G
    change += exchange_IO_Compute;* n) g5 ~( b  [% f& t0 K+ D; l
    waitio++;+ v5 E% U9 m! {& f& E
    }; M( c  q( k! p# y5 i$ A
    else% l( F2 h- t7 |# r! Y, B
    {
    : X+ o# u6 e: J# ~/ ?; o- f. U' T! Dwaitio++;+ S2 h7 j9 @2 M, ]7 J
    }
    6 b( y' @4 l& r7 b3 ^5 ~}9 _( y# R* K5 i3 ^0 j8 |4 ?
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)
    9 `4 d# l8 I' _1 R{
      G4 k$ L7 Z; ?( o& i6 X(* memory).p[0].flag=IO_waiting;
    8 L$ Z- O9 k9 H- W1 G' Vchange += exchange_IO_Compute;1 u* }6 O3 y4 [) i
    }0 Y: C8 X6 P& y* W6 X: G
    else if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)
    2 [1 n( H* t; }2 u{
    . Y9 L: ^' X8 O2 @8 t& y(* memory).p[0].flag=computing;) r( S; _8 K9 C* `) @+ h
    change += exchange_IO_Compute;+ `9 i9 ?+ _9 [7 ?
    }+ K7 k& E2 p! m7 {* h7 t
    if((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成! J! C6 o/ x( w: G. i. W, j5 D" j
    {
    ' H1 A" h- o1 Z4 _# p% J, `# v(*save) = (PCI*)malloc(sizeof(PCI));
    & L2 m' Y! C. \2 r(*save)->next = NULL;
    " ~" j: A* |3 T# d9 x0 Y) P, Q0 F(*save)->processID = (*memory).p[0].processID;
    3 E2 G; k* @6 T& M(*save)->comeingTime = (*memory).p[0].produceTime;7 H5 X! m9 c, J
    (*save)->askMemory = (*memory).p[0].askMemory;* G% Q" ?$ u* P8 L0 t& k
    (*save)->compute = compute;0 b7 Y. N4 a+ y- i( q9 E1 t+ ?1 u
    (*save)->waitio = waitio;
    - }8 k/ L& L) r* s(*save)->exchange = change;' E7 y$ r$ O+ w% V
    (*save)->completedTime = systemClock;
    4 @. @+ S4 q4 b/ J(*save)->runningTime = (*memory).p[0].runningTime;( P5 ~4 N# @! S* k
    *spareMemory = MAX_MEMORY;//*spareMemory + (*memory).p[0].askMemory;
    - H7 M6 o! h; w, ?compute=waitio=change=0;
    % {- \$ R4 f6 T& _7 p; tcomputeLast=waitioLast=changeLast=0;
    ! I" _- d8 D& }& y, w0 ]) x% V+ ^! FSJF_storage_to_memory(&(*storage),&(* memory),&(*spareMemory));
    2 E2 Y( b' z1 X8 V% bchange += exchange_process;
    5 Z, k5 }4 z7 D9 `, X; L! T+ Yreturn task_completed;' r) O: V3 B2 U. p; q
    }0 Q: P9 d  H% ^6 T
    else
    ' `* I2 V! C, Zreturn task_not_completed;
    " l; L, o3 h/ z}
    9 z- G. ~/ j( H2 b: m0 G" Wint SJF_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory)9 r2 K$ N8 T1 o3 z# \6 `  }% c7 ?! L
    {- U7 Y, |& h+ O- W4 N* n
    int i=0,j=0;
    + q1 A: f$ J6 D8 M) k4 N+ pfor(i=1; i<(*storage).proNum; i++)
    # e8 D! J; F6 v6 ^! t{( g" @0 O/ |9 D% n2 c
    if(((*storage).p.computeTime+(*storage).p.ioTime)<((*storage).p[j].computeTime+(*storage).p[j].ioTime))
    3 [4 u1 A0 S+ L8 R) v( T4 R0 u. i9 ej=i;* L* [( g/ \2 x; a; W# `
    }" n2 d3 k2 _$ T& w5 |- ]# e
    if((*storage).p[j].askMemory > *spareMemory)
    # B% g9 @6 j# p. W# [{3 f! ]* x8 i# G% r: |  q0 E+ o
    printf("The memory asked is overflowed than the system memory.\n");/ p% a8 F0 J/ z& N2 E7 I
    exit(0);0 R: J# w- U) O) U
    }
    " V9 z% o" y+ o2 }else
    7 s4 i2 t, L9 q0 B! v$ z) u5 p{
    " h$ M  g( y; h) k2 }: ](*memory).p[0].askMemory = (*storage).p[j].askMemory;9 ?, C7 q. n5 q# l' n7 g% e
    (*memory).p[0].comeingTime = (*storage).p[j].comeingTime;8 C: d3 w% q; k  C$ _' s" u
    (*memory).p[0].computeNum = (*storage).p[j].computeNum;
    3 U* u0 p8 r/ ~, s- ?; l+ W% S(*memory).p[0].ioNum = (*storage).p[j].ioNum;
    3 R) {3 |2 s7 j' b5 [7 t(*memory).p[0].processID = (*storage).p[j].processID;
    ) b  q0 w3 X& K0 d) j' P2 X0 ?: M8 j(*memory).p[0].flag = (*storage).p[j].flag;
    + D0 y$ E  h) _1 ~1 @(*memory).p[0].ioTime = (*storage).p[j].ioTime;
    ' ~, D7 s& f% X(*memory).p[0].computeTime = (*storage).p[j].computeTime;
    0 r9 s4 N4 U" ^; [! V3 K(*memory).p[0].runningTime = systemClock;( I! V& V0 L+ w2 r8 x1 @" w6 I# u
    (*memory).p[0].produceTime = (*storage).p[j].produceTime;
    8 E* q. N$ [- l4 |, U& lfor(i=0; i<(*memory).p[0].ioNum; i++)# N' k; j5 a( n8 {
    (*memory).p[0].ioClock = (*storage).p[j].ioClock;
    : |' Q6 z# Y4 R& o. vfor(i=0; i<(*memory).p[0].computeNum; i++), T  H+ s/ w: @; S, G
    (*memory).p[0].computeClock = (*storage).p[j].computeClock;
    # o0 f0 b% U& R7 M(*memory).proNum=1;; C' m: Y. L$ k8 Y
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;+ T8 e0 k% q) G$ k! n
    produce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程/ r; A$ }( y8 A6 v: }( H
    MAX_COMING_TIME = (*storage).p[j].comeingTime;
      ~+ L! Z8 b8 d0 D, }& Q}
    1 C6 U/ h1 n( C# I6 L! Qreturn 0;7 G' i# J: D& U+ s+ Y2 I
    }
    ; s* o8 L2 a% Y5 I' P8 t7 Xint TimeTurning(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)
    ) E. F  ^# b4 g; O: A4 T{" X0 N+ M( ?! u# c
    static int compute=0,waitio=0,change=0,clockSegment=100,poi=0;
    2 E# r4 U- z+ S( Kstatic int computeLast=0,waitioLast=0,changeLast=0;
    , m# r; ^5 e, p4 Iint i=0,j=0,k=0;, E7 q( r. t9 ~1 J3 K' \& {2 E
    if((*memory).proNum<=0)6 X' x7 R# N  l" l5 _2 m+ |
    TimeTurining_storage_to_memory(&(*storage),&(*memory),&(*spareMemory),-1);
    : p- b' c; |/ J2 @0 ]if(draw==1)6 V2 ?% |, \; G' @% l% c
    {3 O: k# i$ P  x6 `0 B4 n
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    8 |0 J, e6 D$ i3 f0 {" h& N! fdrawPerformance_TT(400,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);8 i0 L6 M, V: ]9 m3 e( n9 t; b1 d1 w

    9 M% L; Z# \- n, s0 A. l! q
    : u# }( z. ?% |, T& ecomputeLast=compute;5 E+ n% p. I( h7 e! B; m
    waitioLast=waitio;
    ) a+ \6 w8 u% e" p1 X  s4 Q7 u' |, DchangeLast=change;/ X- z2 b9 \1 N5 \$ H
    }; V4 _) @, d, ?4 h2 v& D
    if(poi>=(* memory).proNum)
    : X# L* ^3 ^0 x+ Fpoi = 0;
    9 d* \, A/ g* U9 ~if((* memory).p[poi].flag==ready)9 w. ]. y6 R- C6 u
    (* memory).p[poi].flag=computing;2 d  o% `& x8 m
    if((* memory).p[poi].computeNum>0&&(* memory).p[poi].flag==computing)
    ! u3 G6 Z3 ]9 U: J: ]{
    / @) M" d4 b: fi=(*memory).p[poi].computeNum;
    ; w6 }7 _: w% D: t! d9 K! |0 N( Eif(--((*memory).p[poi].computeClock[i-1])<=0)// one compute tase is completed
    . ^4 }/ o1 b5 }6 Z{, G( X2 r6 L7 Y" ?) a
    (*memory).p[poi].flag=IO_waiting;
    ( Y6 Q7 G6 \, L2 X# [* I(*memory).p[poi].computeNum--;
    % z3 ~8 t4 g$ R4 k. p  w  k+ cchange += exchange_IO_Compute;" m" b. |9 N8 R& ?, S- m  O  e
    compute++;) _& [4 L8 ^5 S" n( y, F8 X% a7 z9 v
    }" }8 M. Q2 Z9 e8 n6 V; ]& Q+ Q& J
    else
    % s  ?& R; u3 g4 z{
    ! m# m8 t# Q* f8 e" Ycompute++;
    / f/ _. _# T1 {+ C3 Q4 _8 f}
    - F% C4 H2 D* ^# Y& F7 J( [}0 G0 M) E$ O1 W+ i! ?! [0 C3 X
    else if((* memory).p[poi].ioNum>0&&(* memory).p[poi].flag==IO_waiting)
    : d. A  |3 ^2 [$ }{8 X9 E! `% p( W7 Q$ @  C4 S4 T! I! p
    * Q5 M. t3 x/ E  u, @: X; E
    i=(*memory).p[poi].ioNum;: ~( p9 h2 t" a1 e; @$ ^
    if(--((*memory).p[poi].ioClock[i-1])<=0)// one io tase is completed9 t0 N  e; O# u3 c% ^
    {
    / K6 s9 b  J2 {(*memory).p[poi].flag=computing;4 a% c: }6 L1 y. A: K
    (*memory).p[poi].ioNum--;1 @1 t1 Z- R: j" G4 u
    change += exchange_IO_Compute;# z" M( Y+ B6 W# T2 K
    waitio++;
    ' ?  a. `' ^+ j: z0 M}- O5 q3 r6 k9 s7 g* ^1 N1 u
    else- \4 ^4 F+ J, }2 C- W
    {
    $ n" Z- O. i( g. J+ w6 Gwaitio++;* v% G) O+ e1 S
    }
    2 `& p1 L# w# _8 J) q. L}
    , I4 S, `* Z- g: R  F2 b! Lelse if((* memory).p[poi].ioNum>0&&(* memory).p[poi].flag==computing), Y8 N( F: h& `- `9 H8 J
    {( M( G6 F, P  T
    (* memory).p[poi].flag=IO_waiting;8 |5 [! I6 n# X4 ]
    change += exchange_IO_Compute;( @* [- ?! B; a* X; S1 F
    }. z7 A- M9 ~0 ~. {
    else if((* memory).p[poi].computeNum>0&&(* memory).p[poi].flag==IO_waiting)
    0 l  t+ s! `2 v* ~8 q* _{
    1 ^1 @# T- h+ ?9 M) K(* memory).p[poi].flag=computing;5 m: P: g7 b; _) ~
    change += exchange_IO_Compute;/ X  [6 R/ c" `6 d
    }. h+ y8 b4 I+ j+ `2 ]& B# N
    for(i=0; i<(*memory).proNum; i++)  //其他等待io的进程可以并行推进, s5 F$ s) m  Y5 V7 k
    {
    2 S+ U& |0 A4 f# ?if(i!=poi && (*memory).p.flag==IO_waiting)8 l4 J8 v2 C/ k1 ?( E; h
    {
    % `* h1 O, o0 A( {+ `) hj=(*memory).p.ioNum;3 x. q) i$ G; Q* w0 R
    if(j>0)
    " c* m1 j$ P# E; [; C4 O/ {% T( d9 x{
    / w1 s! I( K3 h5 ?" P0 r& ], i3 sif(--((*memory).p.computeClock[j-1])<=0)// one compute tase is completed, T# U* g* `1 R' E) i
    {* N  i* N1 M0 j8 [) l
    (*memory).p.flag=computing;8 n$ }2 z' S* _0 A; ]4 `# b
    (*memory).p.ioNum--;. v8 Q9 D! q7 p" q& w% `' I% {
    change += exchange_IO_Compute;
    1 M  X  W& J) W) l}
    3 |* z( ^) s2 ~( K5 u2 v5 J) m}( K3 R/ }6 j. ^, k9 L( g8 n6 E. W
    }% ^# ^2 b, z7 P" g+ [2 j) U4 `
    }
    8 @( C# b$ I) Z  [/ Vfor(i=0; i<(*memory).proNum; i++)  //处理已经运行完毕的进程0 ]9 A/ A) e- K% [4 O5 k
    {
    & l9 I/ _5 w2 aif((*memory).p.ioNum <= 0 && (*memory).p.computeNum <= 0) // a task is completed
    % h# e1 x# j9 K{# I! t1 n( c7 M. x3 c! S
    (*save) = (PCI*)malloc(sizeof(PCI));& ?1 _1 I) T! f/ c! e/ y
    (*save)->next = NULL;( B4 [4 B8 q, i0 f$ O( n! v
           (*save)->processID = (*memory).p.processID;
    3 ]* W3 J+ A5 r" r(*save)->comeingTime = (*memory).p.produceTime;
    / k% i  Y. ^& ?" _) Y! a+ o(*save)->askMemory = (*memory).p.askMemory;
    7 u) f) b6 C- P) h6 j& i  ~(*save)->compute = compute;0 s. }8 l/ X1 J5 t. H9 x( Y6 l
    (*save)->waitio = waitio;
    4 A% |) Q- A$ I) n8 }" R4 i(*save)->exchange = change;; r/ `4 g4 h3 u+ {8 B2 a$ S
    (*save)->completedTime = systemClock-(*save)->comeingTime;. o5 I' D" q8 ?6 \6 v4 i2 H
    (*save)->runningTime = (*memory).p.runningTime;8 K4 T* g: G* q! z  f) g
    (*save)->completedTime = systemClock;- c" m5 z# \* Y/ T
    *spareMemory = *spareMemory + (*memory).p.askMemory;
    5 w3 A& y6 a* B8 J0 }  P9 m* Ccompute=waitio=change=0;# F1 j6 a% V/ U
    computeLast=waitioLast=changeLast=0;
    # I! ?; p6 C: Hif(TimeTurining_storage_to_memory(&(*storage),&(*memory),&(*spareMemory),i)==1) // 调入一个新进程进入
    6 V8 D) X4 |$ P/ |{
    1 w9 ]+ r4 {; W1 \7 u" uif(i==poi) //占用CPU的进程已经运行完,将时间片分给其他进程. G; ~. g" B' R8 Y( q- V* `
    {6 @7 K4 H( W) S; \( C. X$ n
    poi++;4 }; U& }, H; w
       clockSegment=2000;
    ; D9 i, D- B0 W$ z& T1 N+ r6 G}
    , }' w2 j$ K: B}! Z+ D  c* Z- A  k' [0 j8 U
    else  //没有足够内存调入新进程& M% N9 I3 p; c' b% n
    {$ e1 l" z& s1 Z
    if(i < (*memory).proNum-1)
    & K6 V0 d: {; z6 s. i4 u{% @7 @- J4 L7 [* e% Y3 S: V2 ?8 {
    for(j=i; j+1<(*memory).proNum; j++)
    ) @2 L3 `5 z& c6 G0 `{
    6 U7 f. U* F1 _  }' B' R$ K(*memory).p[j].askMemory = (*memory).p[j+1].askMemory;
    + ^, J5 E# Z3 R- C2 o' ?(*memory).p[j].comeingTime = (*memory).p[j+1].comeingTime;
    4 }! g" {! d) ?  v$ f5 k* k(*memory).p[j].computeNum = (*memory).p[j+1].computeNum;
    ) c3 I8 \9 [. m( \(*memory).p[j].ioNum = (*memory).p[j+1].ioNum;. O" l& n  G. u4 w* d
    (*memory).p[j].processID = (*memory).p[j+1].processID;
    - d, x& c" m+ k/ S2 v- G8 O. m" s(*memory).p[j].flag = (*memory).p[j+1].flag;
    & y8 i+ c$ w9 _3 ~5 ?- B% r(*memory).p[j].ioTime = (*memory).p[j+1].ioTime;" l2 _: q3 |: y7 q& |
    (*memory).p[j].computeTime = (*memory).p[j+1].computeTime;
    1 e) \5 U, o+ F- f' _4 p(*memory).p[j].runningTime = (*memory).p[j+1].runningTime;
    * q7 E/ o9 j! a, _(*memory).p[j].produceTime = (*memory).p[j+1].produceTime;
    # W3 j+ }5 U: a% D(*memory).p[j].completedTime = (*memory).p[j+1].completedTime;
    2 b# j* z; w4 `7 Mfor(k=0; k<(*memory).p[j].computeNum; k++)
    - I" B9 Z7 O$ Y; @9 S2 L, k$ ](*memory).p[j].computeClock[k] = (*memory).p[j+1].computeClock[k];
    ( {! R) z# B" G8 d" B: N# V1 zfor(k=0; k<(*memory).p[j].ioNum; k++)% q( R: L0 z9 |0 Y& o2 Q
    (*memory).p[j].ioClock[k] = (*memory).p[j+1].ioClock[k];( q$ }9 i' y6 [% x% u& _
    }( f8 j5 J0 N  \; e( w
    if(i<poi)4 X2 D) \  I' i7 s$ {
    poi--;$ @7 o+ b% y$ t3 V9 r
    else if(i==poi)9 u* @! e: x# D" ]* P3 G
    clockSegment=2000;
    - v: }+ S# l% I$ K' _3 G  j0 b}
    & d# {9 B" c% A: h) F9 x) Ii--;5 x* e( s3 i* i0 h! l5 P, ?
    (*memory).proNum--;* a+ t; y" J. [* {% N
    }! P: c9 }3 d) c- c9 f; {/ ~
    return task_completed;4 X- {( ^: Y/ A* |7 X
    }
    6 Y# [2 t: _; s5 ?) U* t}7 j7 L% _" D0 l( \* k4 w
    --clockSegment;, d+ p5 H+ q2 d, I8 r
    if(clockSegment<=0)$ F, H8 z+ i7 O' Y8 |- c) g% m# f5 n
    {; S( Y. `5 V8 j5 h' r/ e4 }
    poi=poi+1;$ P& r0 z! C+ A$ B- n; t
    if(poi>=(*memory).proNum)
    / X. u6 k$ l) \! {poi=0;5 ^% d7 _- G$ Z( @2 M2 m" z
    clockSegment=100;
    , j( H% ]" G& J% A: r}* W$ l) Z1 ]5 z3 J  w
    return task_not_completed;
    , C3 U7 H# y4 n2 A9 e( K! `}& G* n; w( [0 r0 n) I" K9 ^
    int TimeTurining_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory,int pos)
    8 E3 ?: H- a- h4 x- ~" D1 q4 ^{, Q- H4 h& F$ {  E2 s! M; N
    int i=0,j=0,k=0,flag=0,translation=0;8 C7 F& I( z8 ]. Q! P
    for(i=0; i<(*storage).proNum; i++)
    1 i4 t) E2 s3 t4 l% A% f' a{
    * a" [+ W% g4 o2 C' a8 V% Kif((*storage).p.comeingTime>MAX_COMING_TIME)
    3 |& M- q, S6 B0 SMAX_COMING_TIME = (*storage).p.comeingTime;
    4 p' \6 i9 L$ X2 a}
    9 K( U: E3 H- A( w2 |if(pos>=0)& z1 H% c: X4 R/ I  m2 w* E
    {
    # E& Y" x' G( P4 a% h% N1 |' W" h6 Ffor(i=0; i<(*storage).proNum; i++)
    9 z$ ]0 {3 u/ l9 N. z; A{1 t$ a9 v& M+ w
    if((*storage).p.askMemory <= *spareMemory)* W" m2 w8 I4 U$ L5 t) ^" P" r3 z* ?
    {
    . o+ S3 A* Q; @8 e1 D) O  n3 Xj=pos;. F& P- W$ s0 N2 L: w% D8 n6 K
    (*memory).p[j].askMemory = (*storage).p.askMemory;/ c1 ]* p7 X! _5 J& c
    (*memory).p[j].comeingTime = (*storage).p.comeingTime;
    + l6 f! a2 _- v! c(*memory).p[j].computeNum = (*storage).p.computeNum;
    2 {, \! z4 Q* W1 m7 c(*memory).p[j].ioNum = (*storage).p.ioNum;
    9 ^6 K" T- O2 `& E; s% u( I(*memory).p[j].processID = (*storage).p.processID;
    # \$ J* I7 [% s1 _% r; R  n(*memory).p[j].flag = (*storage).p.flag;
    $ w3 s* h- A% p% H7 c(*memory).p[j].ioTime = (*storage).p.ioTime;' s6 A- O( ~" R1 Z7 @
    (*memory).p[j].computeTime = (*storage).p.computeTime;# Z# }# k- C% o2 A4 A) m2 r) d
    (*memory).p[j].runningTime = systemClock;! p4 F/ T- E4 o% D& _9 o
    (*memory).p[j].produceTime = (*storage).p.produceTime;- \2 v, c# v: z( b& K: \
    for(k=0; k<(*memory).p[j].ioNum; k++)$ l* D8 |8 a! w' M4 E
    (*memory).p[j].ioClock[k] = (*storage).p.ioClock[k];6 A2 t" p& }( G' t! t2 P
    for(k=0; k<(*memory).p[j].computeNum; k++)
    / h! p/ t$ ^. H% L: O# [(*memory).p[j].computeClock[k] = (*storage).p.computeClock[k];$ n5 s4 S( o. L" U& W' D( Y
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;
      c1 \) o5 W0 [& u- Tproduce_one_task(storage,i,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程
    8 V) t& s9 w( P# Y, FMAX_COMING_TIME = (*storage).p.comeingTime;
    ( i7 p9 h% V/ N/ n7 Y3 a: Ttranslation=1;0 X2 e7 `2 J8 B1 a( B- X4 n
    break;4 d$ R  B1 B. S
    }  s8 W% W, |. K4 t
    }
    % L/ {) K: ?4 J; T* P0 O. O) x! ~}; T# C+ ~  |& H% h, m: S
    else
    & e. N* q  P# |9 y/ h% @) M, W{& ^- t- \1 D' i  w. o
    while(1)5 V' Y# T# F5 A, Z3 j! d
    {3 [1 ]8 V; d/ n7 `* p3 m
    flag=0;1 h( B( \! b- w: M5 J
    for(i=0; i<(*storage).proNum; i++)
    6 H- T& {8 I, o/ w7 z' @6 s{, `3 w; c5 x! p2 o% }
    if((*storage).p.askMemory <= *spareMemory)
    5 a1 o+ N6 `  z% h6 D- \{* D* q- q" f4 l$ f# P+ b: ~
    j=(*memory).proNum;5 u! U# K  F' k( _6 ~0 }4 B- v
    (*memory).p[j].askMemory = (*storage).p.askMemory;
    ( P' k2 n$ X4 M) |/ Z(*memory).p[j].comeingTime = (*storage).p.comeingTime;! \0 ^) u. b: S+ G3 w/ b8 e
    (*memory).p[j].computeNum = (*storage).p.computeNum;
    . g4 ]  P7 l! Q/ Y/ J(*memory).p[j].ioNum = (*storage).p.ioNum;
    , P$ y6 `+ W2 A( g(*memory).p[j].processID = (*storage).p.processID;
    ; G3 a/ h' m" D% Y- B6 M$ ^1 _(*memory).p[j].flag = (*storage).p.flag;3 }6 ^$ W& k9 G" P1 u9 j
    (*memory).p[j].ioTime = (*storage).p.ioTime;# c6 m6 ^* O/ n
    (*memory).p[j].computeTime = (*storage).p.computeTime;
      s% H# i! L+ _% e8 \7 q# o(*memory).p[j].runningTime = systemClock;; }! H( C8 I! M  F
    (*memory).p[j].produceTime = (*storage).p.produceTime;
    - T9 J% h, \+ O' J# o- ?for(k=0; k<(*memory).p[j].ioNum; k++)
    * F9 O/ |3 F7 g4 r2 Q; g4 X(*memory).p[j].ioClock[k] = (*storage).p.ioClock[k];
    , V: c9 T* E/ Sfor(k=0; k<(*memory).p[j].computeNum; k++); r, y5 t/ G$ i% @
    (*memory).p[j].computeClock[k] = (*storage).p.computeClock[k];. J8 }1 Q4 ^, ^1 Q9 i: ~" J
    (*memory).proNum++;
    , g5 U  n/ Y; ~9 m2 y* @3 V*spareMemory = *spareMemory - (*memory).p[j].askMemory;5 n; _+ O( i: k! b9 a7 a9 N
    produce_one_task(&(*storage),i,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程( S; b. e/ o6 `+ p% O
    MAX_COMING_TIME = (*storage).p.comeingTime;1 _' |: B) [3 @) v0 d: ^
    flag=1;
    + b! n- v  R4 Z9 C  x5 }  Etranslation=1;
    2 }- t* R/ {9 i6 X}: t$ _6 \' x& d0 Y/ I0 J# i
    }3 z/ u, h9 @. k  M& X+ i
    if(flag == 0)
    $ Y, N4 @" A: Y% F" ?* Z" s5 jbreak;
    6 F5 K+ X# X+ j( }7 c}
    & w3 e3 g2 N* ]) T8 W. j8 B: W}4 ]; f% Q# ?  s4 w  F1 Y. U* G$ D) t
    return translation;. `! o  S6 B# T* J, o
    }
    $ ~7 S7 L$ o1 A& }# y$ dint FIFO(processPool *storage,processPool* memory,int * spareMemory,PCI ** save,int draw)
    . _" x2 W0 s, L$ ^. K1 q{! t$ g: @5 [$ J  q# i4 F
    static int compute=0,waitio=0,change=0,flag=0,flagiocpt=0;& N  v4 z6 w  P8 |4 {
    static int computeLast=0,waitioLast=0,changeLast=0;1 L9 D/ {- l+ ~2 `; c8 B. u$ S
    int i=0;7 \7 z6 ~; N6 e8 G
    if(draw==1)
    , g2 E+ j7 Q2 U{1 p- K6 Y& Y$ f- R
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    7 b, Q) g) ?5 Y$ X+ @drawPerformance_FIFO(0,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);; H- |7 w& j8 z7 `
    , p7 {0 X% q; |- Y& E3 F) e' s

    0 Q' J# Z7 `$ C) bcomputeLast=compute;, f/ J2 f7 A6 l8 \
    waitioLast=waitio;
    ' C( k5 ?& |7 H& }- ^. C- ?changeLast=change;
    1 t9 M' V7 H; p# p; Q- o" }! E}
    6 [( \. K% a8 M% Mif(flag==1)  
    % c4 \9 x7 {' O) ?2 P{- O# J+ E: }+ R; s5 x2 w
    if((*memory).p[0].ioNum>0||(*memory).p[0].computeNum>0)  //task is not completed
    " I' |4 m0 T" B7 @3 L& @* T{
    * d# e- ^8 c4 ?+ y  Cif(flagiocpt==0)   // implement compute
    ! M; t" s4 R+ n/ z4 Q% @( f5 p4 ~2 Z{
    : O( e* g7 r/ W9 ni=(*memory).p[0].computeNum;! R0 f+ r+ f! n% d6 B! g. ~- z3 {
    if(i>0 && (*memory).p[0].computeClock[i-1]>0)5 P' ?  g; L. l! h& A
    {
    7 D3 r7 t, S+ ~$ X* \, b  cif(--((*memory).p[0].computeClock[i-1])<=0)// ome compute tase is completed
    ) y+ o0 b, H# }{$ O7 H/ q& `+ {9 ]! u
    flagiocpt = 1;
    6 e3 Q3 I2 f, t7 B. i  u(*memory).p[0].computeNum--;
    / D5 H3 F  F% h+ c% gchange += exchange_IO_Compute;
    : q; I) q. p2 O. kcompute++;+ n4 u  X0 p3 m5 e& r& g/ T
    }6 g9 ^& z' s. S% t; @. U9 ^  N
    else
    9 f  W0 x5 W1 ccompute++;
    ) x$ s9 ]! m7 M
    9 R% E( x5 g" r7 I" c1 ?6 q}- R6 z" M* r) |9 a! b/ {
    else3 s( H* Y7 l* }
    flagiocpt = 1;
    4 Z* P% P9 F+ R9 c' l}
    ) E1 I; [: K: celse  //wait io! ~0 x7 y3 j1 y, h, B/ F' O# ^
    {& |( Q' M2 i; L0 v5 J
    i=(*memory).p[0].ioNum;
    & ]+ a6 ^, s9 T7 ?  _' Zif(i>0 && (*memory).p[0].ioClock[i-1]>0)# ^* h  ]) e& i" d5 C! W4 @
    {
    1 M6 H2 |3 Y% sif(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed
    ) Z1 M7 I0 y7 i1 L{
    3 b' q& u6 y; U) U" Vflagiocpt = 0;
      x  u$ q. h* m9 N8 |# S' f, C1 k(*memory).p[0].ioNum--;
    1 ^+ F5 v. z% I. D& a+ V0 r& Ochange += exchange_IO_Compute;) N; A9 \4 r7 X# ^
    waitio++;, [* |8 O# m2 t3 j' ]
    }, c1 W- j$ V3 J" n  b
    else
    / T% A, y, o+ c- I2 A6 N1 Vwaitio++;1 N, G% w5 O. p9 |

    + u* n; q* f0 P+ }* a  D}0 s1 e. Y- \6 t2 K+ [8 P
    else3 j1 `; z, K, @7 ~" T0 I
    flagiocpt = 0;! q3 j1 u3 u( b# Y
    }# ?7 i5 n! x3 K
    }) J$ L( d2 H( D* }9 d; J$ A/ i
    else  //task is completed5 c; r! c$ N5 D- u
    {
      R: x" \# y1 k$ w5 e" \4 ~) U9 r1 {(*save) = (PCI*)malloc(sizeof(PCI));
    / g' n7 E. O3 K(*save)->next = NULL;8 v! F' N& T" [
           (*save)->processID = (*memory).p[0].processID;/ k* ?$ \+ t4 t9 }/ u7 j
    (*save)->comeingTime = (*memory).p[0].produceTime;
    ( M- }% _6 v4 `0 |) M3 I(*save)->askMemory = (*memory).p[0].askMemory;9 j1 k3 K  X; v6 T: `
    (*save)->compute = compute;
    9 K" ~# \& b  S( s7 s. y! n(*save)->waitio = waitio;, M: {7 @( z: N4 u" d
    (*save)->exchange = change;6 P! O  a8 Y: O7 y+ C3 N7 F
    (*save)->completedTime = systemClock-(*save)->comeingTime;! I& a3 T  v* `
    (*save)->runningTime = (*memory).p[0].runningTime;3 P) F% Z) U" z3 e% l; f9 c
    (*save)->completedTime = systemClock;2 _" |; l# l5 Y" a0 ?# A& _( \
    //*spareMemory = MAX_MEMORY;4 }7 o' l0 \2 \, k# d: [5 `
    free((*memory).p[0].ioClock);
    ! l  Z# Y& x0 o7 ofree((*memory).p[0].computeClock);2 S$ I; u2 X; f% ~+ g9 q; o6 Y. y
    free((*memory).p);
    + t1 w9 T. w; ]( S0 W- `+ Fflag=0;
    ' K3 [& K9 Y$ M5 V- ocompute=waitio=change=0;; E( d0 `' {  C$ g
    computeLast=waitioLast=changeLast=0;. S3 @0 q3 w0 s1 e8 v
    return task_completed;$ M' z( Q7 H# {2 d0 T2 n6 b
    }! a$ E9 |) _, m5 a* i
    }* G+ u: Z4 h" y6 \1 U  w8 k  y
    else         ; t5 r, s4 n& Z: G1 o8 R
    {7 f6 Z& I; T7 Y  v, }
    FIFO_storage_to_memory(&(*storage),&(*memory),&(*spareMemory));6 {- I3 A. g- q# K0 _6 D; p( |
    change += exchange_process;9 @& H, {# U9 R  o
    //*spareMemory -= (*memory).p[0].askMemory;) a  L8 ~2 k0 \5 A
    flag=1;) Q* @* @) P' n; w& L
    //showProcessInf(*memory);$ B$ b+ s) J5 Q& ]8 J
    return task_not_completed;. K0 g, d' j: ^6 ^) S& r# Y
    }- A+ W! i9 j' i8 T; L
    return task_not_completed;
    0 O  _1 d6 v* Q% E8 S}5 z1 f( m( V3 {. ]" J, c
    int FIFO_storage_to_memory(processPool *storage,processPool* memory,int * spareMemory)2 z5 W) c. n9 I/ y
    {& ]# l% A! m% Y% U( h4 j
    int i=0,j=0,k=0;
    , y2 ~0 P) f* S* Y% u  ]7 j( Y3 YMAX_COMING_TIME = (*storage).p[initProcessNum-1].comeingTime;# y, q3 x) [" c" C( `
    (*memory).p = (process*)malloc(initProcessNum*sizeof(process));; a; v1 p3 L) l0 o$ M% y
    memory->proNum = 1;
    . i8 {% J' |% l  Jfor(i=0; i<initProcessNum; i++)
    1 h( ~' q% q) l+ `1 d# ^{" g9 g1 G7 H  l
    if((*storage).p.askMemory <= *spareMemory)
    & ^9 q$ _+ M% c) l+ z" S6 P{) @+ ~; G  e! V- k" g- G  B0 G# v7 P* g
    (*memory).p[0].askMemory = (*storage).p.askMemory;% d, h# X* R: I8 A
    (*memory).p[0].comeingTime = (*storage).p.comeingTime;/ I; J% c3 Z: w4 m  m7 D  y
    (*memory).p[0].computeNum = (*storage).p.computeNum;6 B$ y, u- n3 |) X: o& k9 D1 g
    (*memory).p[0].ioNum = (*storage).p.ioNum;  F7 T0 W! {0 x0 o  Q2 G2 m9 n/ Y
    (*memory).p[0].processID = (*storage).p.processID;+ e! t: U9 A7 t- }4 t; L2 B6 O
    (*memory).p[0].flag = (*storage).p.flag;/ T& C7 o2 I$ q/ D4 v
    (*memory).p[0].ioTime = (*storage).p.ioTime;
    : U0 `. p; m( e3 }$ D3 K(*memory).p[0].computeTime = (*storage).p.computeTime;/ H3 W) H* W. H
    (*memory).p[0].produceTime = (*storage).p.produceTime;
    ) \. [, D* w- ?! r# N(*memory).p[0].runningTime = systemClock;
    5 E0 ~/ P3 Z4 I2 L+ r0 S(*memory).p[0].computeClock = (int*)malloc((*memory).p[0].computeNum*sizeof(int));( p7 B3 q9 b1 g  n) c1 Z
    (*memory).p[0].ioClock = (int*)malloc((*memory).p[0].ioNum*sizeof(int));0 Q  z; O  Q! K) v. Q: _; A# I
    for(k=0; k<(*memory).p[0].ioNum; k++)( Z6 u9 n  U, X5 W/ |* u2 X+ x2 ]
    (*memory).p[0].ioClock[k] = (*storage).p.ioClock[k];
    $ h. V  G1 i4 c/ M. d5 f; kfor(k=0; k<(*memory).p[0].computeNum; k++)$ ?& X  i- v. z7 `# `
    (*memory).p[0].computeClock[k] = (*storage).p.computeClock[k];
    . q8 p  u5 |" ~* Nbreak;
    + ?) ]9 w( N: L/ L3 L}6 ]9 l; w6 p) f" x, b
    }. s" u: c, |7 C: S8 Z
    if(i<initProcessNum)  //调用一个作业进入内存后,并再生成一个作业等待调入8 N9 Q: }! A, j3 g, h
    {( o) M* P/ T  S( ]# `8 {9 n
    produce_one_task(storage,i,ID_FIFO++);' C2 A' M- X" s
    MAX_COMING_TIME = (*storage).p.comeingTime;  G0 V/ j- w" f3 `$ y4 X* W
    sort_by_comingtime(storage,i);/ {/ y7 o1 Z" }. `
    }
    - k7 E' o+ D8 g6 i+ p$ s$ b. _# jreturn 0;. A) B, g% x7 ?: `
    }  w8 w9 l4 ^. f" `7 c& ^6 b
    int sort_by_comingtime(processPool * p,int pos)
    $ v- V- [( y6 q% q9 I, g{. d# J& R# s7 T3 B
    int i=0,j=0;/ a7 E2 [0 o2 l# ?$ A
    process temp;
    ' R$ n) q( `0 R, ], L+ g4 Eif(pos<0)2 z9 t4 o; M! x9 J
    {7 Z" F6 b% i/ x: |& u: k# s( @
    for(i=0; i<initProcessNum; i++)
    ! e3 F1 R; m' r& Sfor(j=0; j+1<initProcessNum-i; j++). [- W( i' O6 C0 M/ s, s
    {: Z# l4 n  O! o' k9 W: M' g; q& N
    if((*p).p[j].comeingTime>(*p).p[j+1].comeingTime)4 F& P' V$ R2 O; m
    {  E( I$ T9 \0 U( h7 W; `( o
    temp = (*p).p[j];9 u$ \" f6 e# K* W; m8 o/ V. x
    (*p).p[j] = (*p).p[j+1];
    ' E" [+ X+ _3 g. q# j& Z3 U3 m(*p).p[j+1] = temp;
    ) K  a' M0 M1 U+ f; |}
    ( w) a8 q; \9 y+ a}
    % k$ N/ Z/ A2 Y+ T. }}
      @, p2 }1 V: w5 w8 J: W0 H' gelse if(pos<initProcessNum); |" z& q2 c5 @6 M& U2 A
    {( v5 H) J# J2 C; ^( p/ E! H
    for(i=pos-1; i>=0 && (*p).p.comeingTime > (*p).p[i+1].comeingTime; i--)+ {+ }; E) h1 k6 k, C. B, j
    {
    ! S0 r3 N! q4 o7 Atemp = (*p).p;/ v- l, ~- p- b8 Z0 o! |5 e
    (*p).p = (*p).p[i+1];3 Y7 g" `* C- K+ k4 j
    (*p).p[i+1] = temp;% v5 R% p3 m5 x; d7 g
    }
    3 n3 [  l9 Q. l/ ]for(i=pos+1; i<initProcessNum && (*p).p[i-1].comeingTime > (*p).p.comeingTime; i++)
    # b- H5 h- W( I: t9 U$ a4 E{$ s9 |$ w( b& }# p& m% W" @
    temp = (*p).p[i-1];$ _/ |$ ~( \+ e$ I% v8 [
    (*p).p[i-1] = (*p).p;' x% ^) X! B& k6 A
    (*p).p = temp;5 ^3 {5 ^* a1 y$ [: Y8 {" ]3 |
    }! X+ x& {3 p+ e% |
    }; U# A( r( i+ S+ V: m& e( t
    else
    3 a; e4 y+ a; r( Q9 Zprintf("position eror\n");
    + w& \' m# V) y8 _* u% Hreturn 0;' Z+ S3 [# n& \
    }, u1 M1 l7 U+ Y1 @) b, E* ^/ [9 c
    int InitPool(processPool * p)
      ^6 ]0 x$ |2 w4 p1 d" d{" N- F* j8 i0 G: A
    int i=0;" z, J7 t) w6 b. t, h3 R' [; g
    (*p).proNum = initProcessNum;4 w* h/ S( s' y9 W6 d
    (*p).p = (process*)malloc(initProcessNum*sizeof(process));- B3 v. s: l/ b
    for(i=0; i<initProcessNum; i++)                                        //init process information2 Z% O4 J, s  O3 o
    {1 r- n. V* U& z9 `0 x0 d
    (*p).p.computeClock = (int*)malloc(initclocknum*sizeof(int));
    3 N0 s6 D# d) \" ~& |: o(*p).p.ioClock = (int*)malloc(initclocknum*sizeof(int));
    ( ~6 f0 {" J* @# a0 O& _3 xproduce_one_task(&(*p),i,ID_FIFO++);
    : ~2 x" W! P9 c& s# I+ I}2 U8 [- m8 V6 ?8 [' B- C+ C  K
    return 0;3 R8 e8 O' s+ g' o$ g& {
    }. i: ^7 Q2 q9 G- Z: Y( w
    int produce_one_task(processPool * p,int i,int id)
    0 C! o/ H; k/ X{
    1 K- S% }1 l& R% jint time=MAX_COMING_TIME,j=0,totallTime=0;
    ( [' j. d  T9 ~1 c8 ^1 W8 q9 |(*p).p.processID = initProcessID+id;           1 D' Q1 S$ x8 l, @% D5 ~3 [
    (*p).p.comeingTime = time+rand()%(MAXProcessRunTime/5);# C2 r0 n( _. ]% m0 z# Y
    (*p).p.produceTime = systemClock;2 Q9 Q! ~" n+ R
    (*p).p.ioNum = rand()%4+20;                                        //IO number setting to 2--5;2 G2 E9 C1 T6 V& o: k  Y- V; Y) d
    (*p).p.computeNum = rand()%4+30;                                   //computNum setting to 3--6;
    . }. k4 ]- ~/ I$ M4 qtotallTime = (*p).p.computeNum  + (*p).p.ioNum;
    $ @" r  A4 t9 g# }3 M/ d(*p).p.computeTime=0;5 V5 r( |6 Q  H; z; ~- @( S& o7 M
    for(j=0; j<(*p).p.computeNum; j++)
    4 j! p3 q8 _5 h+ e' w{4 U0 Y/ r) ^9 |# J
    (*p).p.computeClock[j]=rand()%(MAXProcessRunTime/totallTime)+1;' D. B, r, x3 f: ?5 ~
    (*p).p.computeTime += (*p).p.computeClock[j];
    ' R/ D- m+ Q8 h* }1 G}
    7 v' C' T1 {0 K5 G6 B(*p).p.ioTime=0;+ ~, z- S; ^8 |" h) d) ?5 c6 e
    for(j=0; j<(*p).p.ioNum; j++)
    8 Q+ E  Z7 v* A) `{' G4 M  U1 M' `5 q. y
    (*p).p.ioClock[j]=rand()%(MAXProcessRunTime/totallTime)+1;& B* D; h% X( k* p4 H6 h
    (*p).p.ioTime += (*p).p.ioClock[j];# Q, X" J8 C6 A- ?6 i- M- _+ c/ h9 Q
    }# p& F8 \  e- b7 D! b6 E& U
    (*p).p.askMemory = rand()%(MAX_MEMORY/4);
    : B- f7 o$ d# f3 B5 k* W(*p).p.flag = ready;& T- i6 E. i4 @- e) t
    return 0;# J# O' H' g' Q: q, R2 j" y; }
    }
    5 B: m9 g: L" N% rint showProcessInf(processPool p)
    % ^- s+ ?2 ~3 y{
    $ d5 m. y( l5 p4 g3 j# hint i=0,j=0;7 N5 [& _8 K  _  S5 p$ @8 o2 B
    for(i=0;i<p.proNum;i++); m1 M. Q/ g: |6 ]# `
    {
    " s, V8 z/ a1 ?/ t$ v( Bprintf("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( g0 u2 e3 V& p
    ,p.p.askMemory);+ E* P2 T! A- I  Y0 P% W/ v
    for(j=0;j<p.p.ioNum;j++)! z, [+ K& N/ d3 K5 [/ y/ h$ S$ P
    {
    * N9 B" ?) ?$ z4 T5 f$ w" R$ cprintf("%d ",p.p.ioClock[j]);
    7 J7 H, u0 D, ?; {) Y- Z}
    5 H+ ]2 O0 |' l6 Tprintf("\n");
    ; c9 V- v* ]8 e+ E. w, ifor( j=0;j<p.p.computeNum;j++)
    0 p" u( t, Z% E  C{
    ) z  C/ Y1 k; O8 m9 ?0 {* {) o  q. mprintf("%d ",p.p.computeClock[j]);
    $ ^1 Z7 }; B5 c! A8 ?* J$ i}
    2 p6 p8 Y1 W) T9 C2 ^- q# Z/ ]printf("\n");& R) y) L+ d7 X/ z
    }8 j6 m) m+ X4 m1 M; B2 \& V9 }
    return 0;
    " J+ U: M; o  z% U9 d- u7 E% j}% P* _& c* R- G* ~+ ~$ U
    ————————————————: ^* U' p( S: ^& W* W5 D
    版权声明:本文为CSDN博主「wang_dong001」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    8 P. O7 x- f" U* O( n原文链接:https://blog.csdn.net/wang_dong001/article/details/47843519% m: l) }" S7 i" X- [! i0 q
    2 [1 u# [9 Q, t8 t5 s8 @

    ( c$ b/ q) o" }
    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-7-24 22:35 , Processed in 0.456293 second(s), 51 queries .

    回顶部