-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_resources.py
34 lines (29 loc) · 975 Bytes
/
test_resources.py
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
from ResourceManager.ResourceManager import *
from ProcessManager.Process import *
rec_manager = ResourceManager()
# P S M D
processes = [Process([0, 1, 1, 1, 1, 0, 0, 2]),
Process([0, 1, 1, 1, 2, 1, 1, 1]),
Process([0, 1, 1, 1, 1, 0, 0, 0]),
Process([0, 1, 1, 1, 1, 0, 0, 2]),
Process([0, 1, 1, 1, 1, 0, 0, 2])]
pid = 0
for proc in processes:
proc.pid = pid
pid += 1
for proc in processes[:3]:
if (rec_manager.canAllocate(proc)):
print("Allocating resource...")
rec_manager.allocateAllNeeded(proc)
else:
print("Cannot allocate resource")
rec_manager.print_devices()
rec_manager.deallocateAll(processes[0])
rec_manager.print_devices()
proc = processes[2]
if (rec_manager.canAllocate(proc)):
print("Allocating resource...")
rec_manager.allocateAllNeeded(proc)
else:
print("Cannot allocate resource")
rec_manager.print_devices()