多道作业调度(基于优先级)文档格式.docx

上传人:聆听****声音 文档编号:947382 上传时间:2023-04-29 格式:DOCX 页数:10 大小:14.95KB
下载 相关 举报
多道作业调度(基于优先级)文档格式.docx_第1页
第1页 / 共10页
多道作业调度(基于优先级)文档格式.docx_第2页
第2页 / 共10页
多道作业调度(基于优先级)文档格式.docx_第3页
第3页 / 共10页
多道作业调度(基于优先级)文档格式.docx_第4页
第4页 / 共10页
多道作业调度(基于优先级)文档格式.docx_第5页
第5页 / 共10页
多道作业调度(基于优先级)文档格式.docx_第6页
第6页 / 共10页
多道作业调度(基于优先级)文档格式.docx_第7页
第7页 / 共10页
多道作业调度(基于优先级)文档格式.docx_第8页
第8页 / 共10页
多道作业调度(基于优先级)文档格式.docx_第9页
第9页 / 共10页
多道作业调度(基于优先级)文档格式.docx_第10页
第10页 / 共10页
亲,该文档总共10页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

多道作业调度(基于优先级)文档格式.docx

《多道作业调度(基于优先级)文档格式.docx》由会员分享,可在线阅读,更多相关《多道作业调度(基于优先级)文档格式.docx(10页珍藏版)》请在冰点文库上搜索。

多道作业调度(基于优先级)文档格式.docx

//作业控制块

{int 

priority;

//

super;

char 

name[10];

//作业名

reachtime;

//作业到达时间

starttime;

// 

已经运行了的时间

runtime;

作业需要运行的时间

needtime;

作业要占用的内存

frees;

作业所需磁带

disks;

//作业所需磁带

finishtime;

作业完成时间

cycletime;

作业周转时间

cltime;

作业带权周转时间

state;

作业状态

*next;

结构体指针

}*ready=NULL,*start=NULL,*p,*q,*r,*s,*t;

typedef 

JCB;

sort()

{

JCB 

*first, 

*second;

insert=0;

if((ready==NULL)||((p->

priority)>

(ready->

priority)))

p->

next=ready;

ready=p;

}

else

first=ready;

second=first->

next;

while(second!

=NULL)

if((p->

(second->

priority))

next=second;

first->

next=p;

second=NULL;

insert=1;

first=first->

second=second->

if(insert==0) 

void 

inital()

i;

printf("

\n输入作业数:

);

scanf("

%d"

&

n);

for(i=0;

i<

n;

i++)<

/n;

p=getpch(JCB);

输入作业名:

%s"

p->

name);

reachtime=i;

作业默认到达时间:

i);

\n输入作业要运行的时间:

needtime);

输入作业运行要占用的内存:

frees);

输入作业运行所需磁带:

disks);

输入优先数:

priority);

\n"

runtime=0;

state='

W'

;

next=NULL;

/*if(ready==NULL) 

ready=q=p;

else{

q->

q=p;

}*/

sort();

space() 

//计算内存中作业的个数

l=0;

JCB* 

pr=start;

while(pr!

l++;

pr=pr->

return(l);

apply() 

//把符合条件的作业调用内存并给他们分配资源

len;

p=ready;

while(p!

if(p->

frees<

=freesa&

&

disks<

=disksa)

freesa-=p->

disksa-=p->

r=p;

p=p->

if(r==ready) 

//先将符合条件的作业从队列中分离出来

ready=r->

r->

q=ready;

while(q->

next!

=r) 

q=q->

next=r->

if(start==NULL) 

start=s=r;

//将其查到Start队列

s->

next=r;

s=r;

len=space();

\n\t此时有%d道作业在内存\n\n"

len);

disp(JCB 

pr,int 

m) 

//建立作业显示函数

作业名:

pr->

状态:

%c"

state);

到达时间:

reachtime);

需要时间:

if(m==0){

\t开始时间:

starttime);

结束时间%d"

finishtime);

周转时间:

%f"

cycletime);

带权周转时间:

cltime);

需要内存:

需要磁道数:

check() 

//显示作业状况

\n作业%s于完成%d个作业后运行完毕,其完成后的情况:

q->

name,j);

j++;

disp(q,0);

s=start;

\n\t\t*********当前进入内存的作业状态*********\n"

while(s!

disp(s,1);

s=s->

r=ready;

\n\n\t\t*********当前后备作业表中作业的状态**********\n"

while(r!

disp(r,1);

r=r->

running() 

//运行作业

for(t=start;

t!

=NULL;

start=t->

q=t;

t=start;

starttime=times;

R'

finishtime=q->

starttime+q->

cycletime=(float)(q->

finishtime-q->

cltime=(float)(q->

cycletime/q->

T1+=q->

T2+=q->

times+=q->

F'

freesa+=q->

disksa+=q->

check();

//调用check显示正在运行的就需的以及后备的作业

free(q);

//释放作业

apply();

//分配作业

getch();

super()

*padv;

padv=ready;

do{

if(padv->

state=='

padv->

reachtime<

=times)

super=(float)(times-padv->

reachtime+padv->

needtime)/padv->

padv=padv->

}while(padv!

=NULL);

final()

s,t;

t=T1/n;

s=T2/n;

\n\n作业已经全部完成!

\n%d个作业的平均周转时间是%f"

n,t);

\n%d个作业的平均带权周转时间是%f\n\n\n"

n,s);

main() 

//初始化界面

m;

\n\n\t\t*********************************************\t\t\n"

\t\t\t多道作业调度(基于优先级)\n"

\t\t*********************************************\t\t\n"

inital();

running();

final() 

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2