ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > ZSTU-(2020-2021)-1 > student homework > 2018329621069-张时敏 >
2018329621069_张时敏Homework8 Version 0
👤 Author: by 997371991qqcom 2020-11-26 03:33:18
Initially, Allocate[i,j]=0, which means that no process gets any resources at the initial stage. Assume that the process of requesting resources
Listed as:
Request(1)[M]=(1,0,0);
Request(2)[M]=(2,1,0);
Request(2)[M]=(2,0,1);
Request(3)[M]=(2,1,1);
Request(4)[M]=(0,0,2);
Request(2)[M]=(1,0,1);
Request(1)[M]=(1,0,1);
Please use the Banker algorithm to determine whether each resource request is accepted. If you accept the request, please provide the information after the request is accepted.
Source allocation status, namely Allocate matrix, Need matrix and Available vector.

The output is:
######
第1个请求进程1请求资源被允许
Allocate
1 0 0
0 0 0
0 0 0
0 0 0
Need
2 2 2
6 1 3
3 1 4
4 2 2
Available
8 3 6
############
第2个请求进程2请求资源被允许
Allocate
1 0 0
2 1 0
0 0 0
0 0 0
Need
2 2 2
4 0 3
3 1 4
4 2 2
Available
6 2 6
############
第3个请求进程2请求资源被允许
Allocate
1 0 0
4 1 1
0 0 0
0 0 0
Need
2 2 2
2 0 2
3 1 4
4 2 2
Available
4 2 5
############
第4个请求进程3请求资源被允许
Allocate
1 0 0
4 1 1
2 1 1
0 0 0
Need
2 2 2
2 0 2
1 0 3
4 2 2
Available
2 1 4
############
第5个请求进程4请求资源被允许
Allocate
1 0 0
4 1 1
2 1 1
0 0 2
Need
2 2 2
2 0 2
1 0 3
4 2 0
Available
2 1 2
############
第6个请求进程2请求资源被允许
Allocate
1 0 0
5 1 2
2 1 1
0 0 2
Need
2 2 2
1 0 1
1 0 3
4 2 0
Available
1 1 1
############
第7个请求进程1请求资源被拒绝

 

The source codes are included in the file.  code for banker algorithm

Please login to reply. Login

Reversion History

Loading...
No reversions found.