编写并调试一个多道程序系统的作业调度模拟 下载本文

for(i=0;i<n;i++)

printf("资源[%d]\\t",i);

printf("\\n%6s\\t%6.2f\\t\\t%6.2f\\t",pr->name,pr->needtime,pr->arrivetime); for(i=0;i<n;i++)

printf("\\t%6.2f",pr->storage[i]); printf("\\n"); }

void destroy() /*建立作业撤消函数(作业运行结束,撤消作业)*/ { free(p); }

void check() {

JCB *first,*fir,*p; int flag=0,i,test=0; first=pb;

while(first&&(T>=first->arrivetime)&&(flag==0))

{

for(i=0;i<n;i++) {

if(source[i]>=first->storage[i]) source[i]=source[i]-first->storage[i]; else test=1; } if(test==0) { p=first;

first=first->link; p->link=NULL; if(ready==NULL) ready=p; else { fir=ready;

while(fir->link!=NULL) {

fir=fir->link; }

fir->link=p; } } else flag=1; } pb=first; } void fcfs() {

JCB *first,*second; int ins=0;

if((pb==NULL)||(p->arrivetime<pb->arrivetime

)) {

p->link=pb; pb=p;

} else { first=pb;

second=first->link; while(second!=NULL) {

if(p->arrivetime<second->arrivetime) {

p->link=second; second=NULL; first->link=p; ins=1; } else {

first=first->link; second=second->link; } } if(ins==0) first->link=p;