資源描述:
《進(jìn)程調(diào)度算法--最高響應(yīng)比調(diào)度算法.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
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,p
4、[k].finishtime,p[k].zztime,p[k].dqzztime);}??}//按到達(dá)時(shí)間排序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