c实现银行家算法(2)

2025-09-11

操作系统课程里 用C语言实现银行家算法。

Work:ARRAY[1..m] of integer;

Finish:ARRAY[1..n] of Boolean;

安全性检查的步骤:

step (1):

Work=Available;

Finish=false;

step (2) 寻找满足条件的i:

a.Finish==false;

b.Need<=Work;

如果不存在,goto step(4)

step(3)

Work=Work+Allocation;

Finish=true;

goto step(2)

step (4) 若对所有i,Finish=true,则系统处于安全状态,否则处于不安全状态 /* 银行家算法,操作系统概念(OS concepts Six Edition)

reedit by Johnny hagen,SCAU,run at vc6.0

*/

#include "malloc.h"

#include "stdio.h"

#include "stdlib.h"

#define alloclen sizeof(struct allocation)

#define maxlen sizeof(struct max)

#define avalen sizeof(struct available)

#define needlen sizeof(struct need)

#define finilen sizeof(struct finish)

#define pathlen sizeof(struct path)

struct allocation

{

int value;

struct allocation *next;

};

struct max

{

int value;

struct max *next;

};

struct available /*可用资源数*/

{

int value;

struct available *next;

};


c实现银行家算法(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:清单革命

相关阅读
本类排行
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 7

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219