p = p->next; } } void display_round(pcb *p){ printf(\count state\\n\ while(p){ printf(\ printf(\ \ printf(\ printf(\ \ printf(\ printf(\ \ printf(\ printf(\ \ switch(p->process){ case ready:printf(\ case execute:printf(\ case block:printf(\ case finish:printf(\ } p = p->next; } } void round_cal(){ pcb *p; pcb *r; p = get_process_round(); int cpu = 0; r=p; while(!process_finish(p)){ //就绪队列中还有进程 if(r->needtime==1) cpu+=1; else cpu+=2; //时间片长度是2 cpu_round(r); r = get_next(r,p); //获得下一个需要执行的进程 printf(\ display_round(p); //每调度一次就显示次 set_state(p); sleep(2); } free_process(p); //释放所有进程 } main(){ display_menu(); int k; scanf(\ switch(k){ case 1:priority_cal();break; case 2:round_cal();break; case 3: break; default:printf(\ } } 优先级调度: 时间片轮转调度: 先来先服务调度算法及结果: #include
教师签名: 年 月 日