【文件属性】:
文件名称:操作系统:银行计算法
文件大小:45KB
文件格式:DOC
更新时间:2012-01-07 15:20:48
银行计算法
死锁避免之银行计算法
#include "string.h"
#include "iostream.h"
#define M 5 //总进程数
#define N 3 //总资源数
#define FALSE 0
#define TRUE 1
//M个进程对N类资源最大资源需求量
int MAX[M][N]={{7,5,3},{3,2,2},{9,0,2},{2,2,2},{4,3,3}};
//系统可用资源数
int AVAILABLE[N]={10,5,7};
//M个进程已经得到N类资源的资源量
int ALLOCATION[M][N]={{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
//M个进程还需要N类资源的资源量
int NEED[M][N]={{7,5,3},{3,2,2},{9,0,2},{2,2,2},{4,3,3}};
int Request[N]={0,0,0};