90104971117897110 实 验 一 处 理 机 调 度 一 、实 验 内容 选择一 个调 度 算法,实 现处 理 机 调 度 。 二、实 验 目的 多道系统中,当就绪进程数大于处 理 机 数时,须按照某种策略决定哪些进程优先占用处 理 机 。本实 验 模拟实 现处 理 机 调 度 ,以加深了解处 理 机 调 度 的工作。 三、实 验 题目 1、设计一 个按优先权调 度 算法实 现处 理 机 调 度 的程序; 2、设计按时间片轮转实 现处 理 机 调 度 的程序。 PCB 内容要求 : 进程名/PID; 要求运行时间(单位时间); 优先权; 状态: PCB 指针; 1、可随机输入若干进程,并按优先权排序; 2、从就绪队首选进程运行:优先权-1 要求运行时间-1 要求运行时间=0 时,撤销该进程 3、重新排序,进行下轮调度; 源代码: #inclu de #inclu de #inclu de 90104971117897110 #include typedef struct pcb { char PID[50]; int needTime;//需要运行时间 int priority;//优先权 char state[20];//进程状态 struct pcb *next; } PCB; typedef struct { PCB* front; PCB* rear; } ProcessQueue; void SelectAlgorithm(); void CreateQProcess(ProcessQueue &Q,char*,int time,int pri,char*); void ProcessSchedule(); void InitQueue(ProcessQueue &Q); void visitQueue(ProcessQueue &Q); bool RunProcess(PCB* rp,ProcessQueue &Q); bool NonPreemptivePriority(ProcessQueue &Q);//非抢占式优先权调度 void delProcess(PCB* delp); bool RunProcessPreem(PCB* rp,ProcessQueue &Q);//抢占式优先执行进程 bool PreemptivePriority(ProcessQueue &Q); void RR(ProcessQueue &Q); int main() { int iSel; int i = 0; SelectAlgorithm(); ProcessQueue readyQ;//就绪进程队列 PCB newpcb; InitQueue(readyQ); printf("请选择调度算法:"); do { scanf("%d",&iSel); } while (!(iSel == 1 || iSel == 2 || iSel == 3)); while(i < 3) { printf("请输入要创建的进程:\n"); 90104971117897110 fflush(stdin); gets(newpcb.PID);fflush(stdin); scanf("%d",&newpcb.needTime);fflush(stdin); scanf("%d",&newpcb.priority);fflush(stdin);...