-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.py
76 lines (58 loc) · 1.57 KB
/
Main.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from DiskSpace import Diskspace
from MainMemory import MainMemory
from Scheduler import Scheduler
from MemoryManager import MemoryManager
from Parser import extract_data
from Clock import myClock
from Commands import Commands
from os import remove
import logging
def main():
# setup logging to output.txt
logging.basicConfig(
filename="output.txt",
filemode="w",
force=True,
level=logging.INFO,
format="{message}",
style="{",
)
logger = logging.getLogger(__name__)
listOfThreads = []
(
listOfProcesses,
maximumNumberOfPages,
numberOfCores,
listOfCommands,
K_VALUE,
timeOut,
) = extract_data()
commands = Commands(listOfCommands)
mainMemory = MainMemory(maximumNumberOfPages, K_VALUE, timeOut)
diskSpace = Diskspace()
memoryManager = MemoryManager(commands, diskSpace, mainMemory)
# start the clock
myClock.start()
# start the MMU
memoryManager.start()
# initialise and start the Scheduler
scheduler = Scheduler(
numberOfCores,
memoryManager,
commands,
listOfProcesses,
listOfThreads,
)
scheduler.start()
listOfThreads.append(memoryManager)
listOfThreads.append(scheduler)
listOfThreads.append(myClock)
scheduler.process_thread()
for thread in listOfThreads:
thread.setFinished(True)
thread.join()
remove("vm.txt")
logger.debug(f"Memory: {memoryManager.mainMemory}")
print("Simulation Complete")
if __name__ == "__main__":
main()