Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please don't copy from anywhere Can you edit (as much as you can) this Python code to be Round Robin scheduling algorithm, and add avg

Please don't copy from anywhere

Can you edit (as much as you can) this Python code to be Round Robin scheduling algorithm, and add avg turnaround time?

AND ATTACH THE RESULT and Check the solution please

print("FIRST COME FIRST SERVE SCHEDULLING")

n= int(input("Enter number of processes : "))

d = dict()

for i in range(n):

key = "P"+str(i+1)

a = int(input("Enter arrival time of process"+str(i+1)+": "))

b = int(input("Enter burst time of process"+str(i+1)+": "))

l = []

l.append(a)

l.append(b)

d[key] = l

d = sorted(d.items(), key=lambda item: item[1][0])

ET = []

for i in range(len(d)):

# first process

if(i==0):

ET.append(d[i][1][1])

# get prevET + newBT

else:

ET.append(ET[i-1] + d[i][1][1])

TAT = []

for i in range(len(d)):

TAT.append(ET[i] - d[i][1][0])

WT = []

for i in range(len(d)):

WT.append(TAT[i] - d[i][1][1])

avg_WT = 0

for i in WT:

avg_WT +=i

avg_WT = (avg_WT/n)

print("Process | Arrival | Burst | Exit | Turn Around | Wait |")

for i in range(n):

print(" ",d[i][0]," | ",d[i][1][0]," | ",d[i][1][1]," | ",ET[i]," | ",TAT[i]," | ",WT[i]," | ")

print("Average Waiting Time: ",avg_WT)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions