欢迎来到天天文库
浏览记录
ID:58647710
大小:16.00 KB
页数:6页
时间:2020-10-16
《进程调度算法--最高响应比调度算法.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include"stdio.h"structzgxyb{charname[10];floatarrivetime;floatservicetime;floatstarttime;floatfinishtime;floatzztime;floatdqzztime;};zgxyba[100];voidinput(zgxyb*p,intN){inti;printf("intputtheprocess'sname&arrivetime&servicetime:forexmple:a0100");for(i=0;i<=N-1;i++){printf("inpu
2、tthe%dthprocess'sinformation:",i+1);scanf("%s%f%f",&p[i].name,&p[i].arrivetime,&p[i].servicetime);}}voidPrint(zgxyb*p,floatarrivetime,floatservicetime,floatstarttime,floatfinishtime,floatzztime,floatdqzztime,intN){intk; printf("runorder:"); printf("%s",p[0].name);for(k=1;k3、;k++){printf("-->%s",p[k].name);} printf("theprocess'sinformation:"); printf("nametarrivetservicetstarttfinishtzztdqzz"); for(k=0;k<=N-1;k++) {printf("%st%-.2ft%-.2ft%-.2ft%-.2ft%-.2ft%-.2ft",p[k].name,p[k].arrivetime,p[k].servicetime,p[k].starttime,p4、[k].finishtime,p[k].zztime,p[k].dqzztime);} }//按到达时间排序voidsort(zgxyb*p,intN){ for(inti=0;i<=N-1;i++) for(intj=0;j<=i;j++) if(p[i].arrivetime5、 p[j]=temp; }}//yunxingjieduanvoiddeal(zgxyb*p,floatarrivetime,floatservicetime,floatstarttime,floatfinishtime,float&zztime,float&dqzztime,intN){intk; for(k=0;k<=N-1;k++) { if(k==0) { p[k].starttime=p[k].arrivetime; p[k].finishtime=p[k].arri6、vetime+p[k].servicetime;} else { p[k].starttime=p[k-1].finishtime; p[k].finishtime=p[k-1].finishtime+p[k].servicetime;} } for(k=0;k<=N-1;k++) { p[k].zztime=p[k].finishtime-p[k].arrivetime; p[k].dqzztime=p[k].zztime/p[k].servicetime; 7、 }} voidZGXYB(zgxyb*p,intN){ floatarrivetime=0,servicetime=0,starttime=0,finishtime=0,zztime=0,dqzztime=0; sort(p,N); for(intm=0;m8、e=p[m-1].finishtime
3、;k++){printf("-->%s",p[k].name);} printf("theprocess'sinformation:"); printf("nametarrivetservicetstarttfinishtzztdqzz"); for(k=0;k<=N-1;k++) {printf("%st%-.2ft%-.2ft%-.2ft%-.2ft%-.2ft%-.2ft",p[k].name,p[k].arrivetime,p[k].servicetime,p[k].starttime,p
4、[k].finishtime,p[k].zztime,p[k].dqzztime);} }//按到达时间排序voidsort(zgxyb*p,intN){ for(inti=0;i<=N-1;i++) for(intj=0;j<=i;j++) if(p[i].arrivetime
5、 p[j]=temp; }}//yunxingjieduanvoiddeal(zgxyb*p,floatarrivetime,floatservicetime,floatstarttime,floatfinishtime,float&zztime,float&dqzztime,intN){intk; for(k=0;k<=N-1;k++) { if(k==0) { p[k].starttime=p[k].arrivetime; p[k].finishtime=p[k].arri
6、vetime+p[k].servicetime;} else { p[k].starttime=p[k-1].finishtime; p[k].finishtime=p[k-1].finishtime+p[k].servicetime;} } for(k=0;k<=N-1;k++) { p[k].zztime=p[k].finishtime-p[k].arrivetime; p[k].dqzztime=p[k].zztime/p[k].servicetime;
7、 }} voidZGXYB(zgxyb*p,intN){ floatarrivetime=0,servicetime=0,starttime=0,finishtime=0,zztime=0,dqzztime=0; sort(p,N); for(intm=0;m8、e=p[m-1].finishtime
8、e=p[m-1].finishtime
此文档下载收益归作者所有