#include <STDIO.H>
#include <STDLIB.H>
#include <STRING.H>
#include<CONIO.H>
typedef struct node /**/
{
char name[10]; /*进程标识符*/
int prio; /*进程优先数*/
int round; /*进程时间轮转时间片*/
int cputime; /*进程占用CPU时间*/
int needtime; /*进程到完成还需要的时间*/
int count; /*计数器*/
char state; /*进程的状态*/
struct node *next; /*链指针*/
}PCB;
PCB *finish,*ready,*tail,*run; /*队列指针*/
int N; /*进程数*/
/*将就绪队列中的第一个进程投入运行*/
firstin()
{
run=ready; /*就绪队列头指针赋值给运行头指针*/
run->state='R'; /*进程状态变为运行态*/
ready=ready->next; /*就绪队列头指针后移到下一进程*/
}
/*标题输出函数*/
void prt1( )
{
/*输出标题*/
printf("name cputime needtime count round state\n");
}
/*进程PCB的输出*/
void prt2(PCB *q)
{
/*轮转法的输出*/
printf("%-8s%-8d%-8d%-6d%-5d %-c\n",q->name,
q->cputime,q->needtime,q->count,q->round,q->state);
}
/*输出函数*/
void prt()
{
PCB *p;
if(run!=NULL) /*如果运行指针不空*/
prt2(run); /*输出当前正在运行的PCB*/
p=ready; /*输出就绪队列的PCB*/
while(p!=NULL)
{
prt2(p);
p=p->next;
}
p=finish; /*输出就完成队列的PCB*/
while(p!=NULL)
{
prt2(p);
p=p->next;
}
printf("Press any key to continue...\n");