-
Notifications
You must be signed in to change notification settings - Fork 0
/
RR.py
36 lines (36 loc) · 1.14 KB
/
RR.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
# creating list
process = []
count = 0
num = input("Please enter the number of your processes: ")
num = int(num)
while(count < num):
x = input("Please enter the time of your processes %s: " %(count+1))
x = int(x)
process.append(x)
count+=1
print("==================================================")
print("==================================================")
# sort & display list of process
process.sort()
print("List of Process is : ", process)
print("==================================================")
print("==================================================")
#starting process
L = int(len(process))
while(L > 0):
count = 0
while(count < L):
y = count
if(process[y] == 0):
process.remove(process[y])
L = int(len(process))
count = -1
elif(process[y] > 0):
print("Process %s is running..." %(count+1))
process[y]-=2
if(process[y] <= 0):
print("Execution of the process %s is completed" %(count+1))
process[y] = 0
print(process)
count+=1
print("All processes were executed with Algorithm RR.")