


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#include <iostream>#include <stdlib.h>#include <cstring>#include <stdio.h> using namespace std;class pcbpublic:char name;int prioORround; int cputime;int count;int needtime; char state; pcb *next;class createpcbpublic:pcb* newpcb(int count) private:pcb *apcb=new pcb; switch(c
2、ount)case 1: apcb->name='a'break; case 2: apcb->name='b'break; case 3: apcb->name='c'break; case 4: apcb->name='d'break; case 5: apcb->name='e'break; default: cout<<" 错误" apcb->prioORround=45+rand()%5; apcb->cputime=0;apcb-
3、>count=0; apcb->needtime=10+rand()%5; apcb->state='R'apcb->next=NULL; return apcb;pcb *;class printpublic:void printf(pcb *ready,pcb *tail,pcb *finish,pcb *run)p=run;cout<<" 运行: "while(p->next!=NULL)p=p->next; cout<<p->name<<":"<&
4、lt;p->needtime<<"t"p=ready;coutvv"就绪:"while(p->next!=tail)p=p->next; coutvvp->namevv":"vvp->needtimevv"t"p=finish;coutvv"完成:"while(p->next!=NULL)p=p->next; coutvvp->namevv":"vvp->needtimevv"t"coutv
5、vendl;private:pcb *p;class insert1public:void insert(pcb *ready,pcb *tail)k=ct.newpcb(ready->count);ready->count+=1;p=ready;while(p->next!=tail&&p->next->prioORround>k->prioORround) p=p->next;k->next=p->next;p->next=k;void insert(pcb *ready,pcb *tail,pcb *fin
6、ish,pcb *run) pt.printf(ready,tail,finish,run); k=run->next;k->prioORround-=3; k->cputime+=1; k->needtime-=1;k->state='R' k->next=NULL; run->next=NULL;if(k->needtime>0) p=ready;while(p->next!=tail&&p->next->prioORround>k->prioORround) p=p->
7、;next;k->next=p->next;p->next=k;elsep=finish;while(p->next!=NULL)p=p->next; p->next=k;private:pcb *p;pcb *k;createpcb ct;print pt;class insert2public:void insert(pcb *ready,pcb *tail) k=ct.newpcb(ready->count); ready->count+=1; p=ready; while(p->next!=tail) p=p->next;k-
8、>next=p->next;p->next=k;void insert(pcb *ready,pcb *tail,pcb *finish,pcb *run)pt.printf(ready,tail,finish,run);k=run->next;k->cputime+=2;k->needtime-=2;k->state='R'k->next=NULL;run->next=NULL;if(k->needtime>0)p=ready;while(p->next!=tail)p=p->next;k->
9、next=p->next;p->next=k;elsep=finish;while(p->next!=NULL)p=p->next;p->next=k;private:pcb *p;pcb *k;createpcb ct;print pt;class firstinpublic:void runs(pcb *ready,pcb *tail,pcb *run)if(ready->next!=tail)p=run;p->next=ready->next;p=p->next;ready->next=p->next;p->stat
10、e='W'p->next=NULL; private:pcb *p; ;class prisch public: prisch() private:system("cls"); ='R' ready.count=1; ='T' ='F' ready.next=&tail; tail.next=NULL; finish.next=NULL; run.next=NULL; printf("ttt 优先级数调度 n"); w
11、hile(1)if(ready.count<=5) inst.insert(&ready,&tail);fir.runs(&ready,&tail,&run); inst.insert(&ready,&tail,&finish,&run); if(ready.next=&tail)break; pt.printf(&ready,&tail,&finish,&run); getchar();pcb *p; pcb ready; pcb tail;pcb finish; pcb r
12、un; insert1 inst; firstin fir; print pt; string algo;class roundschpublic:roundsch() system("cls"); ='R' ready.count=1; ='T' ='F' ready.next=&tail; tail.next=NULL; finish.next=NULL; run.next=NULL; printf("ttt 时间片轮转调度 n");
13、while(1)if(ready.count<=5) inst.insert(&ready,&tail); fir.runs(&ready,&tail,&run); inst.insert(&ready,&tail,&finish,&run); if(ready.next=&tail)break;pt.printf(&ready,&tail,&finish,&run); getchar();private:pcb *p;pcb ready;pcb tail;pcb finish
14、;pcb run;insert2 inst;firstin fir;print pt;class menupublic:menu()char c;bool z=false;while(1)system("cls");cout<<"nnntt* 抢占优先数调度算法和 时间片轮转调度算法 *nn"<<endl;int main(int args,char* argv) menu menu; return 0;<<"tt*ttt1, 优先级数调度 tt*n"<<endl <<"tt*tt2, 时间片轮转调度 tt*n"<<endl <<"tt*t3, 退出程序 tttt*n"<<endln"<<endl;if(z=true)cout<<"tttt 选择输入错误! "<<endl
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025内蒙古鄂尔多斯生态环境职业学院专业技术人员招聘18人考前自测高频考点模拟试题附答案详解(典型题)
- 2025年中国化学农药增效剂行业市场分析及投资价值评估前景预测报告
- 2025河北邯郸市馆陶县辅助性岗位招聘13人模拟试卷附答案详解(黄金题型)
- 2025广西资源县中峰镇中心卫生院招聘编外专业技术人员2人模拟试卷有完整答案详解
- 2025年河北保定曲阳县公开选聘职教中心教师18名模拟试卷及答案详解(有一套)
- 2025年六安金寨县人民医院招聘10人模拟试卷及答案详解(新)
- 2025海南文昌市人民医院招聘编外合同制护理人员10人考前自测高频考点模拟试题及答案详解(考点梳理)
- 2025内蒙古恒正实业集团有限公司招聘10人考前自测高频考点模拟试题附答案详解(考试直接用)
- 2025年甘肃省庆阳市正宁县三嘉乡选聘返乡能人、致富带头人到村任职(兼职)模拟试卷及答案详解(有一套)
- 2025北京大学实验动物中心事业编制工程技术岗位招聘1人模拟试卷及一套完整答案详解
- 2026年湖北省地震局事业单位公开招聘12人笔试参考题库附答案解析
- 2025年自考艺术教育题库及答案
- 化工前沿技术进展
- 2025年四川省党政领导干部政治理论水平考试(理论测试)练习题及答案
- 2025年下半年全国中学生天文知识竞赛测试题(附参考答案)
- 高一物理第一次月考卷(全解全析)(天津专用)
- 2025年专利审查对专利密集型行业分析方案
- 2025成考专升本政治试题及答案解析
- 肺间质纤维化教学课件
- DBS教材03精益转换训练
- 护理实习生院感培训课件
评论
0/150
提交评论