}
}
bt = bt-Next;
}
if (i0)
{
while (pcb != NULL)/*更新进程优先权(动态优先权)*/
{
if (pcb-Sts == RUNpcb-PID=0)/*运行的进程优先权降低*/
{
pcb-Prior -= i;
if (pcb-Prior0)
pcb-Prior = 0;
}
else if (pcb-Sts == SUSPENDpcb-PID=0)/*挂起的进程优先权升高*/
pcb-Prior += i;
pcb = pcb-Next;
}
}
if (i0)
SortProcQueue();/*如果优先级有变动则重新排序*/
if (ProcEnd || i0)
{
UpdateBatchs();/*更新多道进程*/
}
return TRUE;
}
/****************************************************************/
/*图形界面相关函数*/
/****************************************************************/
/*表格的单位宽度和高度*/
#define WIDTH 64
#define HEIGHT 12
void *black=NULL;/*背景色方格,使用它擦出表格中的图形*/
int InitGraph()/*初始化图形界面*/
{
intGraphDriver;/* The Graphics device driver*/
intGraphMode;/* The Graphics mode value*/
int ErrorCode;
GraphDriver = DETECT;/* Request auto-detection */
initgraph( GraphDriver, GraphMode, "" );
ErrorCode = graphresult();/* Read result of initialization*/
if( ErrorCode != grOk )
{/* Error occured during init */
printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
getch();
return FALSE;
}
cleardevice();
black = (void*)malloc(imagesize(1,1,WIDTH-1,HEIGHT-1));
getimage(1,1,WIDTH-1,HEIGHT-1,black);
DrawFrame();
DrawData();
return TRUE;
}
int DrawFrame()/*画边框和表头*/
{
settextjustify(CENTER_TEXT, CENTER_TEXT);
gprintf(320, HEIGHT/2-1, "Multi-Batch System Emulation");
settextjustify(LEFT_TEXT, TOP_TEXT);
moveto(0,HEIGHT);
lineto(0,479);
lineto(639,479);
lineto(639,HEIGHT);
lineto(0,HEIGHT);
line(WIDTH*4,HEIGHT,WIDTH*4,479);
line(WIDTH*7,HEIGHT,WIDTH*7,479);
line(0,HEIGHT*2,639,HEIGHT*2);
line(0,HEIGHT*3,639,HEIGHT*3);
gprintf(HEIGHT*0+2,HEIGHT*1+2,"System Batchs");/*系统多道列表头*/
gprintf(HEIGHT*0+2,HEIGHT*2+2,"Batch");
gprintf(WIDTH*1+2,HEIGHT*2+2,"ProcID");
gprintf(WIDTH*2+2,HEIGHT*2+2,"Time");
gprintf(WIDTH*3+2,HEIGHT*2+2,"Prior");
gprintf(WIDTH*4+2,HEIGHT*1+2,"Suspended Processes");/*挂起队列列表头*/
gprintf(WIDTH*4+2,HEIGHT*2+2,"ProcID");
gprintf(WIDTH*5+2,HEIGHT*2+2,"Time");
gprintf(WIDTH*6+2,HEIGHT*2+2,"Prior");
gprintf(WIDTH*7+2,HEIGHT*1+2,"Ready Processes");/*就绪队列列表头*/
gprintf(WIDTH*7+2,HEIGHT*2+2,"ProcID");
gprintf(WIDTH*8+2,HEIGHT*2+2,"Time");
gprintf(WIDTH*9+2,HEIGHT*2+2,"Prior");
}
int DrawData()/*绘制系统数据*/
{
int numRun=0, numSus=0, numRed=0;/*运行挂起和就绪的进程各有多少*/
PCB* now = ProcQueue;
int x=0, y=0;
while (now != NULL)
{
switch(now-Sts)
{
case RUN:
x = WIDTH*1;
y = HEIGHT*(3+(numRun++));
break;
case SUSPEND:
x = WIDTH*4;
y = HEIGHT*(3+(numSus++));
break;
case READY:
x = WIDTH*7;
y = HEIGHT*(3+(numRed++));
break;
}
if (now-Sts==RUN)/*该进程为正在运行的进程*/
{
putimage(x-WIDTH+1,y+1,black,COPY_PUT);
gprintf(x-WIDTH+2,y+2,"%d",numRun);
}
if (now-PID=0)/*该进程不是后备进程*/
{
putimage(x+1,y+1,black,COPY_PUT);
gprintf(x+2,y+2,"%d",now-PID);
putimage(x+1+WIDTH,y+1,black,COPY_PUT);
gprintf(x+WIDTH+2,y+2,"%d",now-Time);
putimage(x+1+WIDTH*2,y+1,black,COPY_PUT);
gprintf(x+WIDTH*2+2,y+2,"%d",now-Prior);
}
else
{
putimage(x+1,y+1,black,COPY_PUT);
推荐阅读
- 角色扮演类小游戏益智,角色扮演类小游戏排行
- oracle表空间与实例,表空间是属于数据库还是实例
- chatgpt头像配色,chare头像
- 包含postgresql地理索引的词条
- vb.net多级菜单 vb添加多个菜单
- 系统为什么装不进u盘系统,系统装不了
- 冒险给宝宝断粮的游戏,冒险给宝宝断粮的游戏怎么玩
- python画函数曲线图 如何用python画函数图
- win732下载,win732下载 迅雷下载