#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
#define getpch(type)(type*)malloc(sizeof(type))
#define NULL 0
struct pcb
{
char name[20];
char state;
int super;
int ntime;
int rtime;
struct pcb *link;
}*ready=NULL,*p;
typedef struct pcb PCB;
void 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
{
first=first->link;
second=second->link;
}
}
if (insert==0)
{
first->link=p;
}
}
}
void input() /* 建立进程控制块函数 */
{
int i,num;
printf("\n请输入进程个数");
scanf("%d",&num);
for ( i=0;i<num;i++)
{
printf("\n进程号NO. %d:\n ",i);
p=getpch(PCB);