实验五 进程调度模拟实验//进程调度算法 proc.c#include #include#include typedef struct pcb//定义 PCB 结构{char name[20]; /*进程标识符*/int cputime; /*进程占用 CPU 时间*/int prio; /*进程优先数*/int needtime; /*进程到完成还需要的 CPU 时间*/struct pcb *next;/*链指针*/}PCB;PCB *RUN,*READY,*RTAIL,*FINSH,*FTAIL;void PRINTLINK(int t)/*输出 3 个队列*/{PCB *p;printf("CPU 运行次数:___%d___\n",t);printf("______________________\n");printf("进程名\t 运行状态\t 运行次数\t 还需要运行次数\n");if(RUN!=NULL){ printf("%s\t 运行\t%d\t%d\n",RUN->name,RUN->cputime,RUN->needtime); }else printf("*运行状态为空\n");p=READY;if(p!=NULL){ while(p!=NULL) {printf("%s\t 就绪\t%d\t%d\n",p->name,p->cputime,p->needtime); p=p->next; } }else printf("*就绪队列为空\n");p=FINSH;if (p!=NULL){ while(p!=NULL){//printf(" 进程名字为:%s\n",p->name);printf("%s\t 完成\t%d\t%d\n",p->name,p->cputime,p->needtime);p=p->next;}}elseprintf("*完成队列为空\n");getchar();}PCB *CPCBLINK()/*建立就绪队列*/{ printf("建立就绪队列\n\n");int i,n,nt,pr;PCB *p,*q,*head;n=0;while(1){ printf("请输入进程的个数(有效范围 1-100):"); scanf("%d",&n); printf("\n"); if (n>=1&&n<=100) break; else printf("输入有误。请重新输入!\n"); getchar(); } head=(struct pcb* )malloc(sizeof(struct pcb));printf("输入第 1 个进程的名称:");scanf("%s",head->name);while(1){ printf("需要的运行时间:"); scanf("%d",&nt); if(nt>0) break; else { printf("输入无效,重新输入!\n"); getchar(); }}head->needtime=nt;printf("优先数:");scanf("%d",&pr);head->prio=pr; head->cputime=0;/*进程已获得的运行时间*/head->next=NULL;q=head; for(i=1;iname); printf("需要的运行时间:"); scanf("%d",&nt); p->needtime=nt; printf("优先数:"); scanf("%d",&pr); p->prio=pr;p->cputime=0;/*进程已获得的运行时间*/ p->next=NULL;q->next=p;q=p;} RTAIL=q;return head;}void...