-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.m
More file actions
46 lines (35 loc) · 1.08 KB
/
test.m
File metadata and controls
46 lines (35 loc) · 1.08 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
n = 5;
m = 3;
Allocation = [0 1 0;
2 0 0;
3 0 2;
2 1 1;
0 0 2];
Max = [7 5 3;
3 2 2;
9 0 2;
2 2 2;
4 3 3];
Available = [3 3 2];
Need = Max - Allocation;
% test isSafe
[Finish, UnlockSequence] = isSafe(m, n, Available, Allocation, Need);
% test request satisfied
Request = [0 0 0;
1 0 2;
0 0 0;
0 0 0;
0 0 0];
[Available, Allocation, Need] = resourceAllocation(m, n, Available, Allocation, Need, Request, 2);
Request = [0 0 0;
0 0 0;
0 0 0;
0 0 0;
3 3 0];
[Available, Allocation, Need] = resourceAllocation(m, n, Available, Allocation, Need, Request, 5);
Request = [0 2 0;
0 0 0;
0 0 0;
0 0 0;
0 0 0];
[Available, Allocation, Need] = resourceAllocation(m, n, Available, Allocation, Need, Request, 1);