-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
67 lines (56 loc) · 2.76 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
import RoundRobin
import ShortestJobFirst
import os
def clear_terminal():
if os.name == 'nt': # For Windows
_ = os.system('cls')
else: # For Linux and macOS
_ = os.system('clear')
def main(processes,arrivalTime):
print_info = """
█████╗ ██████╗ ██████╗██╗ ██╗ ███╗ ██╗███████╗████████╗
██╔══██╗██╔══██╗██╔════╝██║ ██║ ████╗ ██║██╔════╝╚══██╔══╝
███████║██████╔╝██║ ███████║ ██╔██╗ ██║█████╗ ██║
██╔══██║██╔══██╗██║ ██╔══██║ ██║╚██╗██║██╔══╝ ██║
██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ╚████║███████╗ ██║
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝
sign up now for cheap vpn at hub.archnet.online
Select Type of CPU Scheduling Calculation:
────────────────────────────────────────
1. Round Robin (RR)
2. Shortest Job First (SJF)
"""
print(print_info)
try:
select = int(input())
except ValueError:
print("Exting")
try:
if select == 1:
clear_terminal()
print("Round Robin (RR)")
RoundRobin.RoundRobinScheduler().run()
elif select == 2:
print("Shortest Job First (SJF)")
sjf = ShortestJobFirst.ProcessScheduler(processes, arrivalTime)
sjf.schedule_processes()
sjf.print_results()
else:
raise ValueError("Select 1 or 2")
except ValueError:
print("Select 1 or 2")
if __name__ == "__main__":
# For SJF we most initial variables
# processes = {"P1": [0, 4],
# "P2": [2, 1],
# "P3": [0, 2],
# "P4": [4, 6]}
# arrival_times = {"P1": 0, "P2": 2, "P3": 0, "P4": 4}
process = {"P1":[2,2],
"P2":[7,1],
"P3":[5,1]}
arrival_times = {"P1":2,
"P2":7,
"P3":5}
# Run
main(process,arrival_times)