-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroundrobin.py
40 lines (34 loc) · 1.1 KB
/
roundrobin.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
import clinkedlist as c
proc = c.CLinkedList()
quantum = 2
n = 3
rem_bt = [4,6,8]
while(1):
done = True
for i in range(n):
if rem_bt[i] > 0:
done = False
if i == 0:
print("Currently Processing P1 with remaining time: ", rem_bt[i])
proc.AtBeginning('P1')
if proc.listcount() > 3:
proc.removeEnd()
proc.listprint()
if i == 1:
print("Currently Processing P2 with remaining time: ", rem_bt[i])
proc.AtBeginning('P2')
if proc.listcount() > 3:
proc.removeEnd()
proc.listprint()
if i == 2:
print("Currently Processing P3 with remaining time: ", rem_bt[i])
proc.AtBeginning('P3')
if proc.listcount() > 3:
proc.removeEnd()
proc.listprint()
if rem_bt[i] > quantum:
rem_bt[i] -= quantum
else:
rem_bt[i] = 0
if done == True:
break