#include
"stdio.h"
#include
#include
#define getpch(type) (type*)
malloc
(
sizeof
(type))
#define NULL 0
struct
pcb {
/* 定义进程控制块PCB */
char
name[10];
char
state;
int
super;
int
ntime;
int
rtime;
struct
pcb* link;
}*ready=NULL,*p;
typedef
struct
pcb PCB;
sort()
/* 建立对进程进行优先级排列函数*/
{
PCB *first, *second;
int
insert=0;
if
((ready==NULL)||((p->super)>(ready->super)))
/*优先级最大者,插入队首*/
{
p->link=ready;
ready=p;
}
else
/* 进程比较优先级,插入适当的位置中*/
{
first=ready;
second=first->link;
while
(second!=NULL)
{
if
((p->super)>(second->super))
/*若插入进程比当前进程优先数大,*/
{
/*插入到当前进程前面*/
p->link=second;
first->link=p;
second=NULL;
insert=1;
}
else
/* 插入进程优先数最低,则插入到队尾*/