Round Robin Algo
Round Robin Algo
Step 2: Now, we push the first process from the ready queue to execute its
task for a fixed time, allocated by each process that arrives in the queue.
Step 3: If the process cannot complete their task within defined time
interval or slots because it is stopped by another process that pushes from
the ready queue to execute their task due to arrival time of the next process
is reached. Therefore, CPU saved the previous state of the process, which
helps to resume from the point where it is interrupted. (If the burst time of
the process is left, push the process end of the ready queue).
Step 4: Similarly, the scheduler selects another process from the ready
queue to execute its tasks. When a process finishes its task within time slots,
the process will not go for further execution because the process's burst time
is finished.
Step 5: Similarly, we repeat all the steps to execute the process until the
work has finished.
1. It is a pre-emptive algorithm.
2. It shares an equal time interval between all processes to complete
their task.
3. It is a starvation free CPU scheduling algorithm. Hence it is known as
the fairest and simple algorithm.
Advantages
Disadvantage
P1 0 8
P2 5 2
P3 1 7
P4 6 3
P5 8 5
Now we have to create the ready queue and the Gantt chart for Round
Robin CPU Scheduler.
Ready queue: P1, P3, P1, P2, P4, P3, P5, P1, P3, P5
Step 1: At time 0, process P1 enters the ready queue and starts its
execution for the defined time slot 3. During 3 units of the time slice, another
process, P3, arrives in the ready queue because its arrival time is 1.
Step 2: Now, process P3 starts its execution with a time slot of 3 units while
process P1 has to wait. After execution of process P3, process P1 again
resumes its execution for time slot 3.
Step 3: During the execution of process P1, two more processes P2 and P4,
arrive in the ready queue to begin their execution. Since process P2 has
come first, it will be executed for time quantum 2 units after that P4 is
executed.
Step 4: Here, P4 has executed for time slot 3 units, and its task is completed
because BT (Burst Time) is 2. Hence it will not go to the ready queue.
Step 5: After that, process P3 is executed from the ready queue for time slot
3 and then process P5 arrives for time slot 3.
Step 7: Now process P1 is fetched from the ready queue and starts their
execution for time slot 2 as it requires only 2 BT to finish its tasks. Hence it
will not go to the ready queue for further execution.
Step 8: Now, the process P3 is executed for time slot 1 as it requires only 1
BT to complete its tasks.
Step 9: The final process P5 is executed for time slot 2 because it requires
only 2 BT to complete its tasks.
The following are the important terms to find the Completion time, Turn
Around Time (TAT), Response Time (RT) and Waiting Time (WT).
P1 0 8 22 22 14 0
P2 5 2 11 6 4 4
P3 1 7 23 22 15 2
P4 6 3 14 8 5 5
P5 8 5 25 17 12 9
Turn Around Time for P1 = Completion Time (CT) - Arrival Time (AT)
22 - 0 = 22
Turn Around Time for P2 = 11 - 5 = 6
Turn Around Time for P3 = 23 - 1 = 22
Turn Around Time for P4 = 14 - 6 = 8
Turn Around Time for P5 = 25 - 8 = 17
Waiting Time for P1 = Turn Around Time (TAT) - Burst Time (BT)
22 - 8 = 14
Waiting Time for P2 = 6 - 2 = 4
Waiting Time for P3 = 22 - 7 = 15
Waiting Time for P4 = 8 - 3 = 5
Waiting Time for P5 = 17 - 5 = 12