1) 实验中使用的数据结构
(1) PCB进程控制块
内容包括参数①进程名name;②要求运行时间 runtime;③优先数 prior;④状态 state;⑤已运行时间runedtime。
(2) 为简单起见,只设运行队列,就绪链表两种数据结构,进程的调度在这两个队列中切换,如图3.1所示
图3.1PCB链表
2) 每个进程运行时间随机产生,为1~20之间的整数。
3) 时间片的大小由实验者自己定义,可为3或5
4) 可参考的程序流程图如图3.2
图3.2模拟进程调度的流程图
5) 参考程序
#include "stdio.h"
#include "stdlib.h"
typedef struct PCB
{
int name;
int runtime;
int runedtime;
int state;
int killtime;
struct PCB *next;
}PCB;
#