操作系统进程调度C语言代码Word文档格式.docx

上传人:b****1 文档编号:1057872 上传时间:2023-04-30 格式:DOCX 页数:25 大小:16.07KB
下载 相关 举报
操作系统进程调度C语言代码Word文档格式.docx_第1页
第1页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第2页
第2页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第3页
第3页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第4页
第4页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第5页
第5页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第6页
第6页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第7页
第7页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第8页
第8页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第9页
第9页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第10页
第10页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第11页
第11页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第12页
第12页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第13页
第13页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第14页
第14页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第15页
第15页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第16页
第16页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第17页
第17页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第18页
第18页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第19页
第19页 / 共25页
操作系统进程调度C语言代码Word文档格式.docx_第20页
第20页 / 共25页
亲,该文档总共25页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

操作系统进程调度C语言代码Word文档格式.docx

《操作系统进程调度C语言代码Word文档格式.docx》由会员分享,可在线阅读,更多相关《操作系统进程调度C语言代码Word文档格式.docx(25页珍藏版)》请在冰点文库上搜索。

操作系统进程调度C语言代码Word文档格式.docx

\n\t\t/*4、优先级优先调度

\n\t\t/*0、退出*/\n"

\n\n\t请选择菜单项:

\t"

scanf("

%d"

&

a);

\n"

switch(a)

case1:

fcfs();

break;

case2:

sjf();

case3:

sjp();

case4:

yxj();

default:

break;

}

if(a<

0&

&

a>

4)break;

voidsjp()

inti,j,n,min,px,sjp,time;

floatsum1,sum2;

boolflag=true;

\t请输入有n个进程(0<

n<

=50):

n);

while(n>

50||n<

=0)

n\t请重新输入:

"

*/"

\t请输入时间片大小(0<

sjp):

sjp);

while(sjp<

structGzuo{

intid;

//进程名字

intdt;

//到达时刻

intst;

//服务时间

intwct;

//完成时刻

intst2;

//标志是否完成

floatzt;

//周转时间

floatdczt;

//带权周转时间

};

Gzuoa[N];

for(i=0;

i<

n;

i++)

a[i].id=i+1;

\t到达时间:

a[i].dt);

\t服务时间:

a[i].st);

a[i].st2=a[i].st;

for(j=n-1;

j>

=0;

j--)

j;

if(a[i].dt>

a[i+1].dt)

min=a[i].dt;

a[i].dt=a[i+1].dt;

a[i+1].dt=min;

min=a[i].st;

a[i].st=a[i+1].st;

a[i+1].st=min;

min=a[i].st2;

a[i].st2=a[i+1].st2;

a[i+1].st2=min;

min=a[i].id;

a[i].id=a[i+1].id;

a[i+1].id=min;

time=a[0].dt;

//printf("

赋值后TIME值为:

%d\n"

time);

min=0;

while(min<

n)

flag=true;

for(i=0;

if(a[i].st2>

a[i].dt<

=time)

flag=false;

if(a[i].st2>

0)

if(a[i].dt<

当前a[%d].st2值为:

i,a[i].st2);

a[i].st2=a[i].st2-sjp;

运算后当前a[%d].st2值为:

当前TIME值为:

time=time+sjp;

增加之后TIME值为:

if(a[i].st2<

a[i].wct=time+a[i].st2;

a[i].zt=(float)(a[i].wct-a[i].dt);

a[i].dczt=a[i].zt/a[i].st;

min++;

}elseif(flag)

a[i].dt>

time)

time=a[i].dt;

}}

\t1、按id号依次输出\n"

\t2、按完成顺序依次输出\n"

\n\t请选择输出顺序:

px);

\nid:

到达时间\t服务时间\t完成时间\t周转时间\t带权周转时间\n"

sum1=0;

sum2=0;

switch(px)

%d:

%d\t\t%d\t\t%d\t\t%.0f\t\t%.2f\n"

a[i].id,a[i].dt,a[i].st,a[i].wct,a[i].zt,a[i].dczt);

sum1+=a[i].zt;

sum2+=a[i].dczt;

\n平均周转时间:

%.2f\n"

sum1/n);

\n平均带权周转时间:

%.2f\n\n"

sum2/n);

for(j=0;

j<

j++)

if(a[i].id==j+1)

voidfcfs()

inti,j,n,min,px;

a[0].wct=a[0].st+a[0].dt;

a[0].zt=(float)a[0].st;

a[0].dczt=a[0].zt/a[0].st;

for(i=1;

a[i-1].wct)

a[i].wct=a[i].dt+a[i].st;

a[i].zt=(float)a[i].st;

else

a[i].wct=a[i-1].wct+a[i].st;

voidsjf()

intb=0,z;

\n\t\t请输入有n个进程(0<

%d/n"

min=a[0].dt;

if(a[i].dt==a[i+1].dt&

a[i].st>

a[i+1].st)

a[0].wct);

elseb=b+1;

for(j=b-1;

=1;

if(a[i].st>

for(j=i+1,b=j;

if(a[j].dt>

a[i].wct);

=i;

for(z=i;

z<

z++)

if(a[z].st>

a[z+1].st)

min=a[z].dt;

a[z].dt=a[z+1].dt;

a[z+1].dt=min;

min=a[z].st;

a[z].st=a[z+1].st;

a[z+1].st=min;

\n\t请选择输出顺序\n"

{for(i=0;

voidyxj()

intyxj;

//优先级

\t优先级:

a[i].yxj);

min=a[i].yxj;

a[i].yxj=a[i+1].yxj;

a[i+1].yxj=min;

a[i].yxj<

a[i+1].yxj)

elseb++;

if(a[i].yxj<

if(a[z].yxj<

a[z+1].yxj)

到达时间\t服务时间\t优先级\t完成时间\t周转时间\t带权周转时间\n"

%d\t\t%d\t\t%d\t\t%d\t\t%.0f\t\t%.2f\n"

a[i].id,a[i].dt,a[i].yxj,a[i].st,a[i].wct,a[i].zt,a[i].dczt);

a[i].id,a[i].dt,a[i].yx

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

当前位置:首页 > 工程科技 > 能源化工

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

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