最高优先数优先”调度算法7页

上传人:文库****9 文档编号:180325664 上传时间:2021-04-19 格式:DOCX 页数:7 大小:10.19KB
返回 下载 相关 举报
最高优先数优先”调度算法7页_第1页
第1页 / 共7页
最高优先数优先”调度算法7页_第2页
第2页 / 共7页
最高优先数优先”调度算法7页_第3页
第3页 / 共7页
最高优先数优先”调度算法7页_第4页
第4页 / 共7页
最高优先数优先”调度算法7页_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《最高优先数优先”调度算法7页》由会员分享,可在线阅读,更多相关《最高优先数优先”调度算法7页(7页珍藏版)》请在金锄头文库上搜索。

1、实验要求:编写并调试一个模拟的进程调度程序,采用“最高优先数优先”调度算法对五个进程进行调度设计思想:“最高优先数优先”调度算法的基本思想是把cpu分配给就绪队列中优先数最高的进程。采用动态优先数,即优先数在创建进程时给定一个初始值,当进程获得一次cpu后其优先数就减少1。源程序如下:#include stdio.h#define getpcb(type)(type*)malloc(sizeof(type)#define NULL 0struct pcbchar name10;char state;int super;int ntime;int rtime;struct pcb*link; *

2、ready=NULL,*p;typedef struct pcb PCB;main()int len,h=0;char c;input();len=space();while( (len!=0)&(ready!=NULL) )c=getchar();h+;printf(nthe execute number:%dn,h);p=ready;ready=p-link;p-link=NULL;p-state=R;check();running();printf(npress any key to continue.);c=getchar();printf(nn the process has bee

3、n finished.n);c=getchar();input ()int i,num;char k;clrscr();printf(ninput process number?);scanf(%d,&num);for(i=0;iname);printf(nthe super of Process:);scanf(%d,&p-super);printf(nthe time need:);scanf(%d,&p-ntime);printf(n);p-rtime=0;p-state=W;p-link=NULL;sort();int space()int l=0;PCB *pr=ready;whil

4、e(pr!=NULL)l+;pr=pr-link;return(l);check()PCB *pr;printf(n*Now the process running is:%s,p-name);disp(p);pr=ready;printf(n*Now the ready quenue is:n);while(pr!=NULL)disp(pr);pr=pr-link;disp(pr)PCB *pr;printf(nqnametstatetsupertdtimetruntimen);printf(%st,pr-name);printf(%ct,pr-state);printf(%dt,pr-super);printf(%dt,pr-ntime);printf(%dt,pr-rtime);printf(n);destory()printf(nprocess%s has finished:n,p-name);free(p);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号