ImageVerifierCode 换一换
格式:DOCX , 页数:14 ,大小:16.54KB ,
资源ID:5861005      下载积分:1 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-5861005.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(银行家算法1文档格式.docx)为本站会员(b****1)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

银行家算法1文档格式.docx

1、Request当进程pi提出资源申请时,系统执行下列步骤:(1)若RequestNeed,转(2);否则错误返回(2)若RequestAvailable,转(3);否则进程等待(3)假设系统分配了资源,则有:=Available-Request;=Allocation+Request;=Need-Request若系统新状态是安全的,则分配完成若系统新状态是不安全的,则恢复原状态,进程等待为进行安全性检查,定义数据结构:Work:ARRAY【1.m】 of integer;Finish:ARRAY【1.n】 of Boolean;安全性检查的步骤:(1) Work:=Available;=fal

2、se;(2) 寻找满足条件的i:a.Finish=false;b.NeedWork;如果不存在,则转(4)(3) Work:=Work+Allocation;=true;转(2)(4) 若对所有i,Finish=true,则系统处于安全状态,否则处于不安全状态/* 银行家算法,操作系统概念(OS concepts Six Edition)作者:ctu_85*/#include malloc.hstdio.h#define alloclen sizeof(struct allocation)#define maxlen sizeof(struct max)#define avalen sizeo

3、f(struct available)#define needlen sizeof(struct need)#define finilen sizeof(struct finish)#define pathlen sizeof(struct path)struct allocationint value;struct allocation *next;struct maxstruct max *next;struct availablestruct available *next;struct needstruct need *next;struct pathstruct path *next

4、;struct finishint stat;struct finish *next;int main()int row,colum,status=0,i,j,t,temp,processtest;struct allocation *allochead,*alloc1,*alloc2,*alloctemp;struct max *maxhead,*maxium1,*maxium2,*maxtemp;struct available *avahead,*available1,*available2,*availabletemp,*workhead,*work1,*work2,*worktemp

5、,*worktemp1;struct need *needhead,*need1,*need2,*needtemp;struct finish *finihead,*finish1,*finish2,*finishtemp;struct path *pathhead,*path1,*path2,*pathtemp;char c;printf(nPlease enter the type of sources the system has:n);scanf(%d,&colum);Please enter the number of processes now in the memory:row)

6、;Please enter the allocation array:for(i=0;irow;i+)The allocation for process p%d:,i);for (j=0;jnext=alloc2-next=NULL;allochead-value);status+;elsealloc2=(struct allocation *)malloc(alloclen);%d,%dalloc2-if(status=1)allochead-next=alloc2;alloc1=alloc2;alloc2-status=0;Please enter the max array:The m

7、ax needed from process p%d:The type %c maxium system resource may needed:maxhead=maxium1=maxium2=(struct max*)malloc(maxlen);maxium1-next=maxium2-maxium1-maxium2=(struct max *)malloc(maxlen);maxium2-maxhead-next=maxium2;maxium1=maxium2;maxium2-Please enter the available array now exists in the syste

8、m:The type %c available system resource number:avahead=available1=available2=(struct available*)malloc(avalen);workhead=work1=work2=(struct available*)malloc(avalen);available1-next=available2-work1-next=work2-available1-value=available1-value;available2=(struct available*)malloc(avalen);work2=(stru

9、ct available*)malloc(avalen);available2-work2-value=available2-avahead-next=available2;workhead-next=work2;available1=available2;work1=work2;available2-alloctemp=allochead;maxtemp=maxhead;needhead=need1=need2=(struct need*)malloc(needlen);need1-next=need2-value=maxtemp-value-alloctemp-need2=(struct

10、need *)malloc(needlen);need2-value=(maxtemp-value)-(alloctemp-needhead-next=need2;need1=need2;maxtemp=maxtemp-next;alloctemp=alloctemp-finihead=finish1=finish2=(struct finish*)malloc(finilen);finish1-next=finish2-stat=0;finish2=(struct finish*)malloc(finilen);finish2-finihead-next=finish2;finish1=fi

11、nish2; /*Initialization compleated*/processtest=0;for(temp=0;tempstat=0)for(j=0;j+,needtemp=needtemp-next,worktemp=worktemp-next)if(needtemp-valuevalue)processtest+;if(processtest=colum)worktemp1-value+=alloctemp-worktemp1=worktemp1-pathhead=path1=path2=(struct path*)malloc(pathlen);path1-next=path2-value=i;path2=(struct path*)malloc(pathlen);path2-pathhead-next=path2;path1=path2;finishtemp-stat=1;for(t=0;tfinishtemp=finishtemp-value=0)nWARNING,the system is in nonsafe status!exit(0);nThe system is in safe status!nThe safe sequence is:dop%d ,pathhead-while(pathhead=pathhead-next);

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2