操作系统课程设计-模拟银行家算法-课程设计_第1页
操作系统课程设计-模拟银行家算法-课程设计_第2页
操作系统课程设计-模拟银行家算法-课程设计_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

操作系统课程设计操作系统课程设计 模拟银行家算法模拟银行家算法 课程设计课程设计 操作系统课程设计 模拟银行家算法 课程设计 计算机数据库课程设计 模模拟银拟银行家算法 用行家算法 用银银行家算法行家算法实现资实现资源分配 源分配 Output 输出某时刻的资源分配情况 Bank 银行家算法的步骤 1 2 3 及4调用安全性算法 Security 进行安全性检查 Main 各种数据结构的定义 假设 有0 4 五个进程 假假设设系系统统的当前状的当前状态态是安全的是安全的 三类资源 即 A B C 以下各种数据均取自课本 97例子 T0 时刻的资源分配表 各种资源的数量分别为 10 5 7 资源情况 进程 Max A B C Allocation A B C Need A B C Available A B C P0 7 5 30 1 07 4 33 3 2 P1 3 2 22 0 01 2 2 P2 9 0 23 0 26 0 0 P3 2 2 22 1 10 1 1 P4 4 3 30 0 24 3 1 include output int arr 5 3 int i j printf A B C n for i 0 i 5 i printf P d i for j 0 j 3 j printf d arr i j printf n int Security int avialable 3 int need 5 3 int allocation 5 3 int j i int work 3 int finish 5 0 0 0 0 0 for j 0 j 3 j work j avialable j for i 0 i 5 i if finish i 0 for j 0 j 3 j if need i j work i finish j 1 for i 0 i 5 i if finish i 0 return 0 else return 1 Bank int i int request 3 int need 5 3 int avialable 3 int allocation 5 3 int int j printf The process id d n i printf The Process Request for j 0 j 3 j printf d request j printf n if request 0 need i 0 j 3 j avialable j avialable j request j allocation i j allocation i j request j need i j need i j request j printf The source after request n printf Allocation n output allocation printf Need n output need printf The Avialable after request for j 0 j 3 j printf d avialable j printf n else printf RequestError else printf RequestError Security avialable need allocation main int id i int Avialable 3 3 3 2 int Max 5 3 7 5 3 3 2 2 9 0 2 2 2 2 4 3 3 int Allocation 5 3 0 1 0 2 0 0 3 0 2 2 1 1 0 0 2 int Need 5 3 7 4 3 1 2 2 6 0 0 0 1 1 4 3 1 int Request 3 i Id of Process printf The source before request n printf MAX n output Max printf Allocation n output Allocation printf Need n output Need printf The Avialable before request for i 0 i 3 i printf d Avialable i printf n pri

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论