Round Robin Scheduling Algorithm With Example
Round Robin Scheduling Algorithm With Example
Example
Round robin is the scheduling algorithm used by the CPU during execution of the
process . Round robin is designed specifically for time sharing systems . 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 , 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 .
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 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 .
Here , User can calculate the average turnaround time and average waiting time
along with the starting and finishing time of each process
Turnaround time : Its the total time taken by the process between starting and
the completion
Waiting time : Its the time for which process is ready to run but not executed
by CPU scheduler
for example ,
we have three processes, slice time/quantum time = 4
Burst time Waiting time Turnaround time
P1 24 6 30
P2 3 4 7
P3 3 7 10
So here we can see the turnaround time for the process 1 is 30 while 7 and 10 for
2nd and 3rd process
A Gantt chart is a chart which shows the start and finish times of all the processes
.
* Throughput is low as the large process is holding up the Central processing unit
for execution .