forked from nabil-rady/CPU-Scheduling-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
50 lines (40 loc) · 2.33 KB
/
test.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
# Use this file to test
from algorithms.roundrobin import roundrobin
from algorithms.priority_np import priority_np
from algorithms.priority_p import priority_p
from algorithms.FCFS import FCFS
from gantt_chart import gantt_chart
# processes
# p1 = {'name': 'p1', 'arrival_time': 0, 'priority': 2, 'burst_time': 3}
# p2 = {'name': 'p2', 'arrival_time': 2, 'priority': 6, 'burst_time': 5}
# p3 = {'name': 'p3', 'arrival_time': 1, 'priority': 3, 'burst_time': 4}
# p4 = {'name': 'p4', 'arrival_time': 4, 'priority': 5, 'burst_time': 2}
# p5 = {'name': 'p5', 'arrival_time': 6, 'priority': 7, 'burst_time': 9}
# p6 = {'name': 'p6', 'arrival_time': 5, 'priority': 4, 'burst_time': 4}
# p7 = {'name': 'p7', 'arrival_time': 7, 'priority': 10, 'burst_time': 10}
# p1 = {'name': 'p1', 'arrival_time': 0, 'priority': 2, 'burst_time': 11}
# p2 = {'name': 'p2', 'arrival_time': 5, 'priority': 0, 'burst_time': 28}
# p3 = {'name': 'p3', 'arrival_time': 12, 'priority': 3, 'burst_time': 2}
# p4 = {'name': 'p4', 'arrival_time': 2, 'priority': 1, 'burst_time': 10}
# p5 = {'name': 'p5', 'arrival_time': 9, 'priority': 4, 'burst_time': 16}
p1 = {'name': 'p1', 'arrival_time': 1, 'priority': 3, 'burst_time': 8}
p2 = {'name': 'p2', 'arrival_time': 2, 'priority': 4, 'burst_time': 2}
p3 = {'name': 'p3', 'arrival_time': 4, 'priority': 4, 'burst_time': 4}
p4 = {'name': 'p4', 'arrival_time': 5, 'priority': 5, 'burst_time': 1}
p5 = {'name': 'p5', 'arrival_time': 6, 'priority': 2, 'burst_time': 6}
p6 = {'name': 'p6', 'arrival_time': 7, 'priority': 6, 'burst_time': 5}
p7 = {'name': 'p7', 'arrival_time': 11, 'priority': 1, 'burst_time': 1}
negative_waiting_time = [{'name': 'sasa', 'arrival_time': 1, 'burst_time': 2, 'priority': 3}, {'name': 'aass', 'arrival_time': 2, 'burst_time': 3, 'priority': 6}]
# roundrobin
# print(*roundrobin([p1,p2,p3,p4],2))
# priority non preemptive
print(*priority_np([p1, p2, p3, p4, p5, p6, p7]))
# priority preemptive
# print(*priority_p(negative_waiting_time))
# FCFS
#print(*FCFS([p1, p2, p3, p4, p5, p6, p7]))
#print(p1,p2,p3,p4,p5,p6,p7)
# test the gantt chart
#average_waiting_time , processes, x_ticks= priority_p([p1, p2, p3,p4,p5,p6,p7])
#gantt_chart(processes, x_ticks)
# print(*roundrobin([{'name': 'ssd', 'arrival_time': 1, 'burst_time': 3}, {'name': 'ss', 'arrival_time': 7, 'burst_time': 2}, {'name': 'u', 'arrival_time': 8, 'burst_time': 3}]))