You are on page 1of 4

Round Robin CPU Scheduling

Round Robin CPU Scheduling is the most important CPU Scheduling Algorithm which
is ever used in the history of CPU Scheduling Algorithms. Round Robin CPU Scheduling
uses Time Quantum (TQ). The Time Quantum is something which is removed from the
Burst Time and lets the chunk of process to be completed.

Time Sharing is the main emphasis of the algorithm. Each step of this algorithm is
carried out cyclically. The system defines a specific time slice, known as a time
quantum.

1. S. No Process ID Arrival Time Burst Time


2. _ _ _ ______ ______ _______
3. 1 P1 0 7
4. 2 P2 1 4
5. 3 P3 2 15
6. 4 P4 3 11
7. 5 P5 4 20
8. 6 P6 4 9

Assume Time Quantum TQ = 5

Ready Queue:

1. P1, P2, P3, P4, P5, P6, P1, P3, P4, P5, P6, P3, P4, P5

Gantt chart:
EXPALANTION
Absolutely! Here's the step-by-step explanation of the Round Robin example you provided, making
sure to illustrate each stage clearly.

Process Table:

S. No Process ID Arrival Time Burst Time

1 P1 0 7

2 P2 1 4

3 P3 2 15

4 P4 3 11

5 P5 4 20

6 P6 4 9

Time Quantum (TQ): 5

Explanation:

1. Time = 0-5:

o P1 (arrival time 0) is at the front of the ready queue. It executes for the time
quantum (5 units).

o Gantt Chart: | P1 |

0 5

2. Time = 5-10:

o P1 still needs 2 more units to complete. It's moved to the back of the ready queue.

o P2 (arrival time 1) starts execution for its time quantum (5 units).

o Since P2 only needs 4 time units to complete, it finishes and is removed from the
queue.
o Gantt Chart: | P1 | P2 |

0 5 10

3. Time = 10-15:

o P3 (arrival time 2) starts execution and runs for 5 units (the time quantum).

o Gantt Chart: | P1 | P2 | P3 |

0 5 10 15

4. Time = 15-20:

o P3 still has 10 units of burst time remaining, so it's shifted to the back of the ready
queue.

o P4 (arrival time 3) runs for the time quantum.

o Gantt chart: | P1 | P2 | P3 | P4 |

0 5 10 15 20

5. Time = 20-25

o P4 has 6 more units remaining and moves to the back of the ready queue.

o P5 (arrival time 4), even though it's arrived, was waiting in the queue. It starts its
execution.

o Gantt Chart: | P1 | P2 | P3 | P4 | P5 |

0 5 10 15 20 25

6. Time = 25-30:

o P5 is still not finished (needs 15 more units) and moves to the back of the ready
queue.

o P6 (arrival time 4) begins executing.

o Gantt Chart: | P1 | P2 | P3 | P4 | P5 | P6 |

0 5 10 15 20 25 30

7. Time = 30-35:

o P1 is back in front now and needs 2 more time units to complete, which it runs and
then finishes.

o Gantt Chart: | P1 | P2 | P3 | P4 | P5 | P6 | P1 |

0 5 10 15 20 25 30 35
... This process continues in a round-robin fashion until all jobs are completed.

Key Points about Round Robin

• It's great for time-sharing systems where the goal is to give each user/process a fair slice of
the CPU.

• Smaller time quanta lead to more context switching (overhead) but can improve
responsiveness.

• Larger time quanta reduce context switching but may decrease responsiveness for short
processes.

Let me know if you would like to see the complete Gantt chart for the entire execution sequence of
your example!

The Round Robin scheduling algorithm is not preemptive within the time quantum
itself. This means that a process will continue to run uninterrupted until its time
quantum is up, even if a higher-priority process arrives. While the scheduling
appears "preemptive" as processes are swapped out after the time quantum, it's not
truly preemptive within those defined intervals.

Therefore, the Round Robin schedule would remain the same as in the previous
explanation, with no preemption happening during the allotted time quantum for each
process. This characteristic of Round Robin differentiates it from other algorithms
like preemptive priority scheduling, which can interrupt a process even before its
time quantum is complete if a higher-priority process arrives.

You might also like