实验要求:编写并调试一个模拟的进程调度程序,采用“最高优先数优先”调度算法对五个进程进行调度设计思想:“最高优先数优先”调度算法的基本思想是把cpu分配给就绪队列中优先数最高的进程。采用动态优先数,即优先数在创建进程时给定一个初始值,当进程获得一次cpu后其优先数就减少1。源程序如下:#includestdio.h#definegetpcb(type)(type*)malloc(sizeof(type))#defineNULL0structpcb{charname[10];charstate;intsuper;intntime;intrtime;structpcb*link;}*ready=NULL,*p;typedefstructpcbPCB;main(){intlen,h=0;charc;input();len=space();while((len!=0)&&(ready!=NULL)){c=getchar();h++;printf(\ntheexecutenumber:%d\n,h);p=ready;ready=p-link;p-link=NULL;p-state='R';check();running();printf(\npressanykeytocontinue...);c=getchar();}printf(\n\ntheprocesshasbeenfinished.\n);c=getchar();}input(){inti,num;chark;clrscr();printf(\ninputprocessnumber?);scanf(%d,&num);for(i=0;inum;i++){printf(\ninputtheprocessNo.%d:\n,i);p=getpcb(PCB);printf(\nthenameofProcess:);scanf(%s,p-name);printf(\nthesuperofProcess:);scanf(%d,&p-super);printf(\nthetimeneed:);scanf(%d,&p-ntime);printf(\n);p-rtime=0;p-state='W';p-link=NULL;sort();}}intspace(){intl=0;PCB*pr=ready;while(pr!=NULL){l++;pr=pr-link;}return(l);}check(){PCB*pr;printf(\n***Nowtheprocessrunningis:%s,p-name);disp(p);pr=ready;printf(\n***Nowthereadyquenueis:\n);while(pr!=NULL){disp(pr);pr=pr-link;}}disp(pr)PCB*pr;{printf(\nqname\tstate\tsuper\tdtime\truntime\n);printf(%s\t,pr-name);printf(%c\t,pr-state);printf(%d\t,pr-super);printf(%d\t,pr-ntime);printf(%d\t,pr-rtime);printf(\n);}destory(){printf(\nprocess[%s]hasfinished:\n,p-name);free(p);}