QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2531|回复: 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

    $ _$ H" m9 `. z4 r( S经典任务调度算法的模拟程序( j1 H0 ~# C3 b8 R
    本科毕业设计写了一个经典任务调度算法的模拟仿真程序,测试了五种调度算法的运行性能。在程序中虚拟了任务的进程,按照不同调度算法策略从进程池中选取任务执行,在任务执行过程中,保存相关的统计参数,最后对这些参数进行处理,反映各个调度算法的实际运行性能,程序中可以通过修改任务的相关参数改变任务特点,测试不同任务环境情况下,调度算法的性能适应性。程序是通过C语言编写的,为了对运行结果图像化,采用了EasyX的图形库。由于计算机中实的任务调度过程比较复杂,在实验中为了简化程序的实现,在某些方面进行了特殊处理。' v# @# V0 S2 }2 X9 G8 K
      Q0 K1 h: Z: Q0 Z
    编程平台:VC6.0+EasyX图形库环境。4 X: x, c, D9 H8 I6 D/ m
    ' X& S7 _  }0 C6 K( Q; L
    以下截取部分程序运行图::
      k: a, R. j! V+ h4 Y, d4 a
    2 {" ^  l. l# O# ^$ x源代码:
    % X. j8 U# _7 G! R
    / S9 s6 `4 U9 s9 O5 K#include<stdio.h>2 T8 l5 o0 m* N8 f. e( E  @
    #include<stdlib.h>+ H! T2 I# l7 d  R4 o
    #include<easyx.h>
    6 ^$ w$ f9 I# l5 I. c#include<time.h>
    ' t0 c% \$ k+ U) x( n#include<conio.h>
    , G6 D: Z8 ^$ m% L2 f#include<graphics.h>
    % r6 E+ O1 ]5 H6 g- r1 o#define initProcessNum 10# N. [: u5 f7 i  Q
    #define initProcessID 10006 D9 J: q8 Z) L4 E3 ^1 j
    #define MAXProcessRunTime 10000) y, d% r) ?/ I& p& M- A4 ?2 d
    #define MAX_MEMORY  4000( o3 _$ m1 J) s6 p, H
    #define exchange_IO_Compute 10% {- k2 I9 X9 u$ G
    #define exchange_process 25
    + D- @8 o& Y- z/ U#define task_completed 1
    ! @8 D7 b1 O" [% M4 [. N8 b/ y#define task_not_completed 0
      I6 S6 H$ t& C$ z" y6 o% L#define initclocknum 1008 d) O3 {3 ?/ e+ f- G* |  W7 c
    enum condition
    ( n7 e6 B1 c. S* M: e! U{
    1 [" u9 Z. _3 \" d( {dead,computing,IO_waiting,ready3 {  e; O6 n) Q( [4 g9 I0 u6 ?( R
    };
    7 v! R$ E# N) G: Tstruct process9 i* z/ U4 W- I, k8 K2 y; E0 M
    {) D9 w7 N9 a8 v0 P* B
    int processID;
    % q$ `! A# e" Y* Zint comeingTime;2 K" [" Q; R$ x1 s; F5 R
    int ioNum;
    * ^8 t( Y% N/ T* |* W# Uint computeNum;2 M/ t5 v# O3 A( x8 c/ R
    int * ioClock;4 W) K( d! l7 y
    int * computeClock;/ m# u# R  L+ p% M
    int ioTime;0 ~4 |; [& D# l- Y  S$ V
    int computeTime;  l0 g: B# A" Y6 }; x7 h
    int askMemory;4 q* g' T, L2 @  ]7 h
    condition flag;, @6 c: H" c( |' Y% }
    int produceTime;  //生成时间,以下三个数据成员用以计算相关性能
    1 b( X3 i7 E4 w' k7 lint runningTime;  //第一次占用CPU的时间
    6 o* [& M& E" Z% @4 y0 iint completedTime; //进程完成时的时间
    ! K9 p6 E1 X2 }" Q- \6 H4 _+ m' Z9 g};* H' U# m3 ]& x4 m$ n6 j  f" v) R
    typedef struct processCmpletedInfo  //保存完成一个作业的相关信息
    + I* Y: R5 {3 d{
    : f. S3 j8 x7 [+ y6 j, I# Oint processID,comeingTime,askMemory;  T2 T1 f# |) X& v
    int compute,waitio,exchange,completedTime,runningTime;
    ) J8 V7 w6 s; h7 n3 {processCmpletedInfo * next;
    6 L* G/ Q; a/ |& W5 \1 u& R}PCI;
    - _! B( U; M# ?struct processPool
    " b$ z/ C' a, _9 i{
    1 N' ~7 K4 |- E$ u- {process * p;
    / @/ K5 \% ]1 T, _- @5 o( Aint proNum;( D& q$ r# ?1 y% K8 ?3 x
    };  A3 F8 z1 B3 X& ^/ [- }
    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;& S' N( N; _2 R4 Q
    int InitPool(processPool * p);) N/ O' ~  G  F4 P0 b2 O2 q
    int produce_one_task(processPool * p,int i,int id);
    - ]& e& w* x0 nint FIFO(processPool *storage,processPool* memory,int * spareMemory,PCI ** save,int draw);
    ! q$ y0 b. j* K+ dint TimeTurning(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    * [* c* _* |' d) B- ~' U( q# f9 Aint TimeTurining_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory,int pos);
    0 C8 N( K( w  W- a* rint FIFO_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);
    ! t2 s8 r$ L" Tint ShortJobFirst(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    ; ]: }. W: b$ I8 Pint SJF_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);
    1 S1 \& k$ l. h1 F( D" M& }int PriorityDispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);7 m3 z: a5 [8 K  F' {
    int Priority_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory);
    : Y6 p  j9 f. g) W6 f6 y1 n! qint High_response_ratio_s_to_m(processPool *storage,processPool* memory,int *spareMemory,int flag,int disatch);4 [  l- V% s4 N9 w1 _% c
    int High_response_ratio_dispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw);
    + _7 u3 Y7 P* ~) A9 u! b  m9 G3 q% f

    ( v+ a7 X5 \1 b2 ?) oint sort_by_comingtime(processPool * p,int pos);- q* Y4 y* |/ e1 H
    int showProcessInf(processPool p);
    0 x2 G2 E% k4 f' |' Gint drawPerformance_FIFO(int x,int y,int memorry);  t# J, C# y/ S6 G
    int drawPerformance_HR(int x,int y,int memorry);5 P  J' \% J" V) ]
    int drawPerformance_PF(int x,int y,int memorry);
    9 ?5 l6 m, Q$ i! @, J" ~4 P; |4 Wint drawPerformance_TT(int x,int y,int memorry);
      @& z4 k7 q% b8 S- h7 R% M9 Cint drawPerformance_SJF(int x,int y,int memorry);2 f' P/ p% e. k; @0 ~3 ~2 q
    int MouseListening();
    ! a+ Y& [; T2 q3 U& G8 ]int MouseListening2(int *flagShow,int * showTime);8 X: H/ z- E1 J5 ?& g2 p1 I5 y! T7 B# @
    int showRunningResult(PCI* FIFO,PCI * timet,PCI * SJF,PCI* PR,PCI* HR);6 `# x( p4 N* g4 b& A
    ; F" [/ a% b# j9 {/ g( {. L' D

    3 }; R' n! N! ~% `) A, A" y" M0 Xvoid main()
    - I3 y7 ~% S4 y" T1 B5 O{5 o5 J# ^4 F4 C. ^5 D
    PCI* FIFO_save_head=NULL,** FIFO_pri=NULL,* Timet_save_head=NULL,** Timet_pri=NULL,* SJF_save_head=NULL,** SJF_pri=NULL,
    ' _( L* K3 n0 ~*Priority_save_head=NULL,** Priority_pri=NULL,*HR_save_head=NULL,** HR_pri=NULL,* p;
    * f' i3 {& }+ o, p1 _! o" a( ^int i=0,FIFO_memory=MAX_MEMORY,count=0,Timet_memory=MAX_MEMORY,SJF_memory=MAX_MEMORY,Priority_memory=MAX_MEMORY,HR_memory=MAX_MEMORY,
    3 }0 K' _. N7 k9 J! oflagDraw=0,showTime=100000;* s! B1 d7 a- d
    processPool FIFO_p, FIFO_mmy,Timeturn_p,Timeturn_mmy,SJF_p,SJF_mmy,Priority_p,Priority_mmy,HR_p,HR_mmy;
    9 c* t1 J! V# G) P" EFILE *fp=NULL;
    % r" i* z3 l8 T& S4 l2 r) R4 h//processPool HR_p,HR_mmy;
    - B* Y& R, X! o4 l  }! c8 ^1 ?+ I; b) r, x# q

    6 _! Y/ f  F* M9 L5 e0 h4 msrand((unsigned)time(0));
    ) X# V# {6 ^' h$ L# ]systemClock=0;5 j3 Z2 K: {, B& U
    initgraph( 1200,650,SHOWCONSOLE );! o3 X2 w% s8 v: c# ]3 a" K
    settextcolor(GREEN);/ A/ K& Z% }, }2 g0 ~, e9 X/ b0 n
    setlinecolor(GREEN);
    8 C3 ]8 y4 V" ssetfillcolor(GREEN);) Q1 z1 n) Y& U: t8 D. G
    InitPool(&FIFO_p);4 ~  r  ~& a+ ^. t7 b
    sort_by_comingtime(&FIFO_p,-1);3 ]! ~+ k$ G  i
    InitPool(&Timeturn_p);
    9 Q$ n* `. t& q2 C  Y( HInitPool(&SJF_p);( N  J' K6 ^1 ~- O0 P
    InitPool(&Priority_p);
    7 M# k+ m# j" G; {0 W; s/ G. @InitPool(&HR_p);- D+ U% ~$ [' U, k% r0 y$ a# \
    //showRunningResult(FIFO_save_head,Timet_save_head,SJF_save_head,Priority_save_head,HR_save_head);
    9 s" I4 B+ C% h/ o7 b) b5 H//Sleep(10000);
    , f. x$ x+ k3 x0 u
    0 z2 L. Z0 l+ j7 v- J! {- I) W! M) d9 V/ F  Y4 z
    Timeturn_mmy.p = (process*)malloc(initProcessNum*sizeof(process));
    ) Q) P0 F. M/ ]3 Z( O3 D; tSJF_mmy.p = (process*)malloc(initProcessNum*sizeof(process));4 f/ g& A$ v8 w  `
    Priority_mmy.p = (process*)malloc(initProcessNum*sizeof(process));8 x6 F: o' o2 _" _0 D
    HR_mmy.p = (process*)malloc(initProcessNum*sizeof(process));7 Z# ?( a3 r/ Q- @7 Y* d
    for(i=0; i<initProcessNum ;i++)6 k4 s6 g( g% h3 e/ k. ]
    {: [6 F9 t/ f. e, F1 W
    Timeturn_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));( O& z# \, I/ a0 b$ z0 j
    Timeturn_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));
    / |$ c: Q2 x' D) eSJF_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));
    - h( t$ C# O* n. Q$ ^SJF_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));4 q8 b9 N4 K# H% E
    Priority_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));
    3 Y0 o4 E; n7 A) E1 kPriority_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));
    0 c" o/ t) A# J' U2 ^* wHR_mmy.p.ioClock= (int*)malloc(initclocknum*sizeof(int));$ |6 }  X1 E& g. b2 w
    HR_mmy.p.computeClock= (int*)malloc(initclocknum*sizeof(int));
    + P' G/ @0 i/ I/ U6 [1 e5 k}4 k( O1 b7 t3 J, Z$ _
    Timeturn_mmy.proNum = 0;
    * x& L4 o  ?# X8 Y8 mTimeTurining_storage_to_memory(&Timeturn_p,&Timeturn_mmy,&Timet_memory,-1);1 y& X4 {! h9 U6 A: Q
    SJF_storage_to_memory(&SJF_p,&SJF_mmy,&SJF_memory);0 `3 t) S+ K! t& i5 H
    Priority_storage_to_memory(&Priority_p,&Priority_mmy,&Priority_memory);% v2 Q: x  `0 o/ D7 c8 D4 U+ p
    High_response_ratio_s_to_m(&HR_p,&HR_mmy,&HR_memory,0,1);
    ! c4 W; P; ?! T+ e6 U: ^: I& Z//showProcessInf(Timeturn_mmy);7 J4 c* E/ p/ B, p6 n
    FIFO_pri = &FIFO_save_head;$ W8 v+ ^% M) W
    Timet_pri = &Timet_save_head;# ]3 _) T# N5 W; ?! Q5 g
    SJF_pri = &SJF_save_head;& k& t% H* |  D1 z5 `. y, m
    Priority_pri = &Priority_save_head;" p/ x- p) y% Y/ v- s
        HR_pri = &HR_save_head;( J) H/ k+ s6 b% h. O. Z
    setbkcolor(WHITE);0 v! L0 v9 }5 B1 u
    while(1)% M# L7 O& }1 J7 Q  o/ [
    {
    & {/ N2 H0 k) c+ H6 ]8 x' `if(MouseListening()==1)  W: Y" h# n& U0 @# Y7 L
    flagDraw=1;3 @$ g8 B3 g- J9 W! U+ ?
    if(count==100); T" d) I# G& \; E
    {! m2 o) |1 c! f  w4 e
    if(FIFO(&FIFO_p,&FIFO_mmy,&FIFO_memory,FIFO_pri,1)==task_completed)
    3 q: _5 r+ {5 d" j: F6 ^! K# G{# h7 X) v& b0 C. J3 S3 [
    FIFO_pri = &((*FIFO_pri)->next);
    3 j/ \7 C" J' K+ t1 J+ w: b
      ~* c1 k2 [3 i; \; Q# R( b! d//printf("hello");' |+ e2 n+ s/ q2 B! ~  l
    }" L$ {6 G( J8 b; K( {( l& c2 B2 [9 t
    if(TimeTurning(&Timeturn_p,&Timeturn_mmy,&Timet_memory,Timet_pri,1)==task_completed)
    / K" S% l5 ?; @7 n{6 c; {# x3 w5 l; c; h4 f
        Timet_pri = &((*Timet_pri)->next);1 M" P+ l" }. X1 Y9 \' y
    //printf("hello");: g) E8 w# z/ |& `
    }
    & b0 ]4 r) c& P; a$ g! Gif(ShortJobFirst(&SJF_p,&SJF_mmy,&SJF_memory,SJF_pri,1)==task_completed)% ]( H5 \  ]9 e' }2 N9 I5 V+ P
    {$ j0 Q, w) i) W9 [- w7 J
    SJF_pri = &((*SJF_pri)->next);
    ! o5 t% `/ D% A( V8 |# P5 ]//printf("hello\n");
    ; R0 o% o3 m. o' n5 S}( S! S) Y3 X9 J+ j( l8 l
    if(PriorityDispatch(&Priority_p,&Priority_mmy,&Priority_memory,Priority_pri,1)==task_completed)
    0 s* K7 K  R; r  {3 [{1 c, G& g3 J! H" H9 u3 f1 k
    Priority_pri = &((*Priority_pri)->next);, X* D) U% P* y. W: z: v( D& s& Y
    //printf("hello\n");
    7 k- R" A. D/ B9 W( H% t}# [. E( @# i! e& w9 |  A
    if(High_response_ratio_dispatch(&HR_p,&HR_mmy,&HR_memory,HR_pri,1)==task_completed)
      f2 k- U& r8 U0 L) L5 k* O{* ~4 q& ?7 j, ^1 O( L9 C, P% @7 C
    HR_pri = &((*HR_pri)->next);: p( g5 k& l6 t  j3 G3 d$ e. b
    //printf("hello");* N* \8 W9 a7 I% {( H
    }; E6 ^; b0 H# m5 A4 F0 x& _
    count=0;0 K& @, v2 D6 l+ o/ c/ t2 ]$ d
    }& Z5 m5 z5 g0 G2 N. a
    else" s: N9 \4 Z& C! u  `3 D: ?
    {
    4 G: k% t' ]/ Z; \* q" tif(FIFO(&FIFO_p,&FIFO_mmy,&FIFO_memory,FIFO_pri,0)==task_completed)
    + q$ P/ I# n" L* w" L3 Q) w/ s8 r/ ^{
    9 [6 R1 n6 i# k5 G' m+ MFIFO_pri = &((*FIFO_pri)->next);& H# M& O6 V- Y+ @
    // printf("hello");  f% |; k. I# c1 G0 b6 \$ ^1 o
    }: D5 Z' h$ }5 d1 _/ C5 N: M
    if(TimeTurning(&Timeturn_p,&Timeturn_mmy,&Timet_memory,Timet_pri,0)==task_completed)8 {8 ~' [- G9 z. y; J0 T3 d
    {5 @! p; I8 V- e% \- K' o
    Timet_pri = &((*Timet_pri)->next);
    / @- L  ^# s5 F: F( V, n$ @* Q// printf("hello");
    , [1 V; }( I6 ~}% N$ N% ^' Y7 ~! e; N0 H, q  q
    if(ShortJobFirst(&SJF_p,&SJF_mmy,&SJF_memory,SJF_pri,0)==task_completed)& F* k0 F2 o3 O
    {- x  B. N& R* v- _- V
       SJF_pri = &((*SJF_pri)->next);6 l' Y) A% C7 Q: S
    // printf("hello\n");
    2 L( M% E! Y! U8 i% Y  ^) c}
    & h' ?0 c8 i' V3 f) y. Lif(PriorityDispatch(&Priority_p,&Priority_mmy,&Priority_memory,Priority_pri,0)==task_completed)5 c. }& N8 b9 _* V1 `. L
    {
    3 u  R3 A. a) z8 c9 rPriority_pri = &((*Priority_pri)->next);
    + v$ L* J( s: W" q+ S//printf("hello\n");1 q2 v" E6 P& k
    }3 ]3 c. A) E' n
    if(High_response_ratio_dispatch(&HR_p,&HR_mmy,&HR_memory,HR_pri,0)==task_completed)
    7 K1 ]! i8 }8 u2 Y* y" y{
    " G* O0 R. B4 N* f" M9 U: kHR_pri = &((*HR_pri)->next);8 K7 B. K# {- O# _7 d! I( h! @
    //printf("hello");
    & c, M( M$ `( t; }6 L- f//Sleep(1000);8 a9 A) z  E! Z! f0 ~1 N
    }
    0 X* Q% n4 f- l, W: Ccount++;  W# ]* g( T. z" h
    }
    , g/ ~; d9 ^# y% d1 [if(systemClock==showTime)4 d. }1 I/ _4 r1 }2 t
    {/ G; Y8 w; o  K0 s) u6 X
    /*PCI * p=FIFO_save_head;+ v6 b, J% u4 V( i
    int i=0;
    1 Y7 M' b# T9 p( L, D9 w8 ?for( ;p!=NULL;p=p->next)8 f8 d* K8 A# |. P! T' c
    {2 R  V! _7 ^9 _( S6 T2 G( n+ H
    printf("Id %d\n",p->processID);4 p; l' o/ q: V9 E1 k
    printf("comeingtime %d\n",p->comeingTime);; j  s0 {, ~% Z3 N5 k
    printf("runningtime %d\n",p->runningTime);8 ]2 i5 E' R' Z" X% V
    printf("asdmemory %d\n",p->askMemory);: w! Z* ]) `- y' K
    printf("completedtime %d\n",p->completedTime);- _  |3 T4 c6 L) T4 x  Y
    printf("compute %d\n",p->compute);
    6 A% Y+ ~; S' tprintf("exchange %d\n",p->exchange);
    % L6 Y, b, u# y  gprintf("waitio %d\n",p->waitio);
    6 L9 g: {! }5 [3 Z, Xi++;
    ' [* }( e4 ]' }9 e$ u6 R& S& a8 g/ Y; b5 ^- m6 C) `' L( t

    " M: |, g" X& E" {. Z5 a}
    1 g* Z% P  C! |) v/ S0 W! Bprintf("%d\n",i);*/0 P2 [, i8 s+ _
    if( (fp  = fopen( "data.txt", "a" )) == NULL )
    9 b$ B6 Q0 a4 D- j{
    9 P7 R' P$ j" R- j6 iprintf( "The file 'data.txt' was not opened\n" );
    7 a; c) H( P' e5 a9 M//return 1;+ e, F2 J2 P  s* `# w
    }
    9 C8 W8 A& Q+ q9 Y8 Delse
    6 E7 B5 ]& U/ |# o, v+ b+ s$ @{
    ' t  T  L  m. }% d, D! b6 \fprintf(fp,"FCFS \n");# s: e! L, H+ U, j; N6 ]% R& m
    for(p=FIFO_save_head;p!=NULL;p=p->next)
    " x0 S/ n0 H8 Xfprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,# K% ?) W( y0 U8 t3 ~' |" P
    p->exchange,p->waitio,p->runningTime);
    6 X* f' O: o8 z" j( Ifprintf(fp,"\nTime turn \n");: ?! \% s' \5 z: x1 G0 b5 H5 q! p
    for(p=Timet_save_head;p!=NULL;p=p->next)
    ( f! a7 w# _6 U0 o, N8 ?+ Lfprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    - c3 }4 o, J' e! c, H( rp->exchange,p->waitio,p->runningTime);
    5 E6 ?7 i3 T8 Y* u/ l: O  lfprintf(fp,"\nShort Job First \n");
      \9 C0 k" P  j# Jfor(p=SJF_save_head;p!=NULL;p=p->next)+ H' T( o: u" h4 ?; @8 Y8 g
    fprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    3 S# p% p# K) ?! ~: _' ~p->exchange,p->waitio,p->runningTime);
    $ X; G. x0 Z. k) Vfprintf(fp,"\nPriority  \n");
    ; o! \- K) t8 e; p3 J  ffor(p=Priority_save_head;p!=NULL;p=p->next)
    1 i% l0 ^. V" I& Jfprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    9 Q+ H2 `. J  r$ s' ~0 q' Zp->exchange,p->waitio,p->runningTime);
    6 X0 g" u# g# N, V2 gfprintf(fp,"\nHigh response \n");
    , Q) D8 r5 w; Z5 s. `- g2 Rfor(p=HR_save_head;p!=NULL;p=p->next)
    8 s, ^1 i( t7 q' I; Z! Ufprintf(fp,"%d %d %d %d %d %d %d %d\n",p->processID,p->askMemory,p->comeingTime,p->completedTime,p->compute,
    9 a; I& U( P/ M! fp->exchange,p->waitio,p->runningTime);& w5 U7 D7 D+ B. `
    fclose(fp);
    * H* ]; G* y! \- E/ C6 s# n}
    " w" f2 ^: Y# b4 _, yshowRunningResult(FIFO_save_head,Timet_save_head,SJF_save_head,Priority_save_head,HR_save_head);9 a" e, a: T: _/ |5 H, T1 U
    MouseListening2(&flagDraw,&showTime);
    ' t" C; K& [4 B( _( Z  G1 s}( L) Y; v$ o: t8 S! M
    systemClock++;4 w3 t0 g0 B( I" S) H+ C" V4 O! L
    if(flagDraw==0)0 f$ m% e2 I, C
      Sleep(10);
    7 A) {: p6 ~! H" o}
    6 e8 u% ^0 @8 X+ c8 }1 F
    " v8 z! ?. r9 @$ t( D7 k; m# z( P
    }  _2 ?5 r1 e( V1 f: H5 Q( ?
    int showRunningResult(PCI* FIFO,PCI * timet,PCI * SJF,PCI* PR,PCI* HR)
    : O& z4 L9 Z) G! X% P/ @8 f) e) P{
    3 Q, S7 L: E3 E8 v+ oPCI * p=NULL,* name[5];
    . c7 Q- b2 ?4 D0 f: Oint count=0,i=0;
    & O% L# w, A  |char ch[5][10]={"FCFS","timet","SJF","PR","HR"};: W( v  u% u/ C  x. p! o5 ?1 [
    double turnover=0,wait=0,c=0,w=0,change=0,pos[4]={0,0,0,0};6 E. }: N. Y' N% B+ F1 n! U+ m1 \+ L
    struct info8 f6 ^+ g$ z$ L  l2 \! A
    {
    7 k6 G. i1 f& m! cchar name[10];! v' s; e. R; D; a
    double throughput,turnover,wait,CPU_rate;* T  Y3 J3 B- W5 ~
    }inf[5];
    ( Q$ p; ?0 I4 _0 ~4 Aname[0]=FIFO,name[1]=timet,name[2]=SJF,name[3]=PR,name[4]=HR;
    # J* v+ c9 C; l) B0 mprintf("调度算法..........A\n");6 e6 J5 e+ L# Q# F) o9 \0 |7 c* ]
    printf("吞吐量............B\n");0 }5 G$ d) h  y9 w
    printf("平均周转时间......C\n");. W$ w3 a  X& s' D  E1 a4 Y' [
    printf("等待时间..........D\n");
    & {2 G/ c& l& s6 a5 Aprintf("CPU利用率.........E\n");6 u1 j! n  M" S
    printf("A\tB\tC\t\tD\t\tE\n");
    9 K9 p) k) w- g9 P$ n9 I. _$ ffor(i=0;i<5;i++)
    * O+ {% D8 r( R, z4 g; g7 A- W{
    9 W% T- M, p: A0 x- b6 s) Qcount=0,turnover=0,wait=0,c=0,w=0,change=0;& k5 Q6 o. r+ c# a
    for(p=name; p!=NULL; p=p->next)
    / p9 L1 Z: n* \4 y5 j8 A" ^4 M{( w0 r2 |) Z6 |; C! J
    count++;% R4 j: r8 Z! N# S
    turnover += p->completedTime - p->comeingTime;
    ! \: H. x5 d' x& ]. {- d# Pwait += p->runningTime - p->comeingTime;+ K5 B3 Z: P9 ]' b
    c += p->compute;2 q- j$ ]! b: _3 R7 n7 v) O: ^$ ?
    w += p->waitio;
    ) d& C' h1 X8 l& W$ F1 R/ Qchange += p->exchange;
    * J, E; Y4 c* H: p}" N2 {' a, S, W1 ]# W8 J
    turnover = turnover/count;5 q- x9 k$ E1 d" y/ u% y
    printf("%s\t%d\t%.2f\t\t%.2f\t\t%.2f\n",ch,count,turnover,wait,c/(c+w+change));6 F3 e% O+ L! {2 ?
    strcpy(inf.name,ch);* J3 E3 q1 ~* {5 C" d! ]+ u
    inf.throughput=count;. S" [: t# N; u* e" h% t
    inf.turnover=turnover;
    # l5 C. e) s/ v1 {" {inf.wait=wait;
    ' O  Q5 s+ J. l3 I, `inf.CPU_rate=c/(c+w+change);
    1 L. h5 {! p- I( O+ b}  r3 J8 T/ e. Q$ H( _# T. F7 ~9 H( q
    //画图
    2 E& m1 C) R% M- @3 i: @- H, C//cleardevice();
    . U4 @5 e. E1 i! h- ?6 v; l! @line(0,600,1200,600);* I3 ~0 K- i1 K6 x/ t4 I
    line(10,600,10,200);
    7 A8 Z/ |. B0 G. }  o) r! bline(10,200,5,205);  ^& R% D- n4 v6 N# Y( c5 w+ h
    line(10,200,15,205);- d2 y0 C  M5 i2 M& ]% d# i: |
    line(310,600,310,200);$ i0 Q' n4 `, D; @/ S2 W: ?' v
    line(310,200,305,205);) f8 S6 j1 `' O) \" D7 E  p
    line(310,200,315,205);) O2 d+ W# v/ F8 j5 \5 y
    line(610,600,610,200);2 ]; N6 t3 P+ Q4 w6 l/ I$ r; k
    line(610,200,605,205);, A* K% d7 f, P0 W5 j6 _
    line(610,200,615,205);/ N+ W/ r7 _  W. m6 |2 J
    line(910,600,910,200);  u$ G; z, v- R+ v) n6 f
    line(910,200,905,205);9 @7 X, C5 q; F; s+ Q) C( c
    line(910,200,915,205);//最高的长度400,宽度均为40
    & b# F5 p( V1 M2 }for(i=0;i<5;i++)
    + X9 x2 f/ S3 P3 a& o{
    1 I+ \: A/ C! i! tif(inf.throughput>pos[0])5 }# T5 Q3 M5 t
    pos[0]=inf.throughput;
    - j. M0 N9 K' Zif(inf.turnover>pos[1])  T; @4 V% R5 H
    pos[1]=inf.turnover;7 B) a* C! W& I) D
    if(inf.wait>pos[2])
    ( J5 P9 u# U  b" l3 j2 M! l4 Tpos[2]=inf.wait;# b  G. x' J9 l/ Y
    if(inf.CPU_rate>pos[3])% x- H1 `* K# e0 `+ D
    pos[3]=inf.CPU_rate;. f$ q8 ^3 P0 g4 F6 N+ J  i
    }
    5 W# b3 F5 M+ ksettextstyle(30, 15, _T("楷体"));0 [# n  N8 [& G% m" y$ ?
    for(i=0;i<5;i++)
    : F9 s8 T  c" R4 l1 K% T4 }{9 T" A6 }$ P2 N! H
    switch (i)
    3 O3 D4 }, e$ m3 c{& G& u# o% j/ g3 |+ B
    case 0:
    # `% j4 {6 u( ?+ csetfillcolor(BLUE);
    0 }" ~, C, A2 s+ n2 L  W6 s0 ifillrectangle(100,50,150,100);8 ]3 q0 ?/ `8 J9 s! c6 H. w+ g  @( |
    outtextxy(160,50,"FCFS");
    . X1 x7 s/ j) D' c4 x1 u) @break;% p6 D- F6 O0 p! z' _
    case 1:# |. s) {4 U) Y8 V. z
    setfillcolor(RED);
    2 h+ v! Z3 b- }( w* p0 z6 e  W. K  Ofillrectangle(250,50,300,100);$ ~3 D  _" h& C9 ?6 N
    outtextxy(310,50,"timeTurn");# q( A7 M* h1 G- }* x' O$ K
    break;9 B3 H# |6 {! ]% a! g3 [
    case 2:
    4 A" \' R2 m2 m/ k/ g* {setfillcolor(YELLOW);
    ! J5 s8 y) c8 Q' \# e3 I+ wfillrectangle(450,50,500,100);
    $ V6 [, G  W" w/ C; Oouttextxy(510,50,"SJf");! j( }3 V; l  R6 p3 n% d: [9 J
    break;( e3 \* E% B0 ^5 z* f* I: T1 m* T
    case 3:
    $ ]1 M" @) ^+ E' l1 w! z5 i5 X9 h2 F2 ksetfillcolor(BROWN);4 C, W: J( H" k9 a& z3 e0 q
    fillrectangle(580,50,630,100);2 B5 w5 |% o0 Z: ?+ `! O! S
    outtextxy(640,50,"PR");4 ?2 k7 G1 g) z/ {" U9 G% _
    break;/ M$ ]5 F! t* z. d) S) Y1 k
    case 4:# z4 U; v; |4 e0 W
    setfillcolor(GREEN);
      H/ R. ^  [2 q* u2 T4 }7 ffillrectangle(690,50,740,100);/ P& k! W. _- G0 S0 K% ]7 \
    outtextxy(750,50,"HR");
    ' V  x3 k. u2 @4 ~3 k/ ^break;1 X( E$ O3 x% ~, I. Z0 m
    }9 J! P$ y+ k- ]' f: l; n% X
    fillrectangle(50+i*40,600-(int)(inf.throughput*400/pos[0]),90+i*40,600);
    1 a; O( w9 Z; M0 i6 |fillrectangle(350+i*40,600-(int)(inf.turnover*400/pos[1]),390+i*40,600);
    # [. T6 V) H0 i9 i  K' Q/ Y; u' \fillrectangle(650+i*40,600-(int)(inf.wait*400/pos[2]),690+i*40,600);7 K$ [9 b" s3 u5 \# t- A" n" t* R& Q; I
    fillrectangle(950+i*40,600-(int)(inf.CPU_rate*400/pos[3]),990+i*40,600);- d4 I9 x( o" U

    % R. X. U/ O# B0 o( P. [6 u' d" c; U: b- m. G' E+ a' ?
    }6 H( A. j& u" r: }4 b" X
        outtextxy(100,150,"吞吐量");
    # Y4 d8 L. v. o' @outtextxy(350,150,"平均周转时间");& ^! p& x7 w. z0 l/ V- `
    outtextxy(650,150,"平均等待时间");
    * \% i0 ?# ]$ w# H9 u+ {4 ?4 Houttextxy(950,150,"CPU利用率");! V* {7 x3 W! a; w3 W: W
    return 0;2 ]: s" s, {. g* l
    }
    - h1 K$ g* ^% N0 I3 F6 m) `7 zint MouseListening()
    . e  v6 h7 N  z* ~' ^6 c& P/ b{( q$ D% z2 b) D  o* d
    MOUSEMSG p;6 ^0 V  @# C% z1 F" V7 Z( e
    if(MouseHit())6 [; p5 J9 i. |+ e; T
    {$ X0 \: ~5 m# y
    p=GetMouseMsg();- m/ h+ v) y1 P9 ~5 _2 {
    if(p.mkLButton==true)
    1 k; a6 D/ Q0 w' C. [{" J' @- t( a6 T% O) G( D
    if(p.x>0 && p.y>0 && p.x<400 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)
    . j6 N  ?) b2 q: G3 j! j& ]% dFLAG_FIFO = 1;
    3 l+ E# l8 ?% d$ Kelse if(p.x>400 && p.y>0 && p.x<800 && p.y<325 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)& z. `: ^4 @: B% e0 \4 K' j
    FLAG_TT = 1;5 X0 X3 E# a' S" F. G. A: ^1 F
    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)
    " [* [1 K( Y  v( e( qFLAG_PF = 1;
    + D% B6 x4 m) i' J! R. G" Xelse if(p.x>0 && p.y>325 && p.x<400 && p.y<650 && (FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO) == 0)& S  M$ _4 M. g3 ]# V1 Q& @7 l
    FLAG_SJF = 1;! T, E; w/ x' Y# r+ T: U
    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)
    ; j( U; k  b" |( kFLAG_HR=1;* P) ~# S$ u! C; S0 W( z$ J, u$ Y
    else if(FLAG_HR + FLAG_SJF +FLAG_PF + FLAG_TT + FLAG_FIFO >0)1 b. w+ M6 Z3 w) H0 k7 D
    {
    9 ?; l. S& r) }FLAG_HR=FLAG_SJF=FLAG_PF=FLAG_TT=FLAG_FIFO=0;
    - e- T# y% V+ O. e- Xclearrectangle(800,325,1200,650);4 o% w9 o5 }+ M6 i3 f  {3 y
    }0 P, O( f9 N2 l' i# 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 )
    & H; _6 U# G" V1 J9 k" b/ \' v{
    $ z5 z/ a- ?: SFLAG_show=0;- J. w- j6 `- f+ Z
    cleardevice();! c$ x6 q, w- e0 a! F9 m. v7 e
    return 1;' ?+ t# d& Y3 r$ H. _1 q9 m
    }2 w6 C& q4 L. e- y& S8 g
    }. g2 n& S) {8 z7 b- X+ n( Y
    }
    6 y4 O5 q5 n# g8 E( ~. C8 i" ereturn 0;
    2 F9 j7 S; D, P6 {3 R  z. |  R}
    3 c% V7 n# }3 B! g8 q% d5 A. Lint MouseListening2(int *flagShow,int * showTime)
    ! v9 |( z! f, e, F5 u% }7 D{( X/ t& |; p! _1 J
    MOUSEMSG p;
    - a7 ?) [  y. @6 b5 `rectangle(1150,0,1200,50);# `' ^$ v+ k" v5 _& J; h
    outtextxy(1160,10,"X");  Y* u8 ^2 x( G
    while(1)
    2 O% l  l" W, F; R) V, T{) g# m3 T& G# u, z2 h
    if(MouseHit())6 k$ s) ]: A5 u# ?
    {
    ) u- I  z+ c. y% U9 `$ \6 s( w5 fp=GetMouseMsg();+ i' H/ c5 w3 }
    if(p.mkLButton==true)" _. D1 E4 A4 y' r/ c9 w
    {; P' h. t% `+ |& J9 g
    if(p.x>1150 && p.y>0 && p.x<1200 && p.y<50 )0 `) X* x' D: R" F& n- s/ |
    {
    9 N& I9 s6 {, T6 `' M8 `(*flagShow) = 0;
    2 F: l7 O/ ]. i$ ]9 f- e  ~4 i3 L(*showTime) += (*showTime);5 T+ r3 w4 w% u2 J- v& r
    FLAG_show=1;+ p+ V' u8 {+ t1 U4 o
    break;
    ; g2 O5 l$ Q6 A. l" g; A- r5 G8 r}
    9 X0 {" T: k! y0 ]7 \4 L, u
    ( ~# e2 w" J( A4 b9 ]! O! u, X}
    4 P8 K, Y1 i# b. n1 g" f' z}
    / m, c  ~& i3 X, E+ S; wSleep(20);
    0 E. j  ]5 P) B$ c}
    6 i+ i! n& O  t+ f, Zcleardevice();6 @. ~, m! @( P* t, i
    return 0;
    3 r; A/ M) a" r$ z% l/ U}( ?  J+ k/ @2 @; g' |( r5 l
    int drawPerformance_FIFO(int x,int y,int memorry,int com,int wai,int cha)& n- e# @( D$ z/ |
    {
    4 q/ `  P( _( A4 f. ostatic int info[11][3],num=0;
    * V' i+ {# S/ P( _5 E! |int i=0,j=0,pos[10][3][2];
    / Z; h5 {- C5 ~& [0 Z! c2 Hfloat temp,t;' Q. R4 k5 R; i) G! C% z% w
    //画按钮,不属于FIFO图的范围
    % C( V; v8 x; yif(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0 && FLAG_show==1)' K& c. K  H: F" W( m
    {# V" U! ?4 J9 \! z8 D4 _
    settextstyle(30, 15, _T("楷体"));
      v1 {; A0 e, A/ k( xrectangle(890,455,1110,510);
    3 @9 V2 [9 V) d. `rectangle(900,465,1100,500);
    / ~5 C+ I# n3 U3 L' G9 ?outtextxy(910,468,"查看运行结果");# P; O  W3 e7 ?' g2 r
    }
    - W' e' k% c/ ]/ ~/ o. h; u& C//结束画按钮
    * r3 U# ^. w; q8 S  A$ {5 N+ Cinfo[num][0] = com;
    5 V4 s; x' c4 Z5 j$ x8 k! v# \% pinfo[num][1] = wai;
    . K4 t8 e( O/ q4 ~info[num++][2] = cha;
    ; v( N  j" O% t9 I7 Bif(num>10)  //存储10个点- r* s) h0 b% e  K, c" B4 z% r$ B
    {8 U; B; @9 P/ \# I8 _1 p
    for(i=0 ;i<10;i++)
      M! m* X0 i! J/ G{
    $ P1 j* r9 A- O) m. i6 F' @- Kinfo[0] = info[i+1][0];- k5 \: u" o6 F, d  K' g! X
    info[1] = info[i+1][1];
    * q& r) X# O" o$ pinfo[2] = info[i+1][2];+ U! n( d  t0 [4 L; i" o7 H; A: _
    }
    + V; M$ s2 c/ c9 Q" qnum--;
    4 u* U9 Y& h- d4 I. }}
    ; E9 P+ e" V% Rif(FLAG_show==0)# l1 U/ t/ L% C/ J' l
    return 0;
    9 x2 [& p0 k. ?$ J4 H  j* x2 Ifor(i=0; i<num; i++)# z8 Q5 M+ w' H+ ]0 W* h
    {
    ! o' L7 b7 l8 W) _1 A! j4 st = (float)info[0];0 @! T) k3 l1 B# X0 u$ C$ ~
    temp = (t/101)*90;
    6 K2 Q. B: }6 _, b) V: L9 X8 U5 ^, cpos[0][0] = (10-num+i)*25+x+100;  p- H4 x  s% i$ Y! s2 U
    pos[0][1] = y+110-(int)temp;
    1 p7 T9 r) Z. |/ tt = (float)info[1];  |) j* V" f7 C8 o1 r
    temp = (t/101)*90;
    $ S5 n5 H3 B  g( |pos[1][0] = (10-num+i)*25+x+100;$ i+ E' o" ]9 C% m+ l
    pos[1][1] = y+210-(int)temp;6 I( ^) D# U0 m: A
    t = (float)info[2];
    3 v/ C- M/ \' L; l0 d7 I( Ztemp = (t/101)*90;
    - b; h, E' L/ c0 ?& ^pos[2][0] = (10-num+i)*25+x+100;
    $ S4 G( `& G" g% f3 k. Qpos[2][1] = y+310-(int)temp;7 @9 v9 C" @5 O9 H
    }6 e$ A$ M5 {9 J6 M8 Z+ F7 b- \
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)% _+ d7 c, [2 X. x- L9 \: B
    {
    7 k- }8 z9 v+ |9 m+ G. r5 _clearrectangle(x,y,x+400,y+315);
    5 d6 Z9 B3 @8 v! G. w4 `" Msettextstyle(20, 10, _T("楷体"));4 S3 M. l* u7 }) ~8 |' ^
    rectangle(x,y,x+400,y+325);( d1 l! P9 X* c, q
    outtextxy(x+40,y+10,"CPU");       //画柱状图
    ; L* F! j2 j9 y5 C2 X2 \outtextxy(x+45,y+10+100,"IO");1 o1 p$ a" [& ]7 V0 N- M+ P  F
    outtextxy(x+40-15,y+10+200,"change");
    + `3 S9 L0 b9 |. Grectangle(x+35,y+30,x+75,y+110);
    8 X/ {3 V) h! x0 @6 T6 zrectangle(x+35,y+130,x+75,y+210);
    # T1 h* E' |8 N& E$ I( ~2 o1 prectangle(x+35,y+230,x+75,y+310);4 E( O* g/ J1 I% ~
    outtextxy(x+180,y+310,"FCFS");, T1 Z- W4 Y- }' G6 g- }9 V$ p
    t = (float)com;
    ( E0 D' v4 \" S. z7 |% b; `temp=(t/101)*80;% B5 i, _! e3 U. J
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);4 W9 g3 g8 _6 D$ M4 e, b9 M
    t = (float)wai;
    % e: ^9 ^( H$ j- k' @7 utemp=(t/101)*80;3 v! l) D3 f: u( b- K9 s9 {2 g
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);! L) Q2 F6 y: h  {5 L: E
    t = (float)cha;, ^% h' M( g) w8 ]
    temp=(t/101)*80;
    6 N9 M# a; u" O7 X: S8 Kfillrectangle(x+35,y+310-(int)temp,x+75,y+310);! T+ `5 a2 \1 j: ~; d3 s7 f
    for(i=0; i<3; i++)   //画坐标   high=90,length=250* p1 t1 d) z# U* u6 @: W0 i: {
    {
    ! {6 m) C1 F# q7 qline(x+100,y+110+100*i,x+350,y+110+100*i);6 P) y/ W+ N9 }& G* e
    line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);' M" D5 O1 n* Z& Z7 X
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);* A4 I! j% O9 p9 _2 b& `

    6 p& V5 m3 t8 `0 [2 }+ I0 xline(x+100,y+110+100*i,x+100,y+20+100*i);
    + x- [+ W/ ^% S8 M5 M) c. jline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);
      i3 ]: D2 F/ j- f9 a. R8 J5 V* Lline(x+100,y+20+100*i,x+100+5,y+20+5+100*i);
    9 E1 Q6 i: q7 h% `4 h0 Tfor(j=0;j<num-1;j++)6 M# t) a$ N6 V( [3 X6 u+ Q
    {
    / x5 H* h, T+ i# B% k; d5 _$ y4 pline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    " X$ s4 v  m, r6 b8 }line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);8 C; @& Q! h7 S( _+ S% u
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    9 ?- L" n/ Q# i- ?  i}
    6 A2 E2 _: ~( Y& D* ~: N& A0 n}3 {# V# A+ o7 _4 R* v) e- ^
    }
    . f3 O) D& M. I, d, Selse if(FLAG_FIFO==1)
    - e+ N& d( R: b- {0 |  K{/ }: h; l, D- f5 i
    x=0,y=0;1 K; r) i( j# Q7 ~* ~/ g
    for(i=0; i<num; i++)% V; U6 _; F7 M3 Y6 _/ @  K) U* m
    {; y/ C9 V: t7 z7 x+ [/ T1 D
    t = (float)info[0];
    # d3 b; k4 x% W3 D( R- ?8 }/ Htemp = (t/101)*180;
    % W) W( p4 ^  p# X& `' Ppos[0][0] = (10-num+i)*50+x+650;
    % j& m7 `0 u! \" Apos[0][1] = y+210-(int)temp;) f) d2 U' ^0 n% |% T/ Y+ n
    t = (float)info[1];
    . y0 t; g- r! L0 d: |7 vtemp = (t/101)*180;9 L; B$ `" K+ L4 a# i6 O5 j
    pos[1][0] = (10-num+i)*50+x+650;) g+ v9 `& s  ]6 F& M3 W
    pos[1][1] = y+420-(int)temp;
    " r8 g' ^' J  p7 tt = (float)info[2];) B8 C: L) a# \( D
    temp = (float)(t/101)*180;
    $ ]7 y5 F0 E, U* |pos[2][0] = (10-num+i)*50+x+650;
    ' v! Y% u6 I+ ?) I; gpos[2][1] = y+630-(int)temp;: y+ {! W# P2 x! `$ i+ ]& G
    }
    , L: s+ g: `% T6 F* Sclearrectangle(x,y,x+1200,y+650);- T: ?! L3 [3 j. P  V
    settextstyle(40, 20, _T("楷体"));: i) N, N# `& X; c. F* e9 K. ^$ Z) @
    outtextxy(x+50,y+50,"FCFS");
    & [& G& c5 B/ t- B/ ~8 ~outtextxy(x+280,y+20,"CPU");       //画柱状图: x4 Y0 t- R3 J# _
    outtextxy(x+285,y+20+200,"IO");
    7 t) J) I, p( g% L) B% B9 ~outtextxy(x+250,y+20+400,"change");
    ; Z" j  O/ k3 k: ?rectangle(x+270,y+65,x+330,y+215);
    , i7 U5 ^4 v# K- d+ krectangle(x+270,y+265,x+330,y+415);
    0 V$ u& a8 V% Orectangle(x+270,y+465,x+330,y+615);
    3 s8 v1 R. V5 ^& zouttextxy(x+290,y+620,"TT");
    * r0 H. ?( {7 j# q& V- N. Tt = (float)com;8 j! L" `% e* b# ?+ y
    temp=(t/101)*150;% f; X/ N  @7 j% |
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);: E+ P; I# h' b" p5 n
    t = (float)wai;- L# _3 [( J: P% ]
    temp=(t/101)*150;7 ~0 L5 J% E% k. x7 y$ d: _. }
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);* ]3 u7 H  O' h. X8 k$ D3 d
    t = (float)cha;
    ( {% p% n) b2 x, x3 y! O7 H8 z, K, }temp=(t/101)*150;
    6 p7 H  v. g4 H9 I! q) `. z& hfillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    ; G5 G, \. t* {for(i=0; i<3; i++)   //画坐标   high=90,length=250
    2 q  A  ]8 K1 X5 z{$ d6 o! m+ b6 z% ]$ h' P0 F
    line(x+650,y+210+210*i,x+1150,y+210+210*i);7 x& W( w1 Y7 M6 F. q. y
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    & ]# c( r4 I# R# Q' _3 D+ qline(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);
    / F/ `, s5 Y4 K; F6 ]) k' Z9 P/ c1 H6 h$ q% g4 W8 c3 q! T  ?
    line(x+650,y+210+210*i,x+650,y+20+210*i);2 w$ B$ c* R' S4 ^1 ~  P
    line(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
    + r- A7 o& `. G8 N& b* zline(x+650,y+20+210*i,x+650+10,y+20+10+210*i);7 G: J  ]2 k$ S8 j
    for(j=0;j<num-1;j++)
    ; m2 z; x2 H2 y: e0 e% d4 R{
    * v& Y$ W: w3 u, s. Aline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);8 j$ _6 r: V# q& c: X2 U* c6 B2 \0 T0 m
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    ) C! h1 C/ F! s1 {9 a+ Kline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); " X6 r9 ?3 ?5 U: A) T( l6 w
    }
    ) x4 h8 G# M# U5 K/ h' ~) G  q}
    , A4 B$ k% p( G% h2 ~}
    $ `6 g' N( M& G9 j  o. K5 t7 A' g( R) E8 \  C8 y2 `

    4 J# C/ ]- F9 \( ?  yreturn 0;
    / \9 Q, E' \3 a0 |: }0 W8 y}8 c2 Q$ Z9 a2 E. H4 k: z2 D' M
    int drawPerformance_HR(int x,int y,int memorry,int com,int wai,int cha)+ M) v2 z5 a- b6 `& p$ f- t
    {
    ( s  y! y2 y  I1 Lstatic int info[11][3],num=0;
    ) r3 B" \- E; `. Y7 Zint i=0,j=0,pos[10][3][2];' W9 z( {( \) V$ C
    float temp,t;
    8 R$ F8 b- W! t5 N6 oinfo[num][0] = com;! z9 I! Q) g$ x& h/ H& ?
    info[num][1] = wai;# i# l8 T( ~* B. L1 Z# L) M
    info[num++][2] = cha;2 x. g" N5 ]. P; u/ x$ I$ C8 e9 v/ R
    if(num>10)  //存储10个点0 S& S$ K1 s' W, c/ u9 g! k
    {& e, y* M- s* a% ~2 h6 f
    for(i=0 ;i<10;i++)# o- ], @' M. V" Z  q, C& r
    {
    6 v" c0 s  S/ w& M1 A9 Ainfo[0] = info[i+1][0];
    7 P- a1 R' l' @# Iinfo[1] = info[i+1][1];
    & a# C- R2 P" `7 qinfo[2] = info[i+1][2];
    4 E4 Y6 D0 X$ ]' U8 n1 B; h}  `4 ~, `* r3 J. J8 k7 ]; n
    num--;" C0 \6 L* A* Q$ ]
    }7 \" q* B) X7 |. {1 O- T8 @
    if(FLAG_show==0)
    $ l& w! E$ d# ~4 Qreturn 0;9 q4 j! i- C% L  Y& j% M
    for(i=0; i<num; i++)/ n* h# v7 x% i! z) V
    {9 ^5 j' D7 L  z9 R8 S3 l( z! c, j
    t = (float)info[0];
    0 W* R# {$ D" b( `4 Btemp = (t/101)*90;
      x+ B1 s# P0 z& Kpos[0][0] = (10-num+i)*25+x+100;# ?+ |  v! S0 B- C- p! L7 C0 v0 k# r
    pos[0][1] = y+110-(int)temp;/ T" R5 [0 n- b
    t = (float)info[1];$ Y* D# T1 i/ T' K# j4 Y8 E
    temp = (t/101)*90;
    8 q9 l" N( o9 f! O0 U! i3 {pos[1][0] = (10-num+i)*25+x+100;3 v7 W: Y: c% {! D( p( ^( a; I
    pos[1][1] = y+210-(int)temp;
    1 Y* K  ^1 ^9 {' J# r2 v* k0 K. |/ nt = (float)info[2];! m9 R9 {$ o7 ]) n
    temp = (float)(t/101)*90;
    7 j! O! U# W3 N* L. \pos[2][0] = (10-num+i)*25+x+100;
    ' \. e+ r, ?* J8 S8 p( Ipos[2][1] = y+310-(int)temp;1 y# Q3 _# B3 F0 i8 N' U! W8 o
    }) |! E! |0 I2 c7 J
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
    6 Y/ V) C9 K# A7 G/ H{& z# t9 t: H9 m$ x3 v; q; Y
    clearrectangle(x,y,x+400,y+315);
    5 D( Z" |" K( F6 @settextstyle(20, 10, _T("楷体"));( Q* ]4 b/ @; x) M
    rectangle(x,y,x+400,y+325);; t0 O, c4 A0 Q5 v2 m
    outtextxy(x+40,y+10,"CPU");       //画柱状图
    , S. ~/ |  J% c) B4 n4 eouttextxy(x+45,y+10+100,"IO");8 t+ P8 z" B* s  [6 [( G& w
    outtextxy(x+40-15,y+10+200,"change");
    5 M" W- V) _& m, l, B6 v! Trectangle(x+35,y+30,x+75,y+110);
    . a% g  Q5 \: j* a% g  X; l' K$ p2 Xrectangle(x+35,y+130,x+75,y+210);
    + h1 J* M2 j- O* g6 Y" d: Lrectangle(x+35,y+230,x+75,y+310);; V5 M) X9 t. z1 D
    outtextxy(x+180,y+310,"HR");6 G9 L9 o; x7 K% w) a0 A
    t = (float)com;
    0 S" a, |+ i& z+ Rtemp=(t/101)*80;8 D; z! ~. j' J. N1 Y
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);
    - Q" }2 x; l! X, _t = (float)wai;
    ) i* @# e$ ]. X5 C9 \9 ttemp=(t/101)*80;
    ) P) J2 B  b8 n6 J+ N. x7 P/ d8 @fillrectangle(x+35,y+210-(int)temp,x+75,y+210);1 Y0 w. F$ u* }' h4 W, w" W
    t = (float)cha;6 _6 h& c1 y' A1 q* O9 _
    temp=(t/101)*80;
    0 |% ^. Q. o3 [- _fillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    - Y$ t3 _* p: v( ?for(i=0; i<3; i++)   //画坐标   high=90,length=250
    ) @: b1 T0 t: |2 Z3 k{$ L! W+ }4 H: m0 t
    line(x+100,y+110+100*i,x+350,y+110+100*i);/ a. T  b5 @! h7 q8 P
    line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);' O# e+ F; D# B9 O( ]9 m2 L, D
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);" D6 N) P8 ?, |9 B8 `
    : ?- n, u8 l& ?
    line(x+100,y+110+100*i,x+100,y+20+100*i);! n: l9 F9 v7 A1 T
    line(x+100,y+20+100*i,x+100-5,y+20+5+100*i);8 Q7 H4 K7 O% T' k
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);0 B( D: C2 b9 Z/ e9 J
    for(j=0;j<num-1;j++)6 a$ P8 |: s0 l# b% i, W
    {
    ( Y% B0 J% n% f3 D0 Zline(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);7 s3 x3 O) v: Z# n, X! X% J2 w2 t) b
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);# D% C7 {% I4 d1 C) j
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);   `$ P1 b8 D( j' _
    }2 h& q! ~  |( W6 n$ ~5 f' L
    }* U2 m; i7 \. i7 r; m* j6 s
    }' ^. C+ J, e3 u* P0 `$ c( d$ p
    else if(FLAG_HR==1)( B  Q' W. b& c: w$ e
    {2 X% A3 _. Q: d5 Q$ P5 u
    x=0,y=0;
    3 O5 S6 g7 S; G/ rfor(i=0; i<num; i++)) f; U3 |0 l) K# H, I) i
    {
    % W/ R( J9 y. D2 Dt = (float)info[0];# h( n% }* T5 ?7 p4 ^) H3 X
    temp = (t/101)*180;
    . b2 I0 k7 y0 zpos[0][0] = (10-num+i)*50+x+650;
    " J; w4 n% A# `% c" D2 X8 Hpos[0][1] = y+210-(int)temp;
    # W, A+ u  W6 h4 Yt = (float)info[1];7 M1 l, R. Y4 ~7 T
    temp = (t/101)*180;& Q! ?9 u" m; o5 ]5 N
    pos[1][0] = (10-num+i)*50+x+650;
    6 @+ _/ t. w. Q6 ?, ^pos[1][1] = y+420-(int)temp;
    - D. x; X* {7 R3 e! Q* i( mt = (float)info[2];/ G$ k$ T$ F5 r0 x
    temp = (float)(t/101)*180;
    / I0 D, f% W( L' M3 e( p/ ^pos[2][0] = (10-num+i)*50+x+650;$ w, O. ~* t" {
    pos[2][1] = y+630-(int)temp;
    / V: ~% j& X* W}; Z  I* n. C4 C% s* }. A
    clearrectangle(x,y,x+1200,y+650);9 O' T' @, I5 J% d. F3 k% ?$ b# l
    settextstyle(40, 20, _T("楷体"));
    0 ^3 G% U  r/ o! f0 q* x! gouttextxy(x+50,y+50,"HR");; n1 S1 D# K. g  k/ w5 ?
    outtextxy(x+280,y+20,"CPU");       //画柱状图7 M  A* C0 W% Z
    outtextxy(x+285,y+20+200,"IO");% X/ V4 q$ [  q4 h+ m% a1 Q
    outtextxy(x+250,y+20+400,"change");
    3 W' c5 C9 W; e% V3 }* \rectangle(x+270,y+65,x+330,y+215);2 B  M! u  R+ I6 l- @: C" l
    rectangle(x+270,y+265,x+330,y+415);
    % C% I7 E1 a, y$ z9 Trectangle(x+270,y+465,x+330,y+615);
    ' W7 w  F1 r, routtextxy(x+290,y+620,"TT");
    $ ~! E3 F! [* k. et = (float)com;; j  o9 Q& e+ O2 }9 g% S; H
    temp=(t/101)*150;
    ' [: L4 p. Y  w. @; Q$ _fillrectangle(x+270,y+215-(int)temp,x+330,y+215);: e0 M/ Z; k+ t( p0 ]
    t = (float)wai;
    / k& p0 _$ p- A* Dtemp=(t/101)*150;
    ' m9 V* J2 A. J+ w+ S! T, E1 R8 Cfillrectangle(x+270,y+415-(int)temp,x+330,y+415);! M7 g8 o. G7 T: o8 u, X
    t = (float)cha;
    # ^& P1 I1 e8 e, G. J+ j8 q! ytemp=(t/101)*150;# U. Q' D0 f! q) U
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);! x3 B6 X: M3 T1 m% b, T
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    . Y6 {' p0 _- P! z{
    % ?- r- Y( L9 T" hline(x+650,y+210+210*i,x+1150,y+210+210*i);3 N0 S! b- n8 ]
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);7 W0 d( b& v+ I) n: X1 }1 Y
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);" ~! s  o8 o9 Z6 u# T9 R

    : M0 g7 ?( P7 m# t. Y5 Vline(x+650,y+210+210*i,x+650,y+20+210*i);
    0 D: z* S4 b. Q% L5 kline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);' A+ u" t. z* `7 ?5 L+ {
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);5 G2 r: R- a6 k
    for(j=0;j<num-1;j++)* R; U, a! N+ u% Y+ Q. l
    {) w. ]; w9 ]4 m$ S6 h' q/ Q0 L
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
    0 T" s) M2 F; e5 g, ?/ U" M# t# iline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);7 a5 a7 K. ]9 Q9 \2 x
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    & `3 X' k/ F/ D+ a( t" g/ T& O8 z}: p. ~4 n0 P% g% R
    }
    ! h% `0 q5 y$ W+ J! U! u! d8 F% L}" v! n6 d. B  Q+ b/ g

    : V6 y7 a' B* S" a$ u1 t: Y5 [/ c- f9 h' m+ f& S
    return 0;
    7 [: J9 C* ~/ V}
    $ N- o% F$ s& E' m& u: qint drawPerformance_TT(int x,int y,int memorry,int com,int wai,int cha)5 X6 d$ v: I, R3 N# |
    {
    2 s2 N* X5 B# Wstatic int info[11][3],num=0;) S  h2 C5 y! f* u! h8 r
    int i=0,j=0,pos[10][3][2];
    $ C) z& ]/ f& Q+ J* mfloat temp,t;
    2 b5 K* B  ?5 f' i" z* Cinfo[num][0] = com;) K& T4 H* B& D) m1 L* V  e
    info[num][1] = wai;
    & z5 n' U9 M3 B" M0 s4 ?6 A; Minfo[num++][2] = cha;
    - r! i( l0 G" p2 Yif(num>10)  //存储10个点. u9 v/ `8 i( t* _+ G
    {% F4 f. G/ E4 {: l. A0 [2 T
    for(i=0 ;i<10;i++)- m) S3 _1 g$ m
    {
    + z& s! w' \5 K. O/ Hinfo[0] = info[i+1][0];
    4 |8 [; ~" p, i+ Sinfo[1] = info[i+1][1];
    2 E) D( r4 ]" O- O: [info[2] = info[i+1][2];  d% |: q5 |2 c$ \
    }; L, E+ H, @5 M  F: g0 e
    num--;
    5 a( X+ ^2 U+ ]1 V1 a}0 V6 _3 C5 v+ P( J% e
    if(FLAG_show==0)/ [+ u+ V$ p0 u. `
    return 0;( V3 I& e3 u9 g* Q/ {
    for(i=0; i<num; i++)
    & W) q( S5 }1 @/ s( a) V{, D: ?0 ?8 }0 y
    t = (float)info[0];
    ! g9 m+ t4 |# b. j* F  R' \! Qtemp = (t/101)*90;
    7 R; ^7 }( \+ F! p' m5 q6 `pos[0][0] = (10-num+i)*25+x+100;; i! g# q1 Z; ~9 ~3 j3 T7 I2 h- q4 m
    pos[0][1] = y+110-(int)temp;. K) b* e' p% _2 e. w- H( M! M& S
    t = (float)info[1];( @; B( y! s5 @" O- I" s0 H3 z
    temp = (t/101)*90;
      ?, g& e8 p" y& ?% F0 n+ Upos[1][0] = (10-num+i)*25+x+100;0 q  X$ M* N( W5 V' u+ v( }0 q+ @
    pos[1][1] = y+210-(int)temp;
    # E1 a$ Z9 ?# ?9 y. nt = (float)info[2];
    * P& W' N2 H: w, Itemp = (float)(t/101)*90;
    9 @" V4 i+ ^; z1 |# ~! v, \pos[2][0] = (10-num+i)*25+x+100;
    % i$ L% Z; C- `" C/ g4 Npos[2][1] = y+310-(int)temp;
    / H/ E# {2 k) p+ [* C7 t}! r3 U" y' _# \$ k0 C
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)
    0 n8 p9 ]6 V1 x; S/ Y{
    * I: Q2 u/ b( t/ x" m" P( y! o$ ?clearrectangle(x,y,x+400,y+315);! A& P2 H8 N- g* u3 G8 h! \
    settextstyle(20, 10, _T("楷体"));
    " _+ x- @+ z1 A; C* P; ~6 E) M* xrectangle(x,y,x+400,y+325);
    3 h9 P5 }( I+ x! Touttextxy(x+40,y+10,"CPU");       //画柱状图" S6 L* q" c: t
    outtextxy(x+45,y+10+100,"IO");2 K9 ~+ s9 {* `- ^- a( i% G
    outtextxy(x+40-15,y+10+200,"change");
    3 I% Y% l3 H) |rectangle(x+35,y+30,x+75,y+110);
    , k9 s1 C7 ^: e& L, D6 nrectangle(x+35,y+130,x+75,y+210);
    : `; U( Y$ k" t' d. W7 \/ xrectangle(x+35,y+230,x+75,y+310);/ q: i2 b, j: M4 z9 G' A* E
    outtextxy(x+180,y+310,"TT");: w4 L" A; u- _5 `+ v
    t = (float)com;7 j: e6 U& k* t$ O
    temp=(t/101)*80;' k/ ?! f: S+ F# p) P6 ]9 q
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);' A1 Q. p8 M, N5 g: W6 T
    t = (float)wai;
    / p$ P/ L  i" }, e1 Rtemp=(t/101)*80;6 u7 U0 M9 l+ I# _
    fillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    : h- ?+ X- |7 S. U, ~t = (float)cha;
    / v0 S# I6 O8 [# F2 g; U" D. g- Q' dtemp=(t/101)*80;7 r# h* V# C) [8 L1 Q
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);# S0 q) b2 D% r3 v4 `, V
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    , F3 s# w! z9 Z{
    $ l8 D8 j, u, s/ J- R/ f9 {4 v1 d  Jline(x+100,y+110+100*i,x+350,y+110+100*i);
    - `4 }+ a) e6 y! n% v- \line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);& B$ ?) q/ ^1 i& `& M/ V" z
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);' k. m7 c% w5 Y( H  M0 ?7 s: m
    ; c( N# @9 @2 a
    line(x+100,y+110+100*i,x+100,y+20+100*i);
    / Y3 I; w' G9 ?( ~/ G; ~. Mline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);
    6 ]& D) z6 j4 }7 q4 ~# s' D% Rline(x+100,y+20+100*i,x+100+5,y+20+5+100*i);3 q! R8 ?$ Y! c( f1 u3 m% W
    for(j=0;j<num-1;j++)
    ( `8 W4 U. X  i8 }$ f9 b( a7 s{6 S9 q% Z6 E3 w1 W9 V0 E$ P
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);! h9 U' X$ t3 y' |3 _5 ]2 Q, E+ J+ \
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);- w! ]" U/ ^+ G0 C; q
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); : ~0 L' V$ s+ ]* l6 e0 ?, t- G
    }  k0 t" }8 `$ j/ r6 B" d
    }
    . x& Y( `: C3 ^. X3 D% D}
    5 x' z6 I1 O- X0 {. t0 q) t9 o1 xelse if(FLAG_TT==1)
    - }1 g  s& _+ m: Z* {6 P1 h{
    ) A$ y2 D- _, c  Z% n3 w, Bx=0,y=0;5 z' e& N" H: h2 \* Y8 r
    for(i=0; i<num; i++)& t0 m- `3 S3 p, \
    {3 Z& X4 A) g% v
    t = (float)info[0];
    ' d; o8 w' S- Stemp = (t/101)*180;9 G- k& l5 ?4 g5 s7 n# K/ @1 O6 \
    pos[0][0] = (10-num+i)*50+x+650;% n1 h' i% a$ ?. a% X
    pos[0][1] = y+210-(int)temp;) G, y6 B+ q) R" m" a
    t = (float)info[1];
    ! t$ A% q/ J  o* M% J$ s% Atemp = (t/101)*180;
    9 S7 h2 U5 C) J$ c7 G$ V+ W6 apos[1][0] = (10-num+i)*50+x+650;% U& X9 u/ ?+ C' O& @$ M4 O
    pos[1][1] = y+420-(int)temp;; {4 o. C* l/ D( p$ }' e6 Y$ _
    t = (float)info[2];5 _* \" f' g) V+ k  l, S* s
    temp = (float)(t/101)*180;
    1 V3 n) y# F, Hpos[2][0] = (10-num+i)*50+x+650;- b! t4 t  Q5 }$ I8 w6 o% t1 T
    pos[2][1] = y+630-(int)temp;
    4 q8 ]/ m( O+ f) n$ ?& O, \/ L}
    ( y+ F* q; h1 u, h- s' q. Y) Kclearrectangle(x,y,x+1200,y+650);% k" s* o" n, ^. ?3 H0 X
    settextstyle(40, 20, _T("楷体"));. X0 c. O2 W; H. V$ ^
    outtextxy(x+50,y+50,"TT");* Y; C4 }, k; t# V- O
    outtextxy(x+280,y+20,"CPU");       //画柱状图
    ) S7 w% S! X, {) h, oouttextxy(x+285,y+20+200,"IO");
      C# ~0 y8 S+ Aouttextxy(x+250,y+20+400,"change");$ w/ A, S. h$ L# T: p; @, D7 U
    rectangle(x+270,y+65,x+330,y+215);
    6 `! d) B* O2 x* `! K+ k9 u- Trectangle(x+270,y+265,x+330,y+415);, D. v. A6 h* v1 R# Y
    rectangle(x+270,y+465,x+330,y+615);/ k# d* g9 R& g6 ~
    outtextxy(x+290,y+620,"TT");
    3 }, |) g4 X8 f7 J0 dt = (float)com;
    7 W6 k7 N( L% A- {6 @- T" |: R# A" Vtemp=(t/101)*150;. @5 q6 Q' X, v  J" o! L
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);
    1 e) c$ H% V% e# V# Ot = (float)wai;- P" W$ j; C" [& `/ b8 U
    temp=(t/101)*150;. Y6 e! D0 u: T, K8 W+ @
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);
    # Y% ^+ w+ p1 j3 X1 \1 U# Q% S9 n$ ~t = (float)cha;
    ) c; l. G  o9 Vtemp=(t/101)*150;, h  |/ |: M0 V# o; ?$ R" @! ~
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    # v  W/ P. M3 P3 Q8 r9 A) P- vfor(i=0; i<3; i++)   //画坐标   high=90,length=250
    1 Z8 g2 p" Y% m1 Q{# A: s6 ?! n9 ~. `: x, I
    line(x+650,y+210+210*i,x+1150,y+210+210*i);
    - i3 Z: ~, c: ?  f: U! p9 Kline(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    " H9 H  b8 d: P" O3 kline(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);- c; q; ?& T3 {+ [, l

    5 ]6 f' w+ n8 E: t4 b: Aline(x+650,y+210+210*i,x+650,y+20+210*i);
    . _; V. M/ i7 j. y3 P# Mline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);5 J0 u; t7 K! ?' n% ~0 w) O* `
    line(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    8 N: ^' J2 t6 f& gfor(j=0;j<num-1;j++)/ r6 T- g1 Y! x. X7 F6 X
    {. b/ y9 W' g4 }. A" L% h
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);" k) ?8 A3 F- I6 k0 t
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);  t) T2 n% R3 F1 {3 a" Z" |# l
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); ( e3 e1 ?$ a. W6 P  h
    }
    0 p& v; C0 d) n7 P2 W" `0 c$ S}
    & ^% m, ?+ T( G. l+ e1 k/ e9 _* w+ b2 W}0 i; X% R6 d/ x8 q

    + J& Z9 h) _- n% P6 S+ j/ B9 m  q+ ^+ l* A. _
    return 0;
    3 o" K& M: O/ }; T' Y}
    & ?( Q. w. B; I8 q! g1 zint drawPerformance_PF(int x,int y,int memorry,int com,int wai,int cha)
    ; v6 i. n+ @* _3 C{9 c6 J. }* X# X& R+ A
    static int info[11][3],num=0;
    / V$ ^& b8 |; U' b$ Zint i=0,j=0,pos[10][3][2];0 \( y0 ~' C. }1 l2 h0 w7 `
    float temp,t;8 t1 q- m$ M3 s5 L0 _4 g
    info[num][0] = com;# }: L8 W& e3 z0 g4 h9 N
    info[num][1] = wai;
    % A* v+ Y5 {. C& cinfo[num++][2] = cha;
    % E- Y* l. v0 M8 F, ?if(num>10)  //存储10个点# u, `4 l5 u/ O4 E8 {% k! k
    {
    , j- R% d4 h! Kfor(i=0 ;i<10;i++)
    4 t) K  @8 o: D4 b{/ T0 I3 K4 a: E, [/ J
    info[0] = info[i+1][0];9 V5 [# j; [0 |, M) i: @
    info[1] = info[i+1][1];/ P; S/ {* l+ K" e1 S/ r2 I
    info[2] = info[i+1][2];
    : y2 z& d( ?' \8 r& J2 D, [2 F# y! R5 M}
    " F% w  L+ a6 r1 K3 l: lnum--;9 u2 T  }8 N9 d
    }3 p( ~% b, _  o4 k) l
    if(FLAG_show==0)
    6 Q5 D. V0 |, F6 }return 0;
    % O* I' p0 J9 M+ f* ?' N: u6 \6 ^for(i=0; i<num; i++)
      S5 z- y' e- }{& T+ X5 C% b4 [
    t = (float)info[0];+ I; B3 ?2 L/ E
    temp = (t/101)*90;8 }% e/ z; t' r+ v3 h
    pos[0][0] = (10-num+i)*25+x+100;6 z' u& d/ n6 w
    pos[0][1] = y+110-(int)temp;
    & p9 g3 s" O: qt = (float)info[1];
    . S  r7 D8 q& H; N8 b3 Q* ktemp = (t/101)*90;( x3 @/ f. a  N: U9 k2 u3 @% Y% _
    pos[1][0] = (10-num+i)*25+x+100;
    4 S5 u7 J2 @9 m+ `& l' _2 g. i1 @pos[1][1] = y+210-(int)temp;. d" Y8 u  L7 V+ d# d
    t = (float)info[2];
    9 U6 W: E# [/ v9 B: @temp = (float)(t/101)*90;0 X; V) b% b" F9 x' K& m
    pos[2][0] = (10-num+i)*25+x+100;( H/ R  @2 u4 Y& h( K; g; y3 @. l
    pos[2][1] = y+310-(int)temp;& Z) c& L: h. E$ Q% w9 n8 G
    }9 K/ y2 m; \- j1 s3 a& F+ [
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0): f% Y: ]2 E$ t% s
    {
    . V* M9 y, x6 U( w0 fclearrectangle(x,y,x+400,y+315);+ P7 m; H) d, W2 @8 `, @/ I; ~6 W4 u! v
    settextstyle(20, 10, _T("楷体"));
    5 _& ]+ D  O: Xrectangle(x,y,x+400,y+325);* r) i& N' d4 A; r2 G+ T: C* Q
    outtextxy(x+40,y+10,"CPU");       //画柱状图
    ) g" X# O4 d3 H# U) L* l+ |. ]outtextxy(x+45,y+10+100,"IO");  s' g7 I! ?1 e: R( p
    outtextxy(x+40-15,y+10+200,"change");
      t, E, P' F2 L" a2 \6 ]! Nrectangle(x+35,y+30,x+75,y+110);
    9 w+ B8 l7 d- brectangle(x+35,y+130,x+75,y+210);7 z" R7 }; G+ a0 @
    rectangle(x+35,y+230,x+75,y+310);
    & o3 K8 Q: ?: V+ w2 Aouttextxy(x+180,y+310,"PF");  ]6 N. m" g: W
    t = (float)com;( H& k9 p' y; C4 b/ k7 e2 x5 N
    temp=(t/101)*80;) Q' x2 c" P: A! l* {
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);
    ; V% z! Z; s! ?t = (float)wai;
    5 D5 n4 C  f7 h6 u( gtemp=(t/101)*80;
    : g# s& b% I  I9 ifillrectangle(x+35,y+210-(int)temp,x+75,y+210);: g5 k6 h; x0 W- n" K7 T
    t = (float)cha;
    " u1 Q) ?0 [$ ^1 x3 J; Ztemp=(t/101)*80;
    ! c8 u1 _: `, L9 d( X2 Kfillrectangle(x+35,y+310-(int)temp,x+75,y+310);! V- f* B8 i2 J9 T( j( y' n0 D
    for(i=0; i<3; i++)   //画坐标   high=90,length=250
    ) K7 W- v& Z% T  `0 {% u! [{8 g; ^# r6 N/ J
    line(x+100,y+110+100*i,x+350,y+110+100*i);4 y4 c. M& G5 J( V% A: Q
    line(x+350,y+110+100*i,x+350-5,y+110-5+100*i);  ]- }. N! R, N
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);0 d# U2 e( [& o$ R# k* R" K
    ' s5 W2 M9 M0 m& Y
    line(x+100,y+110+100*i,x+100,y+20+100*i);
      T1 e0 L) L( H  o  k6 Y: I4 e: Qline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);( j2 S4 P4 R8 e6 e6 O
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);, ~7 `, _# q9 }  f- G1 |! r- H
    for(j=0;j<num-1;j++)/ J& @% r3 f) }1 m. Y
    {" C* ^. S$ h! m8 i9 z
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);: z4 G- \) s% t  ^
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    $ @% r0 ~3 E- \, G& C8 z0 {$ Mline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    ! t. ~' [; f" j$ R3 n' r7 o6 Z}
    # {- K: ]4 H+ E& ?}! `5 h, z9 E( {- B9 ~7 N. I, K# ]" k
    }) q7 x+ Q: E+ Z4 p- J$ D9 E
    else if(FLAG_PF==1)2 B4 c+ E3 y; ?  h! C& |5 d3 {9 |7 v
    {
    9 d1 ~% o: R% Ex=0,y=0;  r5 r: g  m! S- ?4 J0 n
    for(i=0; i<num; i++)
    ) ]% g( o+ i5 O# d8 Q* o; S{
    * M+ C' W  N" D6 j, r# Ot = (float)info[0];
    2 }( O, o; b' {# r7 dtemp = (t/101)*180;
    % @- U  T" P, D9 x) epos[0][0] = (10-num+i)*50+x+650;" _" H3 t$ I0 G, a- D9 D
    pos[0][1] = y+210-(int)temp;
    7 P" @2 s" Q+ x$ H0 }" N; e4 a- C5 Yt = (float)info[1];6 m; G# x" A5 B& {! c
    temp = (t/101)*180;* \  U. m% m; r$ `
    pos[1][0] = (10-num+i)*50+x+650;
    3 l4 ]; Y0 n# u" m) Zpos[1][1] = y+420-(int)temp;
    * i  h% z. T2 }' m& l. ~t = (float)info[2];
    , z0 G" [0 ~2 j+ s  jtemp = (float)(t/101)*180;4 @7 u5 B! l# W# v& }8 }
    pos[2][0] = (10-num+i)*50+x+650;
    3 N6 S* H: E( _pos[2][1] = y+630-(int)temp;
    4 ^  Z, w8 E! M# T0 Q9 I}  K; m; R; |2 c' [' }9 e& k
    clearrectangle(x,y,x+1200,y+650);
      Q$ l) m& q' V! ^/ Msettextstyle(40, 20, _T("楷体"));3 d' Y- m& a2 ]( ~# W% M
    outtextxy(x+50,y+50,"PF");  K, w# @/ D: m# `" X
    outtextxy(x+280,y+20,"CPU");       //画柱状图' p; f) l* n6 D8 I
    outtextxy(x+285,y+20+200,"IO");
      g+ C3 o, C  H/ M) n7 souttextxy(x+250,y+20+400,"change");
    " Z( R( w5 N3 m. J* ]+ V! n" ?  Wrectangle(x+270,y+65,x+330,y+215);8 i* ^4 b4 K# {6 ^7 A
    rectangle(x+270,y+265,x+330,y+415);: Z& J) \' U& E7 ?; h
    rectangle(x+270,y+465,x+330,y+615);* x" P  u6 |% n$ v$ X; R
    outtextxy(x+290,y+620,"TT");
    6 ]  p3 Z* f% j& R/ et = (float)com;
    3 n# ~% }; Z" Y+ K7 z! Stemp=(t/101)*150;' Z- T7 m( k- y+ b  I- i$ [
    fillrectangle(x+270,y+215-(int)temp,x+330,y+215);
    ! t/ k9 x2 x. G" O6 B3 I3 o* Qt = (float)wai;# n* H9 y0 s, A; V+ X: A
    temp=(t/101)*150;8 M" y4 ?% w9 e* h3 }  n
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);2 u  W% M: x8 N) @  p6 ^) g( [
    t = (float)cha;
    & `' \8 Z, M9 u' ~  L: G# Itemp=(t/101)*150;
    0 N2 Q  u' V6 S2 M7 c' Ffillrectangle(x+270,y+615-(int)temp,x+330,y+615);
    $ t  z9 m( p6 }for(i=0; i<3; i++)   //画坐标   high=90,length=250+ \2 n( S& j- a4 t
    {
    " d$ I  k, t" F6 d5 dline(x+650,y+210+210*i,x+1150,y+210+210*i);5 X6 b2 \; H6 Q) g* @2 E3 ~4 E; l/ ]
    line(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);7 o$ W3 l. D2 L
    line(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);0 D- `4 I7 B) T5 s9 y! v
    ! R- A: y; ]( Y1 D9 i9 a
    line(x+650,y+210+210*i,x+650,y+20+210*i);
    $ n& W/ w: z# u# q% Y! @2 b9 Z, Cline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
    & l( }! |/ M2 |3 a2 n: D% Aline(x+650,y+20+210*i,x+650+10,y+20+10+210*i);
    ; ~0 Z0 v; `: D. ^for(j=0;j<num-1;j++)# T9 E0 \' {' h/ X* K( ?
    {& v! N& D. ?) R" i
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);, {8 J/ |& H9 \9 a( s8 e
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);6 a& o, I9 R0 }: a
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    5 u. p7 I0 d- a8 X}/ y$ d/ `7 U" t* |7 G
    }3 @! X$ {! D% P7 w0 p+ n; d9 {
    }' l1 G) v# ?. V7 Y
    return 0;
    " Y. [! a! P; S2 n& l}5 O3 Y) t$ Q9 M- @$ c& p+ {
    int drawPerformance_SJF(int x,int y,int memorry,int com,int wai,int cha)
    $ E  a9 p, K, V0 V2 i6 t{
    ) `1 J" w* E8 N2 {' |* xstatic int info[11][3],num=0;$ f+ S( R% P( U! P  x) G, H# [
    int i=0,j=0,pos[10][3][2];
    # H. U- e) j+ A" y8 e* Qfloat temp,t;; T  j! I7 g; r4 {) I. N) A2 J4 Q
    info[num][0] = com;8 U  [) `) T: h2 l8 v
    info[num][1] = wai;
    . j% M& u( O0 W6 r" cinfo[num++][2] = cha;2 j9 D/ U# p; E8 O1 ]  c
    if(num>10)  //存储10个点
    1 Z* W$ y2 q8 y' e' E% J/ _{
    * C5 S* i: G4 ~; N8 Gfor(i=0 ;i<10;i++)" I7 w+ l5 f3 s' ^' \5 l
    {
    4 C$ E, E/ A: G: U9 qinfo[0] = info[i+1][0];
    # I+ `/ z- ^. \$ k  l' hinfo[1] = info[i+1][1];6 x( N3 o; a! }! u
    info[2] = info[i+1][2];4 G' K2 x' w! O
    }  G* R6 p4 g! L0 j) F
    num--;* f: ~) f9 @9 v9 P
    }
    ) X3 ?5 ^( A: I7 ~if(FLAG_show==0)
    , {: k: D' Q( ~) n9 n8 q8 n9 preturn 0;+ y' k( ~( M4 X5 I; [: T0 q. J4 R
    for(i=0; i<num; i++)* Y8 K' _0 R5 ]# y5 X. P& ?
    {
    8 L; V. ~2 Z$ b) D& g5 a/ `5 ~' ht = (float)info[0];2 n5 {+ O5 e! v" n+ U6 [" h
    temp = (t/101)*90;; I/ M. t8 N# F$ u% ~
    pos[0][0] = (10-num+i)*25+x+100;" a. H  J& V, w. }3 q
    pos[0][1] = y+110-(int)temp;
    $ w* U. {* h$ ?2 A* N. L/ tt = (float)info[1];
    + P6 G' z) t* s7 ]' Utemp = (t/101)*90;
    3 `9 T- U9 j6 \pos[1][0] = (10-num+i)*25+x+100;
    / j) h0 j5 b  [7 L) Jpos[1][1] = y+210-(int)temp;- a$ q' e' D4 u8 P  ~# L* I: @) _7 c
    t = (float)info[2];
    1 r$ `" m9 n. W9 k7 s& {9 a' K  Xtemp = (float)(t/101)*90;: \$ O8 y3 I  K6 v& c
    pos[2][0] = (10-num+i)*25+x+100;4 r! U2 X: e1 U' Y4 X
    pos[2][1] = y+310-(int)temp;6 b4 Y  f) |+ r. v4 ~0 Q: a7 H3 ~
    }! T* E9 E& g" `3 @0 c' E6 w/ ]
    if(FLAG_FIFO+FLAG_HR+FLAG_SJF+FLAG_PF+FLAG_TT==0)  i. J- |5 K- I5 ^0 A
    {
    0 X' X4 _' X& Y) D0 K. yclearrectangle(x,y,x+400,y+315);8 H- l# _' z& o" Y8 R  B
    settextstyle(20, 10, _T("楷体"));* t! h" D2 V7 g6 ~- W# v; m2 F' X0 ~
    rectangle(x,y,x+400,y+325);
    5 B2 `0 L  i6 v" ?outtextxy(x+40,y+10,"CPU");       //画柱状图  d" L9 |3 ?# B& R
    outtextxy(x+45,y+10+100,"IO");
    0 @# Z5 z4 N) g  |outtextxy(x+40-15,y+10+200,"change");
    + u8 z. V2 e7 j0 Y% w+ `2 [rectangle(x+35,y+30,x+75,y+110);( H7 `1 G8 r9 ]2 U; B
    rectangle(x+35,y+130,x+75,y+210);8 A4 P* `% M. y+ Q" A  Y
    rectangle(x+35,y+230,x+75,y+310);$ k+ L4 J1 |; P* d" q7 F7 d7 w4 B
    outtextxy(x+180,y+310,"SJF");2 k0 r3 @. `3 s1 p. ^2 [
    t = (float)com;
    9 _' e# E, Q" F  Y; Btemp=(t/101)*80;. {1 A2 {0 T* Z7 X7 h) T8 b. ]
    fillrectangle(x+35,y+110-(int)temp,x+75,y+110);
    3 R  ?3 `/ q0 C+ Jt = (float)wai;
    ! k' ?2 ?2 U' z! X3 n$ j7 Gtemp=(t/101)*80;
    - F7 V/ t2 @) Q8 jfillrectangle(x+35,y+210-(int)temp,x+75,y+210);
    8 Z; e3 u' l4 S, b. I! k" Ut = (float)cha;) D0 q- {0 R. J9 \/ a
    temp=(t/101)*80;/ R0 ~5 F; }5 r4 c( R2 z
    fillrectangle(x+35,y+310-(int)temp,x+75,y+310);
    % f3 X4 w9 y8 f/ R' tfor(i=0; i<3; i++)   //画坐标   high=90,length=2502 G, F. i, g. w1 B
    {# h5 a- t% _* M" ]
    line(x+100,y+110+100*i,x+350,y+110+100*i);
    . ]! A, i" S3 s5 B) V; u+ [2 Nline(x+350,y+110+100*i,x+350-5,y+110-5+100*i);9 l8 x% c$ ~, j- _% M' M, a$ I
    line(x+350,y+110+100*i,x+350-5,y+110+5+100*i);( z* p* c9 h8 a7 V( B: Q6 N  v

    8 r  j" k5 f4 v$ |% S7 X5 ?" E/ lline(x+100,y+110+100*i,x+100,y+20+100*i);
    ( r6 d3 |, h9 K) A+ ]) i! e" X) aline(x+100,y+20+100*i,x+100-5,y+20+5+100*i);6 \3 p' t9 q& p# g) B) ?6 `1 H
    line(x+100,y+20+100*i,x+100+5,y+20+5+100*i);+ A7 L9 b) i; I
    for(j=0;j<num-1;j++)" w- G8 W3 `& ^
    {/ C$ ]! Y4 b5 j3 d. A
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);% T( x+ h8 u6 i* V3 l
    line(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);
    ! [& n9 @6 H8 W% {. ]# ]% Jline(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]); 7 d* B" o, |3 B  i6 l" m
    }4 F5 u; B1 S$ w( f( O
    }4 ?: s; a( _( f8 t" T
    }" S8 ~0 o- ~9 Q$ |
    else if(FLAG_SJF==1)2 _4 G, g" n0 Q- H& f; v
    {  N* h/ j; y: Y. ]
    x=0,y=0;
    + b- Z9 Y+ Z; O* w9 L! ^8 j8 i  Yfor(i=0; i<num; i++)
    . b. A' u, n9 N% f% a2 G$ G* W- {{
    + K7 S# S6 \7 u8 i( Ct = (float)info[0];+ c3 A# U6 H0 v! D0 @6 u9 Q
    temp = (t/101)*180;
    % X, h+ S$ v$ L! ^$ }pos[0][0] = (10-num+i)*50+x+650;" ~: @2 t/ ?, T
    pos[0][1] = y+210-(int)temp;3 }% h9 I7 t( f  P6 g$ y6 q& {; o* W
    t = (float)info[1];0 t7 {& q. \* t: U! E
    temp = (t/101)*180;! C: o2 h, Y& X+ J* K( I- K
    pos[1][0] = (10-num+i)*50+x+650;  }. X' ?5 x( S
    pos[1][1] = y+420-(int)temp;
    / {# Y- P" p$ n1 e6 D8 _4 Kt = (float)info[2];: J# O) c# Y2 I* t. L7 I, D) Q
    temp = (float)(t/101)*180;0 S% k! ]* \: L+ y- {$ ~$ W
    pos[2][0] = (10-num+i)*50+x+650;. a- K4 i) }7 k3 ?% r
    pos[2][1] = y+630-(int)temp;
    $ a9 O% O+ a" \2 ^( M0 G}9 H3 E1 ?, z% r" x* w
    clearrectangle(x,y,x+1200,y+650);
    + |! {$ I7 z3 asettextstyle(40, 20, _T("楷体"));
    9 h; Z- d0 m/ D, |outtextxy(x+50,y+50,"SJF");
    1 m& }& T8 o. Q7 Q5 L. nouttextxy(x+280,y+20,"CPU");       //画柱状图
    4 O: ~* a( n! X& E9 aouttextxy(x+285,y+20+200,"IO");
    " R8 \) o% V4 Youttextxy(x+250,y+20+400,"change");
    ' M5 L2 u- j: J3 [' ]8 Z, _rectangle(x+270,y+65,x+330,y+215);% l& i9 [, z3 \8 i+ n
    rectangle(x+270,y+265,x+330,y+415);1 e5 r& ~' ~5 J% B% T2 V1 s
    rectangle(x+270,y+465,x+330,y+615);9 `  w1 w2 V$ f  A/ n/ H# ~
    outtextxy(x+290,y+620,"TT");7 s5 h6 U, \+ l
    t = (float)com;/ h7 [; c4 L& w! \
    temp=(t/101)*150;
    $ j( [+ F% h9 w$ Dfillrectangle(x+270,y+215-(int)temp,x+330,y+215);7 t0 u$ v" u$ s7 }8 ]; ]
    t = (float)wai;* n- E" N# t( Q$ H) D
    temp=(t/101)*150;7 a' e+ @  D4 m* @9 {
    fillrectangle(x+270,y+415-(int)temp,x+330,y+415);
    * D0 S9 O$ |4 l, ]% w9 o; ut = (float)cha;8 o& g8 \: I- j6 @+ n$ E& u
    temp=(t/101)*150;: j- E1 t* X+ v; ?$ i
    fillrectangle(x+270,y+615-(int)temp,x+330,y+615);; N, ~) d' I1 L) T% [
    for(i=0; i<3; i++)   //画坐标   high=90,length=2503 }% g  N" Q; k4 b' b. X
    {! s5 N) \4 d% ]% i; ?
    line(x+650,y+210+210*i,x+1150,y+210+210*i);
    . x$ M  c2 r' B" ]- G  S: Jline(x+1150,y+210+210*i,x+1150-10,y+210-10+210*i);
    . ~- ~8 F# @- g5 vline(x+1150,y+210+210*i,x+1150-10,y+210+10+210*i);* V1 y& e1 ?. F) S& o
    - ^: i8 t2 X2 {+ H& I
    line(x+650,y+210+210*i,x+650,y+20+210*i);
    $ d( A+ t" T, p: O/ s  wline(x+650,y+20+210*i,x+650-10,y+20+10+210*i);
    + h+ m' K# c+ q( X$ o$ M& E  nline(x+650,y+20+210*i,x+650+10,y+20+10+210*i);' H4 |8 E% P1 ^& e- \. l
    for(j=0;j<num-1;j++)
    , w: E& q7 w( _1 s{1 b" e7 X; d1 F" u
    line(pos[j][0][0],pos[j][0][1],pos[j+1][0][0],pos[j+1][0][1]);
      [6 u. E2 e! b3 {  Fline(pos[j][1][0],pos[j][1][1],pos[j+1][1][0],pos[j+1][1][1]);: J- j! A0 `/ R( ]# K* J. l
    line(pos[j][2][0],pos[j][2][1],pos[j+1][2][0],pos[j+1][2][1]);
    # z& g2 T" P4 _3 l}
    & T8 Z( ]( w: y/ ~}
    ' i3 h* }6 x' R7 F+ f7 }}
    3 e- E$ x- G8 r! q& Z- [) Oreturn 0;# F1 ~5 }. W& ], h- w
    }4 X. h- ^( J: L0 e- i4 X& _$ y
    int High_response_ratio_dispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)# X& q1 n: Z# t! O8 H4 {
    {6 L% n) L$ k+ F$ x' ?) Z
    static int compute=0,waitio=0,change=0;
    ' B0 I. F. I5 z9 V; n7 C6 xstatic int computeLast=0,waitioLast=0,changeLast=0;5 \; }% D* K1 i8 E* \0 w
    int i=0;" B2 g. }, q( m% h8 `1 q2 j
    if(draw==1)1 u: H6 b+ o# J- }
    {
    7 P- S0 b# V0 D//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    7 j* _, e* s' p1 P/ NdrawPerformance_HR(400,325,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    8 F0 \+ h; C3 S: M: f7 `) a+ w7 DcomputeLast=compute;( o3 P2 B' g6 n1 y  z1 q/ A
    waitioLast=waitio;
    5 G+ }) b) r0 t# X$ dchangeLast=change;
    ) B. Q: x5 c5 F! p1 _% o. D}5 _: \- ], R( C
    if((* memory).p[0].flag==ready)
    ; ^% z" T$ K$ {/ R! [. M2 K; Q( i(* memory).p[0].flag=computing;6 V# ]' A5 n3 h4 `, r( S# v% z6 {
    if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing); M# c1 X9 b' @7 M
    {
    % q! k" G. u4 d  di=(*memory).p[0].computeNum;2 w; ^/ X4 l' B( O  ~5 T
    if(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed
    - U+ v8 j2 n0 n4 ?7 ~- ]9 d{
    $ q: O4 i/ w' O# Z5 U(*memory).p[0].flag=IO_waiting;  J8 Z: t) l: O( ~0 A7 d4 {( J
    (*memory).p[0].computeNum--;
    7 f, P) B$ z/ J, |: @  U: Jchange += exchange_IO_Compute;  |* ~% Y  O$ G7 c) ], C) G
    compute++;
    * g$ y4 K4 X0 a1 F}1 d' S, O0 I9 ~- z) q' t
    else
    7 u+ v/ Y' ]0 K6 u{
    & R; I4 z2 o2 d2 Lcompute++;7 h0 Y2 x9 l. L/ l
    }
    " Q: p/ D8 O3 o# Q4 _' h7 M) O}4 h) k( h0 s! o$ S/ y' [2 d
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)
    8 c+ p' x/ W1 v{, R4 f# K- \" p; N3 i; m* U% x3 S
    9 ?7 N% i2 N4 C0 d5 f" V7 R
    i=(*memory).p[0].ioNum;& J4 f5 I: j% x& w
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed
    & X! m; G/ r! L3 ]{
    & h% ^4 z# b2 D6 w& ~3 C" K(*memory).p[0].flag=computing;" p7 F2 E  F' u! N1 h
    (*memory).p[0].ioNum--;
    6 i! Q" y6 W, p) Y4 H6 y1 o) p: l- zchange += exchange_IO_Compute;
    7 X. R1 u% n7 k9 N* ?waitio++;
    " s  n' M6 o$ Q5 p- E# X( c}+ q5 f2 g0 X& ]8 H! n5 C
    else7 c' c- ?2 h' |) R% }
    {, F9 n8 F; x' A) y) K# ?
    waitio++;
    ; e5 w6 \: W( y}# w. p% X( a$ v0 ?
    }
    6 U4 t+ E' e1 K% a3 P4 N/ f& K; \1 Delse if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)( o. ?- V# m: }) {7 F* J6 L( X
    {
    $ \9 s) r* w( `* \6 s! z1 p# f0 {: Y! j(* memory).p[0].flag=IO_waiting;
    & M% r2 a9 ]. }* T3 I- Ichange += exchange_IO_Compute;
    8 B9 \( x6 K4 M5 C3 U2 X6 x. m}
    & w/ \, B9 Y! k0 ?4 n/ m+ Felse if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)
    " N' M) _* O& G. ]{1 o  n1 h/ T7 ^! |3 V1 R4 `4 ]. p
    (* memory).p[0].flag=computing;  a: N2 V" K+ C/ x# D
    change += exchange_IO_Compute;' @/ U* N/ ~+ a( @- e7 l& F
    }
    5 ?: }) K' w; I6 X  d: u8 jif((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成
    9 J8 [+ \8 l- l" b7 w6 a9 Z$ w+ }( x{" j* Z- ]4 m8 c  S  v
    (*save) = (PCI*)malloc(sizeof(PCI));
    " c6 R+ i5 `  T- Q( F+ J(*save)->next = NULL;& w; S! C  E0 @" _: p
    (*save)->processID = (*memory).p[0].processID;
    5 C5 S: c+ F, E* }0 A6 K! k* ^% h: D3 u(*save)->comeingTime = (*memory).p[0].produceTime;: \, E! Y. u/ f# Y
    (*save)->askMemory = (*memory).p[0].askMemory;
    9 ^2 I. U7 O5 j* z# s- h9 }(*save)->compute = compute;
    ; H* @1 |7 n$ o: ]+ u(*save)->waitio = waitio;
    # f0 Y2 t" A2 l8 e1 _: n. g(*save)->exchange = change;" s( Y3 n4 Z! O% S* @7 Y  q
    (*save)->completedTime = systemClock;
    3 f6 r! t7 N- s3 O(*save)->runningTime = (*memory).p[0].runningTime;7 ?7 k9 `0 m7 a8 T0 \2 J
    *spareMemory = MAX_MEMORY;         //*spareMemory + (*memory).p[0].askMemory;
    + r0 I+ X  H6 M, {0 q' {compute=waitio=change=0;
    # }1 M/ ]; U* Q7 I4 s* ~" PcomputeLast=waitioLast=changeLast=0;
    : T4 G& E. G% D" [/ ?/ v2 F2 kHigh_response_ratio_s_to_m(&(*storage),&(* memory),&(*spareMemory),1,1);
    5 ?  D& m. `1 }# G( y6 Hchange += exchange_process;
    1 i* D! H, |% S% }/ g& Greturn task_completed;1 D6 O, c- Y' L9 }
    }
    + `5 Y4 v/ _( U6 xelse. E: {+ Y* P, a
    return task_not_completed;$ \) R7 ]$ l. n* I/ c
    }. w2 Y/ y8 _3 ^3 }8 |! e6 n
    int High_response_ratio_s_to_m(processPool *storage,processPool* memory,int *spareMemory,int flag,int dispatch)
    & G% m6 v2 {: X# e$ s" A& ?3 q/ r{
    ! k) A9 l  u+ ~# }; {static int waitTime[initProcessNum],i=0,j=0;
    ) X. ~: g+ F, ~; |) L, w1 J* gstatic double HR_ratio[initProcessNum];
    : E8 `; }0 b/ I& B, qif(flag==0)                    //初始化数组  z' J. {/ b3 B) y+ e# ~0 K
    {# M( [3 K: k5 o/ S/ z( W
    for(i=0; i<initProcessNum; i++)
    % W' V3 |0 L( Z8 k8 p6 F{! Z) |+ Y+ O6 ~. c! L
    waitTime=0;3 G4 a3 H& }% M
    HR_ratio=1;5 ^  i7 |0 h" F4 M# \/ i
    }
    ) S) Y$ J. ^8 g% c}
    8 o3 p- `" ^2 A. h9 x# c" n3 y- Tfor(i=0; i<(*storage).proNum; i++)  //等待时间增加,重置响应比( W' J% X9 m7 X3 b" u5 B# R7 e5 o
    {
    / g1 A, i2 R0 \0 G7 X3 [waitTime++;
    9 {% O: @; T# g( {% zHR_ratio = (waitTime+(*storage).p.computeTime+(*storage).p.ioTime)/((*storage).p.computeTime+(*storage).p.ioTime);
    " V# ~4 R9 F. @) |# q: s8 ]& Dif(HR_ratio > HR_ratio[j])3 ^% Z0 Q' F* {; E: w9 o
    j = i;5 m# e* f- l* v$ t/ d
    }
    ' h- \% E6 p/ ]( r4 T3 {if(dispatch==1)                    //需要调度一个进程到内存中执行
    ' K+ H8 J2 v0 k, u& P  I( @& n9 v{
    7 x/ w3 D+ c+ ?% L. zif((*storage).p[j].askMemory < *spareMemory)3 n% l- t9 }' D- v& V
    {
    , j# [* B1 p9 U: f" s  C9 T(*memory).p[0].askMemory = (*storage).p[j].askMemory;& X2 s& v/ n& i, A
    (*memory).p[0].comeingTime = (*storage).p[j].comeingTime;
    ' I+ F3 @3 o0 @5 M" {(*memory).p[0].computeNum = (*storage).p[j].computeNum;
    3 m& y% I4 U0 r1 G# g1 m2 o1 ~(*memory).p[0].ioNum = (*storage).p[j].ioNum;
    1 J- R( }( M6 C3 r+ E. T4 l(*memory).p[0].processID = (*storage).p[j].processID;
    , K) o( e4 L7 O* |, d# r: \(*memory).p[0].flag = (*storage).p[j].flag;
    2 c' O1 |! D9 P9 g, s(*memory).p[0].ioTime = (*storage).p[j].ioTime;
    ' {# [$ j7 c; Q, t- y5 E% L! h(*memory).p[0].computeTime = (*storage).p[j].computeTime;# J+ N7 @8 ^4 [2 d$ x  ~; _
    (*memory).p[0].runningTime = systemClock;
    0 J  w$ E5 X: Y! l2 ~(*memory).p[0].produceTime = (*storage).p[j].produceTime;
    5 i# V( S( ~8 T6 l+ |% Dfor(i=0; i<(*memory).p[0].ioNum; i++)2 Y3 C5 y' x% T0 f& Q1 ?$ d6 t, K
    (*memory).p[0].ioClock = (*storage).p[j].ioClock;
    " z2 s! d1 ~! ]# [) m( Z) A% \! yfor(i=0; i<(*memory).p[0].computeNum; i++)* \. v" r- ^! D" N7 a3 H# t
    (*memory).p[0].computeClock = (*storage).p[j].computeClock;; J& |5 J* c7 j: g
    (*memory).proNum=1;' w& x5 l, l# Z7 U& X+ [0 \
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;
      ^% a) e5 e9 ]% T% o  [produce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程' @2 Z7 a; w5 Y  c/ ]' Q
    (*storage).p[j].produceTime = systemClock;
    2 v% `) b8 W: C3 v* Y' eMAX_COMING_TIME = (*storage).p[j].comeingTime;
    ( z# A, ?3 q+ E0 cwaitTime[j] = 0;
    + G; a) j; x1 j: E3 i" gHR_ratio[j] = 1;' s2 \% N9 y. m
    }
    # n. u; h' {7 H7 R% L* nelse
    ( K3 K: ^( f# u4 V3 e% v% P( W{/ t5 W* P, D, ]
    printf("A process ask for a memory overed the system capacity\n ");
    0 r3 {# p; M& j" M* C) gexit(1);
    9 K1 z! b1 A: b# A# `* T}' k7 B4 s9 A+ ^7 o, E+ N- @, _
    }$ F+ b1 {. n& J1 f% X& g
    return 0;
    & a+ @: \4 h( L, }: l$ M; g. H- D}2 s0 y7 G, ]" ?* V' I
    int PriorityDispatch(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)8 s5 y) C' W7 \/ C- x& S7 d2 r8 x
    {
    0 Z0 {3 l9 h& Rstatic int compute=0,waitio=0,change=0;
    / I. m& _$ @- b8 A, ?static int computeLast=0,waitioLast=0,changeLast=0;
    7 O/ j3 W# Z- w: u6 f9 l: f! Bint i=0;+ I, r$ ^% \; [8 h9 B8 D2 a+ x7 m* A
    if(draw==1)9 j# S+ z( p. Y5 N8 d9 V
    {
    % [1 Y5 j. X. i9 @5 L//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);4 F( ]8 x" H0 v1 E' T4 J
    drawPerformance_PF(800,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    , M& V* g) w) X
    . L9 B2 f) x4 I- N, h& S6 M! E% _
    7 T8 X6 I9 ^  _computeLast=compute;
    6 f- D6 e3 u6 G# U  ~waitioLast=waitio;
    # t& Q! I. Q  `  n! `* ]0 vchangeLast=change;, a' W& ^, x1 c% j" W
    }( g9 S1 N7 h+ |
    if((* memory).p[0].flag==ready)
    1 L8 B; B$ v0 i! H$ A(* memory).p[0].flag=computing;
    # T; r0 K, F- t$ U, V$ d7 zif((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)
    5 }9 G+ ]+ ~% r5 w# n{
    % ?4 i6 H* b5 x6 |0 ti=(*memory).p[0].computeNum;
    7 L# W2 ~3 v# R/ x. z# D7 s! T$ iif(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed
    2 j4 T% }& Z& ?1 B# G- `0 @{( C1 K/ `0 U. z* w
    (*memory).p[0].flag=IO_waiting;7 r; w! y; A* u: x: }# P- R
    (*memory).p[0].computeNum--;
    + x: H4 `0 N* a  h8 V% r) j  A7 lchange += exchange_IO_Compute;
    6 L* z/ J$ c( Tcompute++;  w$ G) c9 a3 {' ~. \9 O( ~, f
    }. S) `5 T0 ^4 d
    else; m$ g" D0 O: y& B- ^6 d8 z
    {
    $ d6 k/ `" {/ Acompute++;  E' J6 k$ p: n! k
    }/ C; O- g  L( k# {* D1 j
    }
    & T2 E& A/ V. ]6 [6 xelse if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)
    5 c' _) E" t7 {/ o9 T! c{, A! i& i& n/ P* x

      o9 g0 F5 a" h8 @/ [* {) b# q7 w; hi=(*memory).p[0].ioNum;' B  c- G1 `+ {9 \+ i2 W
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed: Q2 W8 ]2 H, j" q3 D, t
    {
    4 C. o5 o/ w# ]  v8 M. ~; V(*memory).p[0].flag=computing;
    3 U$ s0 b8 f, i# N7 O(*memory).p[0].ioNum--;
    3 _( F5 {$ p- S2 l% V& X4 J1 lchange += exchange_IO_Compute;8 C! \; l- H0 i7 J& c
    waitio++;
    4 l) P) m8 a$ U}/ `' |2 e7 ]1 \. R) y3 R# B1 H
    else3 q, a* C8 B" d" I9 o6 @, r% _/ k
    {6 [9 ^6 H7 d2 Q4 `2 f9 c
    waitio++;
    2 E, d% N$ |# {8 u  v}
    ) A" H" c9 k# l$ c0 r}- ^" ], N" K3 s$ q2 W  A
    else if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)
    / l4 A) v2 w: `4 B{, ~  A8 o8 K% M
    (* memory).p[0].flag=IO_waiting;" K+ n2 t/ O$ Z: i+ Q% f! C+ k
    change += exchange_IO_Compute;" v  W7 S7 V0 C5 F! c8 o
    }5 c- t3 b' v& P* g# M
    else if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)
    + t7 F3 f2 x8 u# b{
    + F, [$ H# b$ ~6 U7 m) Q(* memory).p[0].flag=computing;- b2 k1 a' P3 j
    change += exchange_IO_Compute;
    / m( T0 s$ i( |, y+ K' x}. m' }. p# {" f" s9 B! B* r# T6 p
    if((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成
    . y. l& ]# y$ d( B, R& I& G{) @  E; \) Y0 P
    (*save) = (PCI*)malloc(sizeof(PCI));1 D; [0 W! m, F8 ]3 d. b  t
    (*save)->next = NULL;
    , H" T( r" u7 h$ b1 s(*save)->processID = (*memory).p[0].processID;4 i' P# B0 j) z8 a* w" _0 j
    (*save)->comeingTime = (*memory).p[0].produceTime;9 p: X2 c) X! ^* r& L! I& \8 p9 n
    (*save)->askMemory = (*memory).p[0].askMemory;* z% ]* p& ~' ]+ _/ n
    (*save)->compute = compute;
    # d& q& r# A$ v" K(*save)->waitio = waitio;
    & d6 p; x  B4 _(*save)->exchange = change;
    % ~8 z7 c! y, w6 f1 F(*save)->completedTime = systemClock;/ D; G3 C9 n  f5 }5 M0 z
    (*save)->runningTime = (*memory).p[0].runningTime;0 z2 f5 G2 r5 a2 R
    *spareMemory = MAX_MEMORY;      //*spareMemory + (*memory).p[0].askMemory;9 J1 [. J! T; ^- Q& n7 _/ P8 b
    compute=waitio=change=0;
    # P6 u. y" w8 V; l- x9 ZcomputeLast=waitioLast=changeLast=0;$ U, f' M/ s. M: \) _9 E7 C) M
    Priority_storage_to_memory(&(*storage),&(* memory),&(*spareMemory));& d+ `# {/ K/ Z0 S* j' m
    change += exchange_process;
    ( x" W( a& l  g. B8 u% kreturn task_completed;
    ) K$ X# c1 E3 d9 K}! b7 ?- @, j2 X" ~* k, s0 I2 r
    else
    ( p6 i. x  I' @% i1 Freturn task_not_completed;" t( \" |; M1 v5 E6 Z- Y
    }
    ; y+ ?: P$ r4 N% Gint Priority_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory)( J, r  l# v* y
    {
    ' w1 w7 z2 t- e5 rint priorityNum[initProcessNum],i=0,j=0;
    * l+ H9 S$ v  w4 j. q& x2 zdouble temp=0;5 [' T- ?3 n( \% s8 B
    for(i=0; i<(*storage).proNum; i++)    // setting priority to each process
    . V8 L# A5 `" Z- B$ W{8 Z5 N7 e1 q/ U* n% u* T& P. p, \
    temp = (*storage).p.computeTime/(*storage).p.ioTime;
    7 }! q# f7 W# _if(temp > 0.8)4 ]8 d* k1 A. s' v, k, u. G2 E
    priorityNum = 6;
    8 o7 u. c8 S" j/ C, Melse if(temp > 0.7): K) G1 V/ Y7 `9 F
    priorityNum = 5;% c2 n# N+ o/ m( J1 K2 q1 J
    else if(temp > 0.6)
    0 ~" V: ?0 Q0 H# ?priorityNum = 4;
    ) f- F7 t. p% D2 S* eelse if(temp > 0.5)
    ! N' R  j0 O$ JpriorityNum = 3;. S9 N+ A9 h, m2 x( q( O8 `
    else if(temp > 0.4)
    6 U( p  r. ]- n9 s  k. R4 d0 IpriorityNum = 2;$ j4 i& R# E7 t" }' Q, @7 ]6 `( I9 R
    else
      h: `6 v% c" FpriorityNum = 1;
      f' W5 i6 x! ~, E' Iif(priorityNum[j] < priorityNum)
    ' F+ f2 v6 m& t  A: G3 m# n: q% \; dj = i;9 Y) y+ }! ~; `3 R7 L
    }/ c2 g8 Z; _* T& W! V; v  @' U
    if((*storage).p[j].askMemory < *spareMemory)
    % o) ]) d. G, w) w! M* K$ q{& i. m( A2 Y3 O; B7 P. G+ }- R
    (*memory).p[0].askMemory = (*storage).p[j].askMemory;
    8 l# ^' t7 h# Y9 B6 D5 d( m(*memory).p[0].comeingTime = (*storage).p[j].comeingTime;) T5 z$ A5 |1 Q0 G% g
    (*memory).p[0].computeNum = (*storage).p[j].computeNum;( T$ D8 x( ^4 H- O9 d
    (*memory).p[0].ioNum = (*storage).p[j].ioNum;5 T, s4 x# j" Z$ k1 Q
    (*memory).p[0].processID = (*storage).p[j].processID;
    0 g$ U. ?, Q- H2 ]( Z(*memory).p[0].flag = (*storage).p[j].flag;
    5 O* T+ h* Q. j* R# _0 S8 _(*memory).p[0].ioTime = (*storage).p[j].ioTime;, `! m9 w. ]3 P& C) `
    (*memory).p[0].computeTime = (*storage).p[j].computeTime;
    * B9 s: w" m6 g5 W, B$ P& [(*memory).p[0].runningTime = systemClock;  {; ]) J) O4 a9 U- z1 Q" o
    (*memory).p[0].produceTime = (*storage).p[j].produceTime;7 ?4 y5 f# ^) e# Q+ l, y3 }  H- k
    for(i=0; i<(*memory).p[0].ioNum; i++)
    & X' p$ X% T0 `- X6 H, @4 ]3 {/ i(*memory).p[0].ioClock = (*storage).p[j].ioClock;6 W0 Q( ?8 X0 O$ C
    for(i=0; i<(*memory).p[0].computeNum; i++)
    ; V3 Y- a6 B/ \* Q& u(*memory).p[0].computeClock = (*storage).p[j].computeClock;; H0 ^/ h$ i) o, D1 ?
    (*memory).proNum=1;- Y" j) B$ W/ w8 {( l( S1 c
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;
    " X0 v6 p* G& B4 w( {' D0 @+ ~0 U" aproduce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程. h5 b$ G; G; u
    MAX_COMING_TIME = (*storage).p[j].comeingTime;
    & X" h, F! o3 M% ^: F}/ u2 P- q8 ^+ l% u4 }# A9 \; {( n
    else
    3 f8 I, v0 P1 e/ |* I{
    & F7 n3 N4 i( L: o5 P8 eprintf("A process ask for a memory overed the system capacity\n ");
    1 I9 ~+ b8 }3 qexit(1);1 |5 m8 A  Y" A7 h7 t
    }
    ' W7 j/ h" F; areturn 0;. c4 F7 E4 l( _; g
    }0 A5 X- J( B, T9 W
    int ShortJobFirst(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)
    : O0 B: @! X, B" J- e{
    # D- L3 _* H; B  S/ m/ g$ a) Tstatic int compute=0,waitio=0,change=0;( h+ ~" o2 _. X
    static int computeLast=0,waitioLast=0,changeLast=0;6 E0 w' ^( j$ y4 b; @
    int i=0;
    2 C( ^9 I# U  ?3 {/ T: R' Q0 V5 X/ uif(draw==1)6 ?+ y* X+ L5 t% c% F; e) s
    {: l6 {! v# u4 y% E+ `
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);3 D; m( i$ p' E6 ^  G; _3 d
    drawPerformance_SJF(0,325,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);
    8 {8 ~+ l' t) v5 J( e+ G* U
    ; C& {6 F- Q# o, [  K7 G5 Y& f0 Z6 }) w4 r. [+ e
    computeLast=compute;
    % a1 i) _+ O$ l) owaitioLast=waitio;& V$ N; C. b: f$ [& z
    changeLast=change;
    / C# b  @7 x$ U: M}! M, D/ p8 P9 O6 P4 Q4 k) B' @+ m
    if((* memory).p[0].flag==ready)
    # |1 V9 z  p9 d+ c(* memory).p[0].flag=computing;
    , [" {, _7 {# o& l# j3 Y2 u" Q( @& w* f9 Iif((* memory).p[0].computeNum>0&&(* memory).p[0].flag==computing)
    - B9 j7 m0 U. z# t5 A{
    - I! R% c/ j2 @# _1 l9 ji=(*memory).p[0].computeNum;  C, y; S* k6 S4 B+ u/ @" N  ?
    if(--((*memory).p[0].computeClock[i-1])<=0)// one compute tase is completed8 T5 w9 c# f$ c& C1 w/ _
    {! i* N  J" n/ q  H6 V7 R
    (*memory).p[0].flag=IO_waiting;4 C% G/ G1 q6 W) e* R
    (*memory).p[0].computeNum--;2 R# x$ f- a$ Y7 [* f% s
    change += exchange_IO_Compute;# C) o* ?3 [: w- W3 i" n& N6 Q
    compute++;7 v% A7 r' O& D$ {
    }5 m5 |5 Y$ R' C7 x. N
    else
    " n' F0 D0 m$ p3 h" w, N/ p{2 n+ p6 o# J" y
    compute++;5 ^4 m1 D% c* c2 m
    }
    : h. d; F$ r- u; n( X}
    ) o2 @) w8 @6 B1 celse if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==IO_waiting)2 V& k9 c& I1 O/ g& ]* ]
    {
    1 R' P& T$ P5 O+ @# e) c( f
    - M2 u) e8 m+ C9 G0 ti=(*memory).p[0].ioNum;1 Y. A5 w& t- A: `3 [
    if(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed
    . _) l; T! U, l6 v& ?{
    ) p" O* _# e% P8 i5 g# J% F(*memory).p[0].flag=computing;
    / f5 o5 F& ?7 S(*memory).p[0].ioNum--;
    3 \3 d4 g' _6 M' O% Nchange += exchange_IO_Compute;
    , S2 c$ ]$ e! C  ]% {7 L% Uwaitio++;
    ' Q4 t( y8 A9 z, Q9 U$ ^" M& B5 }}
    , l% v% b$ H& w3 eelse
    , T' U9 V; g$ z9 |: A# a{
    / g% G2 X. z( t- x( W3 qwaitio++;6 A0 x/ A+ N7 J- w1 y/ y& t
    }
    9 o: B( `: u1 m- B}
    / X! S: t2 u  d. g( C3 Xelse if((* memory).p[0].ioNum>0&&(* memory).p[0].flag==computing)
    ' A* c! ^) b) C1 b- _{
    5 M/ i2 ^7 W  t2 k% q" l0 C(* memory).p[0].flag=IO_waiting;2 V0 Y0 I: F% q9 V
    change += exchange_IO_Compute;
    8 s3 Y, p+ s. Y  r5 }7 E2 y; n4 ]9 T}
    1 ~8 C, o  m8 q. f2 F; [else if((* memory).p[0].computeNum>0&&(* memory).p[0].flag==IO_waiting)
      H# x5 t% A+ C% S8 `{0 `6 _; @: t4 ?) ]* D: V, Q
    (* memory).p[0].flag=computing;
    0 A2 ?7 U' T8 |4 T5 ~/ t. `change += exchange_IO_Compute;( F6 m9 w( B0 u* t) n( s
    }
    : \+ T& J1 }  G! _  }if((* memory).p[0].computeNum<=0&&(* memory).p[0].ioNum<=0)  //一个作业已经完成% y: F" a  r$ g* `
    {. {) J+ W, s; Q2 C# A
    (*save) = (PCI*)malloc(sizeof(PCI));8 ~1 R& C' d/ l( F4 R
    (*save)->next = NULL;
    0 l$ [% r/ z- N! y- B(*save)->processID = (*memory).p[0].processID;  C; ?( i: l, A6 J8 n5 S
    (*save)->comeingTime = (*memory).p[0].produceTime;
    7 {: P4 e. F1 \(*save)->askMemory = (*memory).p[0].askMemory;
    % @" Z* k  V  r5 l3 [(*save)->compute = compute;. w) P- o# w7 ]' `1 v& y; l6 }9 ~
    (*save)->waitio = waitio;1 M; ~+ U2 L( K: D3 `/ R8 ~
    (*save)->exchange = change;
    3 K$ t5 N3 H  f# b0 n(*save)->completedTime = systemClock;" i8 ~/ p7 y3 ]2 S3 f' z- H9 P
    (*save)->runningTime = (*memory).p[0].runningTime;
    8 |6 _: X* L7 o( W7 G*spareMemory = MAX_MEMORY;//*spareMemory + (*memory).p[0].askMemory;
    7 O( M. q9 P+ J% F5 Pcompute=waitio=change=0;0 ^$ Z# p( L+ j  ^# \' T
    computeLast=waitioLast=changeLast=0;
    ; t7 R1 t' x" F+ F6 ^; {: r* HSJF_storage_to_memory(&(*storage),&(* memory),&(*spareMemory));
    : _9 h9 n- `0 y0 |1 schange += exchange_process;
    : m& O. ?$ a1 oreturn task_completed;
    3 `  i! ~. x5 D& A% `$ ^/ L4 i2 r( z}/ h/ ?. Q, `- b7 ]
    else& h+ V1 i0 Z9 S; x8 n
    return task_not_completed;( R  Q6 F- X6 v
    }. }7 D2 _8 q( X. E! Q
    int SJF_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory)3 W% e9 V6 ?, T( q" L' ?5 G" j
    {# A" Q/ D6 O& ]1 k
    int i=0,j=0;7 x3 `/ i3 l1 l
    for(i=1; i<(*storage).proNum; i++)3 J7 n1 ^& l+ E' l% a  s
    {
    3 l- ?( @4 L8 y# Uif(((*storage).p.computeTime+(*storage).p.ioTime)<((*storage).p[j].computeTime+(*storage).p[j].ioTime))3 l! J  O4 q4 V9 u  ^
    j=i;
    " l$ W  z& j( G$ b; q' O3 @}" \: l) v! b8 F& L( y3 `/ b' y0 t- l
    if((*storage).p[j].askMemory > *spareMemory). Z1 O3 K$ b  q6 `- _( n
    {
    ! V& v+ p' r( s) B- M* m3 W0 ~printf("The memory asked is overflowed than the system memory.\n");5 C# _) Y& w( P' W9 U
    exit(0);4 P4 N5 B+ U- I2 I/ R; R/ b( i
    }6 o& j3 D! T: g( g, B3 ^
    else9 E( {# v6 B. P- t8 _- ^/ h# F9 F
    {9 n- ~/ J  S% p' s0 h
    (*memory).p[0].askMemory = (*storage).p[j].askMemory;. r. ^% Y: i. h$ o- T) u0 Y9 S9 f6 g8 q
    (*memory).p[0].comeingTime = (*storage).p[j].comeingTime;
    7 k3 k4 k/ c% B5 K* H% I(*memory).p[0].computeNum = (*storage).p[j].computeNum;
      V- `3 Z3 D, ]3 H2 N6 l6 {(*memory).p[0].ioNum = (*storage).p[j].ioNum;! U  u+ q7 F+ g; P5 R
    (*memory).p[0].processID = (*storage).p[j].processID;
    $ t" a' f0 c/ k) B1 Q, U(*memory).p[0].flag = (*storage).p[j].flag;/ z+ S/ p2 W9 a" u; z# g$ {
    (*memory).p[0].ioTime = (*storage).p[j].ioTime;
    - U2 f) V( ]) j7 `(*memory).p[0].computeTime = (*storage).p[j].computeTime;
    6 p8 S; t2 H/ f7 `(*memory).p[0].runningTime = systemClock;
    4 K0 T2 F' H. K% i# D(*memory).p[0].produceTime = (*storage).p[j].produceTime;
    + ?3 R" j" p( T* i9 Z3 z% Mfor(i=0; i<(*memory).p[0].ioNum; i++)
    * H$ j" j0 V  |(*memory).p[0].ioClock = (*storage).p[j].ioClock;& o6 g" s0 t9 l. C, l% A1 |
    for(i=0; i<(*memory).p[0].computeNum; i++)& T# |; Z- e8 B6 B0 ^& Z
    (*memory).p[0].computeClock = (*storage).p[j].computeClock;% Y1 z3 O  L+ f
    (*memory).proNum=1;8 ?5 p9 _1 X' Y8 L  X1 G/ M- _  X: C
    *spareMemory = *spareMemory - (*memory).p[j].askMemory;. @9 W( O, [: [" l
    produce_one_task(&(*storage),j,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程+ V. L3 Q/ ~& ^! R  B
    MAX_COMING_TIME = (*storage).p[j].comeingTime;
    ) ?3 k) w; c3 S' q}
    6 R! U/ X& D% G2 ?+ W/ dreturn 0;
    & i9 h4 Z5 U  y3 m}( C/ V2 X# @, p2 d1 s& Y7 m, _
    int TimeTurning(processPool *storage,processPool* memory,int *spareMemory,PCI ** save,int draw)
    7 U6 R5 ~( T5 ^* t7 c% [{
    6 |* m8 v- X" _& @4 S" b; Tstatic int compute=0,waitio=0,change=0,clockSegment=100,poi=0;7 h% _7 l$ ^0 V  {/ f! w4 f3 Z
    static int computeLast=0,waitioLast=0,changeLast=0;7 K9 t$ S2 C' b
    int i=0,j=0,k=0;5 m) I; _" ]6 ], ]# i
    if((*memory).proNum<=0), p9 [( U: c" t8 J) ^
    TimeTurining_storage_to_memory(&(*storage),&(*memory),&(*spareMemory),-1);! y) ^6 a: p3 Q0 r* B
    if(draw==1)
    ) m9 `$ U" W" o, n! n, [: ]{) f$ f4 b8 A8 _4 E9 O# E5 E* c( H
    //printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);( z9 U: E9 f* Y  {6 X
    drawPerformance_TT(400,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);9 f0 t" k$ K3 Y
    5 Y2 v$ E0 v1 S4 _* x5 X5 Q

    5 t) P- [0 Q, ?& v$ wcomputeLast=compute;$ p4 L/ j3 T  ]# N& i+ @5 g
    waitioLast=waitio;
    4 f) T6 T. q. m: @/ o4 LchangeLast=change;
    8 J3 Z6 X4 x& U. Y}
    4 S- c- d7 U7 p. E9 T$ V) g4 Hif(poi>=(* memory).proNum)
    ' Z) h$ ]2 R) `4 Q/ Jpoi = 0;
    ( V/ E' Y! c5 z4 H! v9 Sif((* memory).p[poi].flag==ready)* Y: c& B  u4 C- U
    (* memory).p[poi].flag=computing;' z% M6 a' y* h, ]2 P" ]' z4 A
    if((* memory).p[poi].computeNum>0&&(* memory).p[poi].flag==computing)2 R# [: I) o8 U
    {
    , V+ g6 H: k, k, x8 \5 X# hi=(*memory).p[poi].computeNum;
    0 F8 s" Y1 G8 ?) z) x$ v% \if(--((*memory).p[poi].computeClock[i-1])<=0)// one compute tase is completed: X2 ^1 I- o. ^
    {/ Y# Q3 a% u2 c3 l
    (*memory).p[poi].flag=IO_waiting;/ X& }# W( E! Y6 ^9 s  j2 ~
    (*memory).p[poi].computeNum--;6 H9 @( v$ `! B, k/ C+ O# S7 L
    change += exchange_IO_Compute;
    4 V+ m8 S. s5 y& K6 V& G  ^, Ncompute++;% o8 J4 i0 T- d, k6 y  P. B* p$ `
    }7 Q) f" f6 U3 U' u2 t
    else
    * s& w' g: E- n' b  ^& g{
    - U0 y$ C" Z# G( `# a$ g+ Ucompute++;& O- I  A: D1 i! w7 X" r% ^
    }& Y: q# f2 k3 g- U# ?. Q/ R3 _
    }: A+ N) y+ s3 }" N3 Z1 I4 R6 d, M
    else if((* memory).p[poi].ioNum>0&&(* memory).p[poi].flag==IO_waiting)- a1 c9 `& k& u+ _; |- H4 }
    {
    1 h8 L. Q" I2 w0 ~8 S1 f  Q$ y" q4 y$ T
    i=(*memory).p[poi].ioNum;- z- e$ U7 J3 v, G' F4 O
    if(--((*memory).p[poi].ioClock[i-1])<=0)// one io tase is completed
    . |1 |- {% T, b9 a. Q, b{0 q) q: l0 G* Q! r# ]. G, Y
    (*memory).p[poi].flag=computing;
    - f' F4 n7 h7 E5 P. U. c(*memory).p[poi].ioNum--;
    ) K  B; S+ Y/ t/ x, c, ?6 F/ `change += exchange_IO_Compute;
    ' h! ]% ~6 X( r2 |1 X# l$ pwaitio++;
    ) D* E% T3 g; k( l}6 d* s9 I7 q5 y( q( ?/ v, @
    else8 d: Y3 K! g) t- s( j
    {/ q# ?0 S7 Z% v* I7 M
    waitio++;3 u+ P$ T4 _/ s5 `; s
    }4 Z8 M, |8 h. N4 w; e
    }7 J5 @* B+ _! J/ @% [% h
    else if((* memory).p[poi].ioNum>0&&(* memory).p[poi].flag==computing)' h( O; ?3 J* {1 m2 ~- R0 x
    {
    & D6 m; N, r+ F6 @! O  I2 X(* memory).p[poi].flag=IO_waiting;$ e5 |8 Y# L) m% P8 f
    change += exchange_IO_Compute;) E/ R8 ?* S: f, N/ d
    }
    4 K9 t  V+ [  ?, n: ]2 V5 A4 melse if((* memory).p[poi].computeNum>0&&(* memory).p[poi].flag==IO_waiting)
    ( E- e/ Z$ \" h0 F3 H+ u{7 l& H2 W0 D; N0 @6 A# T
    (* memory).p[poi].flag=computing;6 {0 U+ p5 W' W- R+ O4 L
    change += exchange_IO_Compute;2 \4 z) Q+ V4 ^% A$ j" p* r
    }9 s! S  V, _3 _) Q! s0 p
    for(i=0; i<(*memory).proNum; i++)  //其他等待io的进程可以并行推进
    6 V9 H3 K& Q; z! @9 F( x2 J4 L{; f3 }' a: [0 F( t5 O) @/ w& s. ^
    if(i!=poi && (*memory).p.flag==IO_waiting)1 G: ^6 d, p* q! K6 R& a
    {3 t# q) H# ^/ [; v3 f
    j=(*memory).p.ioNum;
    6 P. n, n+ D( j5 u; B6 d& l8 Gif(j>0)2 A7 a& P% W8 G  A5 o) C0 H
    {4 ?- A, u) h3 v6 t. K2 r
    if(--((*memory).p.computeClock[j-1])<=0)// one compute tase is completed1 O, m" U* ?2 d/ U% f- N
    {
    0 _3 {/ g3 w5 {4 W6 C(*memory).p.flag=computing;
    1 b6 S+ A% G0 R  [% ?(*memory).p.ioNum--;* ^( F$ m6 Z- G2 D- E
    change += exchange_IO_Compute;
    & K9 w2 a  O! b, N}* Y2 j8 M" a3 v% Z& Z9 U9 Q
    }
    ! a6 x- o* F4 L# J$ `}+ y) n! @0 [. r% @
    }
    4 E5 s% U( L1 I' _" ffor(i=0; i<(*memory).proNum; i++)  //处理已经运行完毕的进程+ M6 E/ f( Z1 e& Z6 W+ e( F& m2 b
    {
    9 J, l; p" s1 ]if((*memory).p.ioNum <= 0 && (*memory).p.computeNum <= 0) // a task is completed2 `, X* `% |% z' u% d* Y
    {2 i9 n% r! a% N3 h5 |
    (*save) = (PCI*)malloc(sizeof(PCI));3 s* {+ r9 `  T. x- d
    (*save)->next = NULL;. [- I: c, B! [7 A
           (*save)->processID = (*memory).p.processID;
    - [7 ~  G- B. q) S' V& v(*save)->comeingTime = (*memory).p.produceTime;
    8 c1 N  @& U; {8 \1 z3 p3 ^8 N) a(*save)->askMemory = (*memory).p.askMemory;4 a3 O% r$ `; q) |# O/ W5 R
    (*save)->compute = compute;
    ) [2 q/ o* S& C(*save)->waitio = waitio;8 [/ q$ c0 P8 l# C. Z8 V. F
    (*save)->exchange = change;
    * u. N( O5 M4 h! ^; F6 R$ U* Y(*save)->completedTime = systemClock-(*save)->comeingTime;, ~) ^+ O0 ?# A. E
    (*save)->runningTime = (*memory).p.runningTime;! j+ U( `4 S0 D- L& s& P7 {  l
    (*save)->completedTime = systemClock;
    - u% ], X( M4 J# Q*spareMemory = *spareMemory + (*memory).p.askMemory;
    2 E+ p% ^" p# D4 ]: F; M& q$ Bcompute=waitio=change=0;' y% Y' k$ ?& k, \/ U( f5 |3 L( ~6 w
    computeLast=waitioLast=changeLast=0;
    , [) |) X/ B+ j6 M( wif(TimeTurining_storage_to_memory(&(*storage),&(*memory),&(*spareMemory),i)==1) // 调入一个新进程进入+ C6 l4 X  O& b+ D- x5 Q- V" q3 ^
    {) t* O- Q9 \; ]6 @
    if(i==poi) //占用CPU的进程已经运行完,将时间片分给其他进程
    1 w6 N) v- O  H. [{
    & ^( m; T: o8 d! Z$ k  T) p& Lpoi++;
    . k. j; M8 n9 Z/ O+ Q   clockSegment=2000;, Y! s' t' _8 w0 y) |
    }
      @# I6 G4 x7 b. E  Z5 b}
    1 A" e" o6 A6 q0 ]else  //没有足够内存调入新进程7 z! u% [0 p1 o9 w3 l. _
    {
    & X$ c. |( G; t6 i* ]% |: dif(i < (*memory).proNum-1)% u7 a" `! [' c+ M/ h, [
    {6 ?/ J( T4 ~' ?' K
    for(j=i; j+1<(*memory).proNum; j++)) {& d* D3 v/ b( ~9 }# w
    {' v* N. ^; D  }* i- X
    (*memory).p[j].askMemory = (*memory).p[j+1].askMemory;3 F# Y: m  U$ z8 Q
    (*memory).p[j].comeingTime = (*memory).p[j+1].comeingTime;7 k4 U$ t9 O; G2 S1 H1 P3 F7 M; J
    (*memory).p[j].computeNum = (*memory).p[j+1].computeNum;
    7 F7 ^5 D9 `5 X9 C6 _(*memory).p[j].ioNum = (*memory).p[j+1].ioNum;
    5 C0 k! n9 b) B, D" g) R* Y(*memory).p[j].processID = (*memory).p[j+1].processID;
    , t# C4 X. y/ f( o# e6 `(*memory).p[j].flag = (*memory).p[j+1].flag;
    " r/ g$ D: h2 Z. X: O4 U; V1 V(*memory).p[j].ioTime = (*memory).p[j+1].ioTime;
    / t! Z# a, k, S1 N(*memory).p[j].computeTime = (*memory).p[j+1].computeTime;
    & i% U. I8 _  `: B(*memory).p[j].runningTime = (*memory).p[j+1].runningTime;
    6 u6 s- c7 }" `" y# B# b; O(*memory).p[j].produceTime = (*memory).p[j+1].produceTime;% K! r( T* D0 l
    (*memory).p[j].completedTime = (*memory).p[j+1].completedTime;
      U0 R8 ~* [. n5 ~1 q0 Ffor(k=0; k<(*memory).p[j].computeNum; k++)
    / h, {; o3 L! x+ r(*memory).p[j].computeClock[k] = (*memory).p[j+1].computeClock[k];
    : O( ]/ t4 v+ i, n8 B% O7 gfor(k=0; k<(*memory).p[j].ioNum; k++)* @% C& b$ ]& N& c
    (*memory).p[j].ioClock[k] = (*memory).p[j+1].ioClock[k];( u- ?# i, K4 E6 _
    }, E, T, V) y. O  p: K4 @; K
    if(i<poi)
    3 p/ F* k( D1 K: z" _  Q! ypoi--;$ }+ J0 ]+ B- B4 t: B+ ?( j
    else if(i==poi)
    " n  Z& A$ R1 l- R' y1 u9 a( xclockSegment=2000;: Q# @9 n$ e  o7 X1 n/ s- k' K
    }
      N+ ?9 p1 a$ H* v# G$ Mi--;: }1 T& @0 m5 `! V3 O! U$ e
    (*memory).proNum--;" T4 \2 m1 }" V  L. A- A& w  B- ]1 w
    }. N3 o- H+ c8 i4 t# l
    return task_completed;) [5 b. E! h5 e' \0 d( d/ l& V- {
    }
    & J2 H3 r/ E$ ^. N: I}& L! ]7 G% m, \; p& h
    --clockSegment;
    % N- A) W2 b/ o7 B8 L( T9 x: C& xif(clockSegment<=0); `7 {" f! J) |( W! d$ t# {
    {
    " `# |% ?' X1 Lpoi=poi+1;& b+ p' I0 R# H8 r) h
    if(poi>=(*memory).proNum)8 C+ E9 e( O: j% f
    poi=0;7 C  X. B; l0 s$ V
    clockSegment=100;
    1 y6 ^- K- O7 ~1 [. S6 I% i}
      C% t% _0 W0 v1 [* h. C1 S+ jreturn task_not_completed;" W1 b. p9 `* t, z
    }- E4 n" |  j5 |1 R+ s
    int TimeTurining_storage_to_memory(processPool *storage,processPool* memory,int *spareMemory,int pos)
    ( N4 {0 K8 o" g8 R5 u{
    + ]* ?" S( a! T- J% yint i=0,j=0,k=0,flag=0,translation=0;
    ( @! R' g- N, V' G1 rfor(i=0; i<(*storage).proNum; i++)" c# `" s- A/ ^+ i0 b0 f
    {
    9 N$ z2 Y* Q4 ~( Z9 |" yif((*storage).p.comeingTime>MAX_COMING_TIME)
    $ s- B9 {' E# v& ]& @. X+ h* mMAX_COMING_TIME = (*storage).p.comeingTime;6 Z& Y' N, n2 g1 K+ F/ W2 ]
    }
    4 n0 R+ \# s3 ?" m4 q/ Hif(pos>=0)8 `# h6 H' N) l/ n
    {  K$ w2 R9 @9 a1 J! B2 \
    for(i=0; i<(*storage).proNum; i++)
    7 F' I9 I& p3 ~, U/ K& N- }{
    * ?; f6 N0 f0 M* K. R4 pif((*storage).p.askMemory <= *spareMemory)
    9 _7 s4 G! Q# Q- a{& A$ a, H4 V3 H6 V: e; W, J
    j=pos;4 s$ |) \; i! d$ ]
    (*memory).p[j].askMemory = (*storage).p.askMemory;( }3 e1 D' q: X! C$ z/ p6 z
    (*memory).p[j].comeingTime = (*storage).p.comeingTime;
    / ~$ A" X  w- [9 V# U(*memory).p[j].computeNum = (*storage).p.computeNum;, S7 ]4 n  }# S3 }2 u& k
    (*memory).p[j].ioNum = (*storage).p.ioNum;
    % r' }3 B# l: w(*memory).p[j].processID = (*storage).p.processID;6 i. t4 \8 N$ R
    (*memory).p[j].flag = (*storage).p.flag;1 {7 J# O/ m+ Y) C
    (*memory).p[j].ioTime = (*storage).p.ioTime;' s. ]( r% ^% H8 O
    (*memory).p[j].computeTime = (*storage).p.computeTime;. e9 z% N) `: m) G7 u% @( j
    (*memory).p[j].runningTime = systemClock;1 u5 W4 H, q- d% |, M
    (*memory).p[j].produceTime = (*storage).p.produceTime;
    2 n' y$ o. q# v7 q0 ?. J0 bfor(k=0; k<(*memory).p[j].ioNum; k++)
    " {# k; R6 A: I(*memory).p[j].ioClock[k] = (*storage).p.ioClock[k];1 M9 Y4 k/ |, r0 }% d
    for(k=0; k<(*memory).p[j].computeNum; k++)
    8 P: I; G7 L  `+ w. `0 K(*memory).p[j].computeClock[k] = (*storage).p.computeClock[k];
    % l/ G, o0 F$ {4 k+ D) N*spareMemory = *spareMemory - (*memory).p[j].askMemory;
    0 R: {# c, e: o5 zproduce_one_task(storage,i,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程
    / S7 i2 v  f  k3 Z* d/ L; JMAX_COMING_TIME = (*storage).p.comeingTime;4 w7 f5 l2 ?( o+ |
    translation=1;
    * l' K/ V/ c4 t3 [8 U2 `break;
    1 s# o/ G  P: F; W  H0 G2 J# C}7 H( X! o7 T/ x1 H9 Z% u% s
    }; A1 o# ^9 C( |1 P' z
    }: I5 U) U7 O  d; {: \
    else
    " S% R9 C" V2 l7 e0 G. n, G) F{
    & F* D& p1 Q! j" o/ |6 H5 Owhile(1)  c- _! n( H$ Y2 S% j
    {) [% F+ \' q$ P/ I1 l
    flag=0;+ N# ]& V  Y% B3 C2 m# D
    for(i=0; i<(*storage).proNum; i++)
    ) R( g) g% x) v% k+ z- j, E{; m! w: w5 V" }4 }
    if((*storage).p.askMemory <= *spareMemory)( I- H. s: h" ?( ~+ B' t- r
    {  K4 p4 \8 u$ g5 T
    j=(*memory).proNum;
    2 s$ }) R9 _+ S9 H! T2 ~: R, d; ^(*memory).p[j].askMemory = (*storage).p.askMemory;8 x) h1 d3 f0 D* E. Y
    (*memory).p[j].comeingTime = (*storage).p.comeingTime;
    5 O, ?- W& ?0 H8 s(*memory).p[j].computeNum = (*storage).p.computeNum;
      i) d* o2 J/ d* v( l(*memory).p[j].ioNum = (*storage).p.ioNum;
    + [7 e) n/ J& i2 Q8 H# ~' L(*memory).p[j].processID = (*storage).p.processID;/ `0 P3 @/ `: d% q8 q+ b4 c
    (*memory).p[j].flag = (*storage).p.flag;
    7 W2 i2 O( u* J4 w+ u4 p# k' ~(*memory).p[j].ioTime = (*storage).p.ioTime;
    0 o$ A2 J6 j5 T' K" P(*memory).p[j].computeTime = (*storage).p.computeTime;: G0 p' B! D3 X3 m
    (*memory).p[j].runningTime = systemClock;
      o/ m' B4 s+ V(*memory).p[j].produceTime = (*storage).p.produceTime;( a! R; B: C3 U
    for(k=0; k<(*memory).p[j].ioNum; k++)2 `; Z- a# D3 a1 o1 u, n
    (*memory).p[j].ioClock[k] = (*storage).p.ioClock[k];; m$ K' ], A2 {
    for(k=0; k<(*memory).p[j].computeNum; k++)
    9 r8 O/ V4 w! x(*memory).p[j].computeClock[k] = (*storage).p.computeClock[k];) M7 f6 D' {, ?. [  `- y7 B
    (*memory).proNum++;
    1 P& ~" o# h4 c% u* w' L5 A% Z*spareMemory = *spareMemory - (*memory).p[j].askMemory;0 {" a4 N' L; d, f$ [# J
    produce_one_task(&(*storage),i,ID_FIFO++);           //调入一个进程后,再在进程池中新生成一个进程
    8 r) F( j5 ~: g; y5 n& e& KMAX_COMING_TIME = (*storage).p.comeingTime;
    8 r% ~$ h, c0 s9 ~8 f5 Dflag=1;4 @* s5 k4 q4 Z
    translation=1;' n% H) c9 r; N& P1 O% t
    }
    5 e9 i" A  z+ U* s. {9 B1 }3 `& t4 M}
    + W2 d! x7 S1 J' xif(flag == 0)
    " r7 U7 s. M4 s1 i1 ybreak;
    1 C! g4 I) [' B) Q7 C2 n}
    * M  h% h5 m3 g' a}
    . r. Z- [- F! A  k* C  Jreturn translation;9 f* a  O" H" J) {- Q9 n; F
    }* R9 A# U0 G' j( I/ e0 i. D
    int FIFO(processPool *storage,processPool* memory,int * spareMemory,PCI ** save,int draw)
    . C1 b* j! W$ }{0 z( K) Q" w9 A' Z( w3 p
    static int compute=0,waitio=0,change=0,flag=0,flagiocpt=0;% Q0 Z  u" \9 C; y, Y) ~# ^- B0 T
    static int computeLast=0,waitioLast=0,changeLast=0;
    2 J' F4 B3 @- p# X0 t3 j: G$ Aint i=0;
    5 }7 r: Y  I* |* u9 t9 kif(draw==1)' R9 \  A& v2 x/ K1 R
    {
    6 O* ?  o$ q& W$ w' y# q' }* z$ M//printf("%d %d %d\n",compute-computeLast,waitio-waitioLast,change-changeLast);
    9 z" m# m6 t; p5 H* \$ c; O+ rdrawPerformance_FIFO(0,0,MAX_MEMORY-(*spareMemory),compute-computeLast,waitio-waitioLast,change-changeLast);* K# T2 \- B" d2 C9 t9 d
      F8 z" l* ~: F- a- s7 U) ]5 m

    ) c, v& }8 S# n2 C! ScomputeLast=compute;) U) o1 k& r! ~: L  z" y) C2 ~
    waitioLast=waitio;( ]1 ^1 i4 x' |3 e/ ^0 r
    changeLast=change;. F4 q& ?. J  H2 Q
    }$ E* v  D; ]) Q
    if(flag==1)  5 n4 A9 y; j2 w( U' a  e8 g9 O. n3 O
    {
    9 n; I3 \% A* y9 t8 cif((*memory).p[0].ioNum>0||(*memory).p[0].computeNum>0)  //task is not completed
    2 }7 y. l/ J0 \4 w. }* v; _{7 _: H: c. h+ `/ o; r$ d- i6 r
    if(flagiocpt==0)   // implement compute6 {: Q+ c( D* f5 A8 W
    {
    9 o. H' d* D' u4 i3 ci=(*memory).p[0].computeNum;5 z6 K% c9 W/ X! L
    if(i>0 && (*memory).p[0].computeClock[i-1]>0)$ o; H2 M6 U9 J
    {
    ) h5 L" o/ s3 G/ Sif(--((*memory).p[0].computeClock[i-1])<=0)// ome compute tase is completed
    3 ^' U9 j0 c  w8 y, V  v% {* C{
    2 p2 q- {( M: oflagiocpt = 1;$ J) ?+ _1 Z7 s3 Z
    (*memory).p[0].computeNum--;
    1 r4 y& M& k$ {9 x5 t6 N; Tchange += exchange_IO_Compute;
    ' F) t& j; g/ K' ~3 W. c, Jcompute++;- G$ H: r( J3 j1 `2 M1 z
    }5 h6 ~, n# m! T+ L1 z$ x9 y' O
    else; z  F# V4 G- Y, c; S& H
    compute++;0 \3 Q3 Q; _( R' E7 Q( v8 G; b
    * k8 z: Q0 X& E% n
    }
    ( V4 n7 p7 x0 `$ h+ a1 ~else
    9 C+ a  H5 b$ V# Mflagiocpt = 1;; U8 X5 I* p% \$ h
    }
    ; T$ g! y' H$ I& L& T; nelse  //wait io
    + Y3 N7 k# X$ L6 Z{
    / L) M: B$ C7 l( h" d1 ki=(*memory).p[0].ioNum;
    4 p+ Z( w" R8 k9 ?if(i>0 && (*memory).p[0].ioClock[i-1]>0)
    0 v+ ^: y6 ]; @; x: u% G{
      ?6 W! `7 k7 Y6 e$ ^' t- e/ a% o% Vif(--((*memory).p[0].ioClock[i-1])<=0)// one io tase is completed8 |, f2 l, D+ n& c" q: X( B
    {2 X; K7 l* |6 _& J5 j# v
    flagiocpt = 0;; z8 n- D; X7 z. h
    (*memory).p[0].ioNum--;+ a) ?7 {- e$ t$ b) T! O- {: l
    change += exchange_IO_Compute;7 _. |% M# P$ _) S# U
    waitio++;9 t( s5 k& n( t5 A) T' g
    }
    ' B4 f9 p5 _, v+ a+ m/ Helse
    : ^/ J2 ~. q7 ]6 G+ v1 \, l; D7 Vwaitio++;1 j0 ?% u5 ?6 j! T( |

    2 [& v* c! M9 r) T}
    3 [, R. W) O7 a2 X: h! o9 C9 W) helse
    ! i: u! i1 e( Z& M$ V$ Vflagiocpt = 0;) C) I2 w! Y, y0 k& [
    }4 H+ A' f1 a0 W$ [2 H
    }& L; l9 |* `/ w
    else  //task is completed' M/ ^( L3 f3 w) M/ y5 C
    {
    # T& h* v$ {) M* |2 e# T1 e(*save) = (PCI*)malloc(sizeof(PCI));
    & w& F- u& m$ a6 i! X( I3 D. X' A- e(*save)->next = NULL;, A' X1 d+ R* `' Z, v
           (*save)->processID = (*memory).p[0].processID;
    ) ?4 N3 F( l- _  |/ M) J(*save)->comeingTime = (*memory).p[0].produceTime;
    * \# e3 q7 O1 M) h7 S  _9 `(*save)->askMemory = (*memory).p[0].askMemory;* `0 {7 D5 X' l3 F3 C" A5 X
    (*save)->compute = compute;4 N$ a% U: Y( l% e6 g7 t" y' I6 B
    (*save)->waitio = waitio;8 t. o" S; f: ~+ T& e( Z
    (*save)->exchange = change;; S  a3 T) H" S0 R. E
    (*save)->completedTime = systemClock-(*save)->comeingTime;' o1 P! _" O/ i
    (*save)->runningTime = (*memory).p[0].runningTime;
    9 n' B! |0 D4 m8 y3 U7 y$ p(*save)->completedTime = systemClock;
    3 o$ M8 C" J6 q0 m2 L+ I1 t//*spareMemory = MAX_MEMORY;
    ! W: T. s4 m8 e2 h0 W& Gfree((*memory).p[0].ioClock);2 H' J% J; k4 X2 d
    free((*memory).p[0].computeClock);
    : p4 [" J. ?! s  o) A  Z+ }free((*memory).p);
    + n3 R8 ]4 ^! F) I8 ^flag=0;# z& |% [" e, B; X; m9 y/ Z
    compute=waitio=change=0;
    , ~5 M& j; z. J5 L$ _- U5 FcomputeLast=waitioLast=changeLast=0;
      Q' ?9 P8 ~- b6 z' e! ]return task_completed;
    " }  M2 b7 j3 U1 D# y: Q- r}% l  K  x* V4 o7 o! K+ q; Z
    }7 |. z% P' V: ~& J+ g6 u6 ^
    else         ( @& U. o! R* X1 }$ n
    {
    4 P5 D9 `* h( ?7 w; xFIFO_storage_to_memory(&(*storage),&(*memory),&(*spareMemory));
    5 q5 p1 [% m8 ~$ r, E# _) cchange += exchange_process;1 t( x7 c  H" c+ J
    //*spareMemory -= (*memory).p[0].askMemory;
    4 L: `( l: s; Kflag=1;: \  `% \) w& C8 g
    //showProcessInf(*memory);
    + H3 |, r, A( D( J# ?. \* Zreturn task_not_completed;3 x+ {/ G5 V. Y
    }
    # L& K- m5 I/ [" z3 yreturn task_not_completed;, a" {* Z8 w  ^7 n) M  ?/ m
    }( x# @9 g$ h3 D4 s5 m) m6 I1 V
    int FIFO_storage_to_memory(processPool *storage,processPool* memory,int * spareMemory)
    3 q- O2 J2 _6 V0 o; }! b( |{
    + f: B/ q5 B! p3 ?( m9 B, Jint i=0,j=0,k=0;
    , A" }& ?/ `1 Q5 MMAX_COMING_TIME = (*storage).p[initProcessNum-1].comeingTime;- A5 D. W  `5 t9 r* `5 P7 y6 L$ r
    (*memory).p = (process*)malloc(initProcessNum*sizeof(process));
    * T) R( d0 m+ L' imemory->proNum = 1;0 ?7 u& o9 A+ C$ J% T4 @5 H
    for(i=0; i<initProcessNum; i++)2 E: j  s8 `* `
    {8 n. }4 B" M8 `: ~/ `
    if((*storage).p.askMemory <= *spareMemory)4 {4 N3 x- D, C  J
    {7 w; T+ U; W7 [- T
    (*memory).p[0].askMemory = (*storage).p.askMemory;# ~! ]8 {# B! x4 y& F, o' n% s
    (*memory).p[0].comeingTime = (*storage).p.comeingTime;
    4 ~2 L; m( B6 R7 K6 v(*memory).p[0].computeNum = (*storage).p.computeNum;/ E1 A2 N. l2 B& Y3 v. \1 X
    (*memory).p[0].ioNum = (*storage).p.ioNum;( I6 Q; c7 ]! M( o7 n" t8 V
    (*memory).p[0].processID = (*storage).p.processID;8 G$ K& H  v3 \
    (*memory).p[0].flag = (*storage).p.flag;
    2 ]: P& o: S* K0 r. Y! l& R) t  d6 [(*memory).p[0].ioTime = (*storage).p.ioTime;
    % i; R/ t+ m8 o7 G7 H$ I+ h( v' s$ ~(*memory).p[0].computeTime = (*storage).p.computeTime;
      O& g, _& O) [  [7 G(*memory).p[0].produceTime = (*storage).p.produceTime;& g/ M; _3 a0 I
    (*memory).p[0].runningTime = systemClock;3 J7 O; p% A- [) \1 ]2 P- ~  B
    (*memory).p[0].computeClock = (int*)malloc((*memory).p[0].computeNum*sizeof(int));" Y' q/ q/ C' I1 F
    (*memory).p[0].ioClock = (int*)malloc((*memory).p[0].ioNum*sizeof(int));" h' H" P9 `3 n
    for(k=0; k<(*memory).p[0].ioNum; k++)
    5 e; x' v6 ~. D3 [$ f. B(*memory).p[0].ioClock[k] = (*storage).p.ioClock[k];$ Q8 q* L' n* P& z# D2 R" y; R. W5 k
    for(k=0; k<(*memory).p[0].computeNum; k++)
    ; Q2 `+ B# P0 i: f* }(*memory).p[0].computeClock[k] = (*storage).p.computeClock[k];
    * N. n9 m" V4 Y0 n) lbreak;5 B7 H3 t6 U0 ^& @6 U2 F- ?
    }' I* e5 I& O9 _/ b: n* e4 p
    }
    - e& H" v; `; Z5 N/ jif(i<initProcessNum)  //调用一个作业进入内存后,并再生成一个作业等待调入
    - R3 m: x& i" ^. w1 q% `; ]& n+ [{
    4 b3 |7 s+ W4 s$ ^$ vproduce_one_task(storage,i,ID_FIFO++);) F+ e0 E, ?# Q2 F) P
    MAX_COMING_TIME = (*storage).p.comeingTime;- u* E# ^, `6 D( g. f4 z1 o' [* V
    sort_by_comingtime(storage,i);3 P9 N0 ?8 J* I
    }
    5 \) F* p( Z1 w9 B4 b  ?return 0;3 f+ w; c* a( a) b; |  f. H6 m+ b
    }, {2 {, j/ G; m9 j" U8 [3 j
    int sort_by_comingtime(processPool * p,int pos)3 ?# H8 U9 |1 `% D; z1 @
    {
    6 C5 A# e. v8 k5 L- v; ]int i=0,j=0;2 ]: C- N8 V2 s/ k$ ^( K9 r
    process temp;
    % @, x5 \9 d, I: F( p; Wif(pos<0)9 M" m; w' B# C) k2 b! s
    {- x* ^& I0 J$ v" V: a
    for(i=0; i<initProcessNum; i++)+ d7 R' L1 @7 v7 ?- D0 H
    for(j=0; j+1<initProcessNum-i; j++)
      C2 B# e8 h: w0 v) g. D/ k! j6 K{5 o' X7 {, d6 J
    if((*p).p[j].comeingTime>(*p).p[j+1].comeingTime)/ f7 f* R0 q* }2 C6 J# L4 K' K
    {1 l( e7 X5 [9 |1 a
    temp = (*p).p[j];- B% A( j: F7 X- X
    (*p).p[j] = (*p).p[j+1];
    3 V( Q! l( i& d' M7 [9 M( D9 t2 X(*p).p[j+1] = temp;& E8 p7 [$ c( r$ D
    }$ C; b# o- T8 r: C
    }
    5 x* K* z1 u3 B5 B" W, N}2 U1 o" b- W+ R, |% L  }
    else if(pos<initProcessNum)
    9 r1 w0 K. x" C3 Y+ P  q8 B{
    , p0 H( I. Y7 S9 ]2 n- }5 Sfor(i=pos-1; i>=0 && (*p).p.comeingTime > (*p).p[i+1].comeingTime; i--)
    4 i, p$ i6 }+ P: n% q( p( ^5 }. V7 G{
    % e; s" B) Q" p0 s- `temp = (*p).p;
    / u5 d( P5 S3 @/ [(*p).p = (*p).p[i+1];
    0 l( Z$ m  P/ U9 |  F(*p).p[i+1] = temp;5 I. z% a  L1 i. m2 G# i9 \8 P
    }. i- `+ k3 [0 @, {; t3 |
    for(i=pos+1; i<initProcessNum && (*p).p[i-1].comeingTime > (*p).p.comeingTime; i++)
    " f! n/ Z: |( q3 G9 g1 O% S{
    & p0 }6 j5 @. P8 Q9 O/ x$ I: {temp = (*p).p[i-1];
    - a. ]* k2 \0 F(*p).p[i-1] = (*p).p;
    7 b2 s* J5 ]) L! o(*p).p = temp;% w' e/ C6 J+ C4 b; s) |
    }5 ]# z4 G/ s- _
    }7 h7 Z- d9 B1 O8 m  ~, ?* b
    else5 J$ V% E1 b5 S
    printf("position eror\n");+ ]; L) k8 Q8 W2 m! d& R. A
    return 0;
    ' l8 }9 q1 M' F}) a# D; U( {% l# D* c( }$ t
    int InitPool(processPool * p)! @2 s# I* z+ @: d/ [. l
    {
      R% I9 t+ B7 x( t7 C1 Sint i=0;
    / L6 K; X( Y6 h) }7 m(*p).proNum = initProcessNum;
    1 t2 r' V5 ^7 V1 R+ [(*p).p = (process*)malloc(initProcessNum*sizeof(process));# }4 P) F" {( U8 v8 c1 h
    for(i=0; i<initProcessNum; i++)                                        //init process information4 \6 \6 E9 ~8 j( }
    {
    & {* |* v0 x5 e5 k( u& j(*p).p.computeClock = (int*)malloc(initclocknum*sizeof(int));
    2 @+ v3 @# q4 `(*p).p.ioClock = (int*)malloc(initclocknum*sizeof(int));0 @! i7 j; h8 e* p/ S+ w
    produce_one_task(&(*p),i,ID_FIFO++);
    ' q3 H) x  B% y+ B: U1 A7 k! u}
    , h+ p' ~8 h" f0 x8 H2 F! {return 0;
    & g8 p- _7 `2 m: f* A1 e}! v& m; q; Y& u* p4 V
    int produce_one_task(processPool * p,int i,int id)
    ' T. p% a$ v1 q: y{. M' A, b) n: v) T
    int time=MAX_COMING_TIME,j=0,totallTime=0;9 ]9 X  T" s* P' V$ m. P
    (*p).p.processID = initProcessID+id;           
    5 P: ]# x: l4 T. b- z# j(*p).p.comeingTime = time+rand()%(MAXProcessRunTime/5);
    0 x$ u  B8 ~* v7 X* O: e(*p).p.produceTime = systemClock;
      z, I, g5 H5 c# Q( D6 i(*p).p.ioNum = rand()%4+20;                                        //IO number setting to 2--5;; H3 R% A/ R" {1 u
    (*p).p.computeNum = rand()%4+30;                                   //computNum setting to 3--6;
    8 X8 F  Q! f( Q; FtotallTime = (*p).p.computeNum  + (*p).p.ioNum;% X9 \; G5 U0 g! o, z- J
    (*p).p.computeTime=0;( z2 h" L& |7 Y7 B2 `1 M
    for(j=0; j<(*p).p.computeNum; j++)
    / }, i/ F1 @6 ^{
    3 c* m. D9 P8 q(*p).p.computeClock[j]=rand()%(MAXProcessRunTime/totallTime)+1;( {* x" Z7 i" p/ e% ?
    (*p).p.computeTime += (*p).p.computeClock[j];0 S0 V, S. p* ~2 v6 o" G
    }$ S9 A* I  Q" N4 l2 U; r  z( Q
    (*p).p.ioTime=0;
    , _3 w5 J1 T; l3 R6 L8 nfor(j=0; j<(*p).p.ioNum; j++)2 @$ I6 s* X# l, ~% w- v# r
    {, r3 M& k7 p% t  t
    (*p).p.ioClock[j]=rand()%(MAXProcessRunTime/totallTime)+1;1 M3 ?) s8 |4 d% f0 ^( B; ]4 `" C
    (*p).p.ioTime += (*p).p.ioClock[j];1 t; @% v0 L6 }7 `+ I5 d
    }
    ! c# i0 s! B' z; C1 W' ^$ [(*p).p.askMemory = rand()%(MAX_MEMORY/4);
    + J6 ?6 p; o- `5 ~5 ?  i3 B3 B. O: N(*p).p.flag = ready;
    9 [3 p9 m/ W$ h, E& vreturn 0;$ v; I- i: U6 U4 C
    }! D. _" D# V; R7 H3 f
    int showProcessInf(processPool p)
    8 |/ g/ C4 U  ?3 T4 }{
    2 h; o& ^4 w' W5 D  [, k0 y8 Yint i=0,j=0;5 |$ d* D- Z" l, s. O  N
    for(i=0;i<p.proNum;i++)8 d" M" M6 F4 `4 @6 e; R
    {* A. N' Y. y2 }3 P' M
    printf("ID:%d,%d,%d,%d,%d,%d,%d\n",p.p.processID,p.p.comeingTime,p.p.ioNum,p.p.computeNum,p.p.ioTime,p.p.computeTime
    ; ?! B9 L/ E! B7 T) b" K7 t% m,p.p.askMemory);& B- c  t7 l+ m: b& |" i
    for(j=0;j<p.p.ioNum;j++)+ H4 y' D& W7 Q4 e7 L
    {+ s& Z' D7 E( j- R8 k2 R( a
    printf("%d ",p.p.ioClock[j]);
    ' B* ]: y: U& J& i+ }2 W}
    ; O0 N6 D7 u9 M+ `4 x) H% {  R, oprintf("\n");
    - d9 p" i( x1 w# Qfor( j=0;j<p.p.computeNum;j++)  B9 A) Z! n7 |. J# ?0 F( j5 Z4 k4 E
    {( ], Z7 E2 U; B  q* r1 c" Z
    printf("%d ",p.p.computeClock[j]);
      c2 k7 }7 _4 @1 {- M  t, l3 m}, e2 ^! _+ `8 t  Y3 ~7 j# J
    printf("\n");' `( h7 G" Y2 O, `$ R
    }
    1 h$ E1 j9 _9 s& g( H. G2 b' Treturn 0;
    . S. y: ]4 ~3 y" }5 N}/ j8 z+ `7 F$ D/ }( p
    ————————————————
    0 o/ _2 {, B! Y版权声明:本文为CSDN博主「wang_dong001」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。; }% i/ \( J: m% U. N/ J; T8 J* ]
    原文链接:https://blog.csdn.net/wang_dong001/article/details/47843519
    , l" L/ R1 w5 v" C9 H6 b# X9 h4 c$ i2 v% h/ c8 y5 H6 Y

    & B, k; S. r( e3 i  L5 S
    zan
    转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
    您需要登录后才可以回帖 登录 | 注册地址

    fastpost qq
    收缩
    • 电话咨询

    • 04714969085

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

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

    蒙公网安备 15010502000194号

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

    GMT+8, 2026-11-1 04:12 , Processed in 0.375737 second(s), 51 queries .

    回顶部