homework8 Version 0 |
|
👤 Author: by 1403861656qqcom 2021-01-06 14:21:49 |
/*
Authour: david_jett
Time:2015/12/8 23:06
Content:banker's algorithm
*/
#include <iostream>
#include <cstring>
#define m 3 //资源种类
#define n 4 //进程数
struct state
{
int resource[m];
int available[m];
int claim[n][m];
int alloc[n][m];
}P;
using namespace std;
int request[m];
//judge the current state according to banker's algorithm
bool is_Safe(state tmp,int x)
{
bool status[n];
int cnt=1,pos;
memset(status,0,sizeof(status));
status[x]=1;
bool