Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help, thank you Question 2 [30 pts]: Implement Round Robin Scheduling algorithm using queues in Python. It is the most commonly used algorithm for

Need help, thank you

image text in transcribedimage text in transcribed
Question 2 [30 pts]: Implement Round Robin Scheduling algorithm using queues in Python. It is the most commonly used algorithm for CPU scheduling. a Each process takes an equal share of CPU time. For this question we choose a time quantum of 2 units. I After being processed for a predefined time, if the process still requires more computation, it is passed to a waiting queue. Answer the following questions: . Report the time each process is completed a Report wait times of each process in the queue Wait time = End time Arrival Time Required Time Procesle Arrival Time Required Time P1 0 4 P2 1 3 P3 2 2 P4 3 1 from collections import deque time_quantum = 2 class Process: def __init__(se1f, name, arrival_time, required_time): self.name = name self.arriva1_time arrival_time self.required_time = required_time self.time_processed = 0 ] : from collections import deque time_quantum = 2 : class Process: def _init_(self, name, arrival_time, required_time) : self . name = name self. arrival_time = arrival_time self . required_time = required_time self . time_processed = 0 def _repr_(self) : return self. name : p0 = Process ( 'P1' , 0, 4) p1 = Process ( 'P2' , 1, 3) p2 = Process ( 'P3', 2, 2) p3 = Process ( 'P4', 3, 1) processes = [p0, p1, p2, p3] end_times = {process. name:0 for process in processes} wait_times = {process. name:0 for process in processes} 1 : queue = deque ( ) running_proc = None # Tracks running process in the CPU running_proc_time = 0 # Tracks the time running process spent in the CPU for t in range (11) : ### CODE HERE ### 1 : print (end_times) # End times for each process print (wait_times) # Wait times for each process in the queue

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions