if(name==blockedQueue[i].name){blockedQueueHead--;
readyQueue[readyQueueHead]=blockedQueue[i];
readyQueueHead++;
15 / 26word.
blockedQueue[i]=blockedQueue[blockedQueueHead];
blockedQueue[blockedQueueHead]=null;
Order(readyQueue,readyQueueHead);
printf(\"The process %c is ready!\\n\
return 0;
}
}
if(i==blockedQueueHead){
printf(\"error:This process has not been blocked!\\n\");
}
return 0;
}
int Show(){
16 / 26word.
printf(\"\\nCPU time:%d\\n\
printf(\" name needtime priority\\n\");
printf(\"Ready Queue: \");
int i;
if(readyQueue[0].name!=NULL)
for(i=readyQueueHead;i>0;i--)
printf(\"%c %d %d\\n
\
else printf(\"null\");
printf(\"\\nRunning Process: \");
if(run.name==NULL) printf(\"null\");
else printf(\"%c %d %d\\n
\
printf(\"\\nBlock Queue: \");
17 / 26word.
if(blockedQueue[0].name==NULL) printf(\"null\");
else for(i=blockedQueueHead;i>0;i--)
printf(\"%c %d %d\\n
\y);
}
int main(){
SELECT:
printf(\"\\n\\n1:input
process\\n2:Dispath\\n3:Timeout\\n4:EventWait\\n5:EventOccurs\\n0:exit\\n\");
new
int select=getchar();getchar();
switch(select)
{
case '1':Creat();Show();break;
case '2':Dispath();Show();break;
18 / 26word.
case '3':Timeout();Show();break;
case '4':EventWait();Show();break;
case '5':EventOccur();Show();break;
case '0':exit(0);
default:printf(\"Please select from 0 to 5\\n\");
}
goto SELECT;
return 0;
6.运行结果及其说明
(1)创建进程:按‘1’创建进程,进程被放入就绪队列,并按优先级从高到低 排列。就绪队列最多容纳5个进程,当创建第6个进程时,程序会提示。
19 / 26word.
20 / 26word.
(2)Dispath:按‘2’将就绪队列中的进程转移到运行队列中,如果运行队列中已有进程 则该进程先执行一个时间片,然后回到就绪队列中,最后将新就绪队列中优先级最
21 / 26word.
大的进程放到运行队列中
(3)Timeout:消耗一个时间片,若之前运行队列中有进程,则该进程所需执行时间减一并回到
就绪队列,否则什么也不发生
22 / 26word.
(4)EventWait:当运行队列中有程序时,使用EventWait将该程序转移到阻塞队列
23 / 26word.
(5)EventOccurs:在阻塞队列中选择一个事件发生的进程,将其放入就绪队列中。
24 / 26word.
7.程序使用说明
(1)输入‘1’创建进程
(2)输入‘2’将就绪队列中优先级最大的进程放入运行队列
(3)输入‘3’消耗一个时间片
(4)输入‘4’将正在运行状态的进程放入阻塞队列中
(5)输入‘5’将阻塞的进程放入就绪队列中
最新文件---------------- 仅供参考--------------------已改成word文本
25 / 26word.
--------------------- 方便更改
26 / 26word.