Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def Shortest _ remaining _ Time ( processes ) : GanttChart = [ ] ready _ queue = deque ( ) waiting _ queue =

def Shortest_remaining_Time(processes):
GanttChart =[]
ready_queue = deque()
waiting_queue = deque()
current_time =0
temp =1
GanttChart.append((processes[0].num, current_time, temp))
if (processes[1].Arrival_time >= temp):
current_time += processes[1].Burst_time + temp
GanttChart.append((processes[1].num, temp, current_time))
processes.sort(key=lambda y: (y.Burst_time))
while current_time <=200:
for process in processes:
if current_time < process.Arrival_time: # Check attribute consistency
current_time = process.Arrival_time
if current_time <=200:
if process.remaining_time >0 and process not in ready_queue and process not in waiting_queue:
if process.Burst_time == process.remaining_time:
GanttChart.append((process.num, current_time, current_time + process.Burst_time))
process.waiting_time = max(0, current_time - process.Arrival_time)
process.turnaround_time = process.waiting_time + process.Burst_time
ready_queue.append(process)
if ready_queue:
ready_queue = deque(sorted(ready_queue, key=lambda x: x.remaining_time))
process = ready_queue.popleft()
GanttChart.append((process.num, current_time, current_time +1))
process.remaining_time -=1
temp +=1
current_time +=1
if process.remaining_time ==0:
waiting_queue.append(process)
temp =0
else:
current_time +=1
if waiting_queue:
for process in waiting_queue:
if temp >= process.Comes_back_after:
ready_queue.append(process)
waiting_queue.remove(process)
break
avg_waiting_time = calculate_average_waiting_time(processes)
avg_turnaround_time = calculate_average_turnaround_time(processes)
TurnAroundTimeTotalwithSupposed_p_srtf = sum(process.turnaround_time for process in processes if process.remaining_time ==0)
return GanttChart, avg_waiting_time, avg_turnaround_time, TurnAroundTimeTotalwithSupposed_p_srtffix it to give me this results:Shortest Remaining Time First:
GANTT CHART:
0 P11 P29 P613 P518 P719 P623 P728 P533 P637 P542 P743 P647 P752 D557 P661 P566 P767 P671 P776 P581 P685 P590 P791 P695 P7100 P5105 P6109 P5114 P7115 P6119 P7124 P5129 P6133 P5138 P7139 P6143 P7148 P5153 P6157 P5162 P7163 P6167 P7172 P5177 P6181 P5186 P7187 P6191 P7196 P5200
Average waiting time =35.4
Average turnaround time =115

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions