printf("CHOOSE THE ALGORITHM:\n");
printf("1 PRIORITY\n");
printf("2 ROUNDROBIN\n");
printf("3 EXIT\n");
}
pcb* get_process(){
pcb *q;
pcb *p; //头指针
pcb *t; //尾指针
int i = 0;
printf("input name and time\n");
while (i < P_NUM){
q=(pcb *)malloc(sizeof(pcb));
scanf("%s",q->name);
scanf("%d",&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++;
}
return p;
}
void free_process(pcb *p){
pcb *q;
while(p!= NULL){
q = p;
p = p->next;
free(q);
}
}
void display(pcb *p){
printf("name cputime needtime priority state\n");
while(p){
printf("%s",p->name);
printf(" ");
printf("%d",p->cputime);