Skip to content

Commit

Permalink
Merge pull request #393 from sifa123/patch-1
Browse files Browse the repository at this point in the history
Create multilevel queue scheduling.py
  • Loading branch information
Kavya-24 authored Oct 6, 2024
2 parents b344807 + 16069ba commit 6b65575
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Python/multilevel queue scheduling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
n = int(input("Enter the number of processes : "))
#print(n)
p = [0] * n
bt = [0] * n
wt = [0] * n
tat = [0] * n
su = [0] * n
for i in range(n):
p[i] = i+1
bt[i] = int(input("Enter the burst time for process " + str(i+1) + ": "))
su[i] = int(input("System/User process (0/1) ? "))

for i in range(n):
for j in range(i+1, n):
if su[i] > su[j]:
p[i], p[j] = p[j], p[i]
bt[i], bt[j] = bt[j], bt[i]
su[i], su[j] = su[j], su[i]

wtavg = 0
tatavg = 0

for i in range(1, n):
wt[i] = wt[i-1] + bt[i-1]
tat[i] = tat[i-1] + bt[i]
wtavg += wt[i]
tatavg += tat[i]

print("PROCESS\tSYSTEM/USER PROCESS\tBURST TIME\tWAITING TIME\tTURNAROUND TIME\n")

for i in range(n):
print(str(p[i]) + "\t\t" + str(su[i]) + "\t\t" + str(bt[i]) + "\t\t" + str(wt[i]) + "\t\t" + str(tat[i]))

0 comments on commit 6b65575

Please sign in to comment.