printf(\在等待队列的进程是:\while(q != NULL) {
printf(\进程%s \q = q -> next; }
/* 显示相应的PCB块 */
printf(\进程详细PCB------------------------------------\printf(\进程名/t/t|进程ID/t/t|进程状态/t|进程所需时间/t|进程运行时间/n\printSort();
/* 进行一次时间片轮换调度算法, 将队首的进程放到队尾,之前第二位进程获得cpu时间片 */ q = first_pcb;
while(q -> next != NULL) { q = q -> next; }
first_pcb -> state = 'w'; q -> next = first_pcb;
first_pcb = first_pcb -> next; q -> next -> next = NULL; printf(\
printf(\运行调度\system(\}
/* 将新的PCB块放到链表末尾 */ void pushPCB(int i) {
q -> next = p; q = p;
if(i == process_num - 1) q -> next = NULL; }
/* 建立PCB块并将他们组成一个队列 */ void newPCB() { int i;
printf(\请输入进程数:\scanf(\q = (PCB*)malloc(sizeof(PCB));
first_pcb = (PCB*)malloc(sizeof(PCB)); for(i = 0; i < process_num; i++) {
system(\
p = (PCB*)malloc(sizeof(PCB));
printf(\请输入第%d个进程名:\scanf(\
printf(\请输入进程需要的运行时间:\scanf(\p -> id = id++; p -> run_time = 0; p -> state = 'w'; if(i == 0) {
first_pcb = q = p; p -> next = NULL; }
else pushPCB(i); } }
void main() {
newPCB();
current_process = process_num;
printf(\按任意键开始进程调度/n\system(\
while(current_process) { showPCB(); } }
五.调试
1.先进先出算法调试
(1).输入进程组一的进程数
(2).依次输入进程的名称,到达时间及服务时间
(3).输入完成后按回车键调用算法得到算法执行的各类信息
2.时间片轮转算法调试
(1)输入进程组一的进程数:
(2)依次输入进程名及所需的服务时间:
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库进程调度算法模拟-(3)在线全文阅读。
相关推荐: