欢迎来到天天文库
浏览记录
ID:58657004
大小:474.54 KB
页数:16页
时间:2020-10-16
《操作系统实验-处理机管理.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、学号专业姓名实验日期10.26教师签字成绩实验报告【实验名称】处理机管理【实验目的】在多道程序或多任务系统中,系统同时处于就绪态的进程有若干个。也就是说能运行的进程数远大于处理机个数。为了使系统中的个进程能有条不紊的运行,必须选择某种调度策略,以选择一进程占用处理机。要求学生设计一个模拟单处理机调度的算法,以巩固和加深处理机调度的概念。【实验内容】7.3.1先来先服务调度的算法#includeusingnamespacestd;constintmaxn=1010;st
2、ructNode{stringname;intarrival_time;intstart_time;intrun_time;intfinish_time;intid;stringstatus;}prog[maxn];boolcmp(Nodea,Nodeb){returna.arrival_time3、c_with_stdio(false);intcnt=0,n,now=0;vectorq;vector::iteratorhead=q.begin(),tail=q.end();cin>>n;for(inti=0;i>prog[i].name>>prog[i].arrival_time>>prog[i].run_time;prog[i].status="R";prog[i].id=i;}sort(prog,prog+n,cmp);while(true4、){cout<<"now"<=n)break;now++;continue;}vector::iteratorit;Nodex=q.front();if(now-x.start_time>=x.run_time){pr5、og[x.id].finish_time=now;prog[x.id].status="C";prog[x.id].start_time=x.start_time;it=q.begin();q.erase(it);//q[0].start_time=now;head=q.begin();head->start_time=now;}if(q.size()==0){cout<<"queueisempty~"<6、;it=q.begin();cout<<"runningprogress:"<name<start_time<run_time-now+it->start_time<7、++it)cout<<""<name<8、averagetime"<usingnamespacestd;constintmaxn=1010;structNode{stringname;intrk;intarrival_time,start_time,run_time,finish_time;inti
3、c_with_stdio(false);intcnt=0,n,now=0;vectorq;vector::iteratorhead=q.begin(),tail=q.end();cin>>n;for(inti=0;i>prog[i].name>>prog[i].arrival_time>>prog[i].run_time;prog[i].status="R";prog[i].id=i;}sort(prog,prog+n,cmp);while(true
4、){cout<<"now"<=n)break;now++;continue;}vector::iteratorit;Nodex=q.front();if(now-x.start_time>=x.run_time){pr
5、og[x.id].finish_time=now;prog[x.id].status="C";prog[x.id].start_time=x.start_time;it=q.begin();q.erase(it);//q[0].start_time=now;head=q.begin();head->start_time=now;}if(q.size()==0){cout<<"queueisempty~"<6、;it=q.begin();cout<<"runningprogress:"<name<start_time<run_time-now+it->start_time<7、++it)cout<<""<name<8、averagetime"<usingnamespacestd;constintmaxn=1010;structNode{stringname;intrk;intarrival_time,start_time,run_time,finish_time;inti
6、;it=q.begin();cout<<"runningprogress:"<name<start_time<run_time-now+it->start_time<7、++it)cout<<""<name<8、averagetime"<usingnamespacestd;constintmaxn=1010;structNode{stringname;intrk;intarrival_time,start_time,run_time,finish_time;inti
7、++it)cout<<""<name<8、averagetime"<usingnamespacestd;constintmaxn=1010;structNode{stringname;intrk;intarrival_time,start_time,run_time,finish_time;inti
8、averagetime"<usingnamespacestd;constintmaxn=1010;structNode{stringname;intrk;intarrival_time,start_time,run_time,finish_time;inti
此文档下载收益归作者所有