#include #include #include typedef struct node { int id; /*进程标识数*/ int priority; /*进程优先数 越大越高*/ int cputime; /*进程已占用CPU时间 最初为0*/ int alltime; /*进程还需占用的时间*/ int startblock; /*阻塞时间,再运行startblock时间片,进入阻塞。*/ int blocktime; /*被阻塞时间,再等待blocktime时间片,进入就绪。*/ char state; /*进程的状态*/ struct node *next; /*链指针*/ }PCB; PCB *ready,*block,*run; /*队列指针*/ int N=5; /*将就绪队列中的第一个进程投入运行*/ void firstin() { run=ready; /*就绪队列头指针赋值给运行头指针*/ run->state='r'; /*进程状态变为运行态*/ ready=ready->next; /*就绪对列头指针后移到下一进程*/ } /*输出函数*/ void prt( ) { PCB *p; p=run; printf("RUNING:\n"); printf("id cputime alltime priority startblock \n"); if(run!=NULL) /*如果运行指针不空*/ printf(" id %-2d\t%-10d\t%-10d\t%-10d\t%-10d\n",p->id, p->cputime,p->alltime,p->priority,p->startblock); /*输出当前正在运行的PCB*/ ...... |
查看评论
已有0位网友发表了看法