- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
模拟进程调度及银行家算法的实现(Simulation process scheduling and bankers algorithm implementation)
模拟进程调度及银行家算法的实现(Simulation process scheduling and bankers algorithm implementation)
/ / main.cpp
#包括“银行家。”
#包括”的过程。”
#包括时间。”
#包括程序。”
主()
{
int的选择;
cout “请输入选择:(1。进程调度2。银行家算法。0退出)“ endl;
选择;
PCB电路板;
队列Qready;
国际timeclips;
int过程;
int i;
在运行时;
国际runedtime = 0;
int消磨时间= 0;
int max [ ] [ 3 ] = { 5,5,9,5,3,6,4,0,11,4,2,5,4,2,4 };
int分配[ ] [ 3 ] = { 2,1,2,4,0,2,4,0,5,2,0,4,3,1,4 };
int需要[ 5 ] [ 3 ];
int可用[ ] = { 2,3,3 };
k,j;
int请求[ 3 ];
如果(1 =选择)
{
srand((int)时间(空));
InitQueue(qready);
cout “请输入进程数:”;
过程;
cout “请输入时间片:”;
timeclips CIN;
对于(i = 0;i 过程;i + +)
{
运行时间= int(10×rand() / rand_max)+ 1;
pcb.name =我;
pcb.runtime =运行;
pcb.runedtime = 0;
pcb.killtime = 0;
PushNode(Qready,PCB);
cout “过程” PCB。名字“”运行时=“ pcb.runtime “”runedtime =“ pcb.runedtime “”消磨时间=“ pcb.killtime;
cout endl;
}
流程的运行(Qready,timeclips);
}
如果(2 =选择)
{
ArraySub(马克斯,分配,需要);
showarray(马克斯,分配,可用);
int的选择;
cout “请输入选择:(1。分配资源0。退出))“ endl;
选择;
而(选择)
{
cout “请输入进程号:”;
CIN K;
cout “请输入申请资源数:”;
请求[ 0 ]…请求[ 1 ]请求[ 2 ];
k=k - 1;
银行家(需要,请求,可用,分配,K);
showarray(马克斯,分配,可用);
cout “请输入选择:(1。继续分配资源0。退出))“ endl;
选择;
}
}
返回0;
}
/ / bank.cpp
#包括“银行家。”
int ArraySub(int array1 [ ] [ 3 ],int array2 [ ] [ 3 ],int array3 [ ] [ 3 ])
{
int,j;
对于(i = 0;i 5;i +)
对于(j=0;j<3;j + +)
array3 [我] [ J ] = array1 [我] [ J ] - array2 [我] [ J ];
返回0;
}
布尔comparearray(int的要求[ ],int需要[ ])
{
int i;
对于(i = 0;i 3;i +)
如果(请求[我]需要[我])
返回false;
返回true;
}
int减(int 1 [ ] [ ]以邻,int)
{
int i;
对于(i = 0;i 3;i +)
1 [我] = 1 [我] - [我]以邻;
返回0;
}
int加(int 1 [ ] [ ]以邻,int)
{
int i;
对于(i = 0;i 3;i +)
1 [我] = 1 [我] + [我]以邻;
返回0;
}
int拷贝(int 1 [ ] [ ]以邻,int)
{
int i;
对于(i = 0;i 3;i +)
1 [我] =以邻[我];
返回0;
}
int CopyArray(int array1 [ ] [ 3 ],int array2 [ ] [ 3 ])
{
int,j;
对于(i = 0;i 5;i +)
对于(j=0;j<3;j + +)
array1 [我] [ J ] = array2 [我] [ J ];
返回0;
}
布尔搜索过程(int需要[ ] [ 3 ],int可用[ ],[ ]为国家,int和K)
{
int i;
对于(i = 0;i 5;i +)
如果(comparearray(需要[我],可用)!B带[我])
{
k = i;
返回true;
}
返回false;
}
bool类型安全(int需要[ ] [ 3 ],int可用[ ],int分配[ ] [ 3 ],国际安全[ 5 ])
{
bool bstate [] =
您可能关注的文档
- 如何定位《 黑客 ip》(How to locate hacker IP).doc
- 如何实现文件下载(How do I implement file downloads).doc
- 如何建设一个能产生效益的企业网站(How to build an enterprise website that can produce benefit).doc
- 如何快速提高六级成绩——我的亲身经历(How to improve six grades quickly - my own experience).doc
- 如何成为大老板(How to be a big boss).doc
- 如何坦然应对经销商的发难(二)(How to cope with the challenge of dealers (two)).doc
- 如何建立商业银行风险管理体系(How to establish a risk management system for commercial banks).doc
- 如何学套定额(How to set quotas).doc
- 如何把电吉他弹得飞快(How do you play the electric guitar so fast).doc
- 如何完好微波炉·(How good is the microwave oven).doc
- 梁冰有万分之一就不得了(Liang Bing 110000 of them are incredible).doc
- 每日一语(Daily expression).doc
- 每日一句英语(One English sentence a day).doc
- 毛绒小熊(Plush bear).doc
- 民企宿命在于自以为是管理(Private enterprise lies in self righteous management).doc
- 民升外降,人才竞争力显露新格局(People rise, outside down, talent competitiveness show new pattern).doc
- 母鸡加点(The hen added some).doc
- 民族团结43938(National unity 43938).doc
- 民营企业六忌(Six private enterprises).doc
- 民营医院管理中5大关键管理(5 key management in private hospital management).doc
最近下载
- 2024河南郑州文化旅游和体育集团有限公司社会化公开招聘34人笔试备考试题及答案解析.docx VIP
- 招标代理档案管理制度.docx VIP
- 2025南方电网昆明供电局项目制用工招聘(48人)笔试模拟试题及答案解析.docx VIP
- 农业服务中心2025年度工作计划 .doc VIP
- 外窗防水节点施工方案(JS).doc
- 2025-2026学年小学科学五年级上册青岛版(五四制2024)教学设计合集.docx
- 2025《J金融租赁公司所在行业的波特五力模型分析》5800字.doc
- 2025金风变流器2.0MW故障代码手册V4.docx VIP
- AP微积分AB 2014年真题 (选择题+问答题) AP Calculus AB 2014 Released Exam and Answers (MCQ+FRQ).pdf VIP
- 动态口令认证机制的网上投票系统设计与实现.docx VIP
文档评论(0)