Question
Round Robin Scheduling Algorithm with Example Round robin is the scheduling algorithm used by the CPU during execution of the process. It is similar to
Round Robin Scheduling Algorithm with Example
Round robin is the scheduling algorithm used by the CPU during execution of the process. It is similar to first come first serve scheduling algorithm but the preemption is the added functionality to switch between the processes.
A small unit of time also known as time slice or quantum is set/defined. The ready queue works like circular queue. All processes in this algorithm are kept in the circular queue also known as ready queue. Each New process is added to the tail of the ready/circular queue. By using this algorithm, the CPU makes sure, time slices (any natural number) are assigned to each process in equal portions and in circular order, dealing with all process without any priority.
It is also known as cyclic executive.
The main advantage of round robin algorithm over first come first serve algorithm is that it is starvation free. Every process will be executed by CPU for a fixed interval of time (which is set as time slice). So, in this way no process left waiting for its turn to be executed by the CPU.
Round robin algorithm is simple and easy to implement. The name round robin comes from the principle known as round robin in which every person takes equal share of something in turn.
Pseudo Code:
* CPU scheduler picks the process from the circular/ready queue, set a timer to interrupt it after 1 time slice/quantum and dispatches it.
*If a process has burst time less than 1 time slice/quantum
> Process will leave the CPU after the completion
> CPU will proceed with the next process in the ready queue / circular queue.
else If process has burst time longer than 1 time slice/quantum
> Timer will be stopped. It causes interruption to the O/S.
> Executed process is then placed at the tail of the circular/ready queue by applying the context switch
> CPU scheduler then proceeds by selecting the next process in the ready queue.
Here, the user can calculate the average waiting time along with the starting and finishing time of each process
Waiting time: It is the time for which process is ready to run but not executed by CPU scheduler
Say we have the process arrival time and burst time chart given below.
| Arrival Time | Burst Time |
P1 | 0 | 16 |
P2 | 0 | 10 |
P3 | 6 | 4 |
P4 | 7 | 6 |
P5 | 8 | 10 |
Write a program to illustrate how these processes would be scheduled using Round Robin (RR) and calculate the waiting time for each process. If when choosing a process to schedule next you could legally choose any of a number of processes, choose the one with the lowest-numbered name; i.e., choose Pi over Pj if i < j.
Do not include context-switching time in your program. Assume that the quantum is set to 5 time units.
Print out the execution of the processes, when a process is completed, and average wait time.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started