-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbankerAlgo.m
More file actions
34 lines (23 loc) · 751 Bytes
/
bankerAlgo.m
File metadata and controls
34 lines (23 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
n = 5;
m = 4;
Allocation = [0 0 1 2;
1 0 0 0;
1 3 5 4;
0 6 3 2;
0 0 1 4];
Max = [0 0 1 2;
1 7 5 0;
2 3 5 6;
0 6 5 2;
0 6 5 6];
Available = [1 5 2 0];
Need = Max - Allocation;
% test isSafe
[Finish, UnlockSequence] = isSafe(m, n, Available, Allocation, Need);
% test request satisfied
Request = [0 0 0 0;
0 4 2 0;
0 0 0 0;
0 0 0 0;
0 0 0 0];
[Available, Allocation, Need] = resourceAllocation(m, n, Available, Allocation, Need, Request, 2);