进程调度算法实验报告文档格式.docx
《进程调度算法实验报告文档格式.docx》由会员分享,可在线阅读,更多相关《进程调度算法实验报告文档格式.docx(13页珍藏版)》请在冰豆网上搜索。
![进程调度算法实验报告文档格式.docx](https://file1.bdocx.com/fileroot1/2022-10/12/b5774d0c-1372-4b18-bc02-16a97450a96b/b5774d0c-1372-4b18-bc02-16a97450a96b1.gif)
00这种形式的数据的加减乘除运算和比较运算,
五、数据结构设计
1.时间类
classtime{
public:
time(intx=0,inty=0){
time:
:
hour=x;
minute=y;
}
time&
operator=(consttime&
t1)
{
this->
hour=t1.hour;
minute=t1.minute;
return*this;
timeoperator+(timet2)
intminutes,hours;
minutes=(minute+t2.minute)%60;
hours=hour+t2.hour+(minute+t2.minute)/60;
returntime(hours,minutes);
timeoperator-(timet2)
intminutes,hours;
minutes=minute-t2.minute;
if(minute<
0){
minutes+=60;
hour--;
}
hours=hour-t2.hour;
friendbooloperator<
(timet1,timet2)
if(t1.hour<
t2.hour){
returntrue;
elseif(t1.hour==t2.hour){
if(t1.minute<
=t2.minute){
returntrue;
}
returnfalse;
friendostream&
operator<
<
(ostream&
out,consttime&
t1){
returnout<
t1.hour<
"
"
<
t1.minute*1.00;
friendistream&
operator>
>
(istream&
in,time&
inth,m;
scanf("
%d:
%d"
&
h,&
m);
t1.hour=h;
t1.minute=m;
returnin;
inthour;
intminute;
};
2.作业内容
typedefstructJOB{
charname[20];
//Jobname
timein_time;
intrun_time;
timest_time;
timeend_time;
intround_time;
//周转时间
intwait_time;
doublerounds_time;
//带权周转
doublereson_radio;
//响应比
}job;
六、流程图
七、源代码
#include<
stdio.h>
stdlib.h>
string.h>
iostream>
usingnamespacestd;
doublesum_time;
//全部作业周转时间和
doublesums_time;
//全部作业带权周转时间和
intn;
//jobcounts
//重载max
timemaxn(timet1,timet2){
if(t1.hour>
t2.hour){
returnt1;
elseif(t1.hour==t2.hour){
if(t1.minute>
returnt1;
returnt2;
}
//eg:
120转化成2:
timem_exchange_h(intrun_time){
timerun;
run.hour=run_time/60;
run.minute=run_time%60;
returnrun;
//eg:
2:
0转化成120
inth_exchange_m(timet1){
returnt1.hour*60+t1.minute;
//先来先服务;
voidjob_input(job*x){
cout<
作业\t进入时间\t估计运行时间(分钟)\t开始时间\t结束时间\t周转时间(分钟)\t带权周转时间"
endl;
for(inti=0;
i<
n;
i++){
cout<
x[i].name<
\t"
x[i].in_time<
\t\t"
x[i].run_time<
\t\t\t"
x[i].st_time<
x[i].end_time<
x[i].round_time<
x[i].rounds_time<
作业平均周转时间T="
sum_time/n<
作业平均带权周转时间T="
sums_time/n<
voidFCFS(job*x){
sum_time=0;
sums_time=0;
timerun=m_exchange_h(x[0].run_time);
x[0].st_time=x[0].in_time;
x[0].end_time=x[0].st_time+run;
x[0].round_time=h_exchange_m(x[0].end_time-x[0].in_time);
sum_time+=x[0].round_time;
x[0].rounds_time=x[0].round_time*1.0/x[0].run_time;
sums_time+=x[0].rounds_time;
for(inti=1;
x[i].st_time=maxn(x[i].in_time,x[i-1].end_time);
x[i].end_time=x[i].st_time+m_exchange_h(x[i].run_time);
x[i].round_time=h_exchange_m(x[i].end_time-x[i].in_time);
x[i].rounds_time=x[i].round_time*1.0/x[i].run_time;
sum_time+=x[i].round_time;
sums_time+=x[i].rounds_time;
\n【先来先服务作业调度算法计算结果】\n"
job_input(x);
//短作业优先;
voidSJF(job*x){
intflag[100000];
memset(flag,0,sizeof(flag));
timerun=