Question: Python Change the code to repeatedly execute the code with different time quantum value to be obtained from user input. To repeat execution, ask the
Python
Change the code to repeatedly execute the code with different time quantum value to be obtained from user input. To repeat execution, ask the user whether to continue or not Y to repeat, exit otherwise Changes required are marked by #NOTE within the code.
def roundrobinschedulingprocesses quantum:
n lenprocesses
rembursttimes p for p in processes
waitingtime n
turnaroundtime n
t # Current time
order # To track the order of execution
while anyrembursttimesi for i in rangen:
for i in rangen:
if rembursttimesi:
processexecuted False
if rembursttimesi quantum:
#NOTE: do the change here to track the execution order
t quantum
rembursttimesi quantum
processexecuted True
else:
#NOTE: do the change here to track the execution order
t rembursttimesi
waitingtimei t processesi
rembursttimesi
processexecuted True
if processexecuted:
#NOTE: do the required change here
#NOTE: print a message "Process executed for units"
pass
# Calculate turnaround time
for i in rangen:
turnaroundtimei processesi waitingtimei
# Calculate average times
avgwaiting sumwaitingtime n
avgturnaround sumturnaroundtime n
# Display results
print
Process IDtBurst TimetWaiting TimetTurnaround Time"
for i in rangen:
printfprocessesittprocessesittwaitingtimeittturnaroundtimei
printf
Average Waiting Time: avgwaiting
printfAverage Turnaround Time: avgturnaround
# Print execution order and number of context switch
print
Execution Order Process ID Time Units:
#NOTE do the required change here
if namemain:
#NOTE do the required change here
# List of processes processid bursttime
# Assuming same initial arrival time for all process
processes
quantum
roundrobinschedulingprocesses quantum
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
