文档库

最新最全的文档下载
当前位置:文档库 > 操作系统进程管理程序

操作系统进程管理程序

#include

#include

#include

#include

#include

#define P_NUM 5

#define P_TIME 50

enum state{

ready,

execute,

block,

finish

};

struct pcb{

char name[4];

int priority;

int cputime;

int needtime;

int count;

int round;

state process;

pcb * next;

};

pcb * get_process();

pcb * get_process(){

pcb *q;

pcb *t;

pcb *p;

int i=0;

cout<<"input name and time"<

while (i

q=(struct pcb *)malloc(sizeof(pcb));

cin>>q->name;

cin>>q->needtime;

q->cputime=0;

q->priority=P_TIME-q->needtime;

q->process=ready;

q->next=NULL;

if (i==0){

p=q;

t=q;

}

else{

t->next=q;

t=q;

}

i++;

} //while

return p;

}

void display(pcb *p){