Jump To Question
Round Robin Scheduling Algorithm in Operating System
Round Robin (RR) is a preemptive scheduling algorithm that assigns a fixed time slice (or time quantum) to each process in the ready queue. Each process is allowed to run for a time quantum, and if it doesn’t finish within this period, it is sent back to the end of the queue, and the next process in line is executed. This cycle continues until all processes are completed.
Method to Solve Round Robin Scheduling Algorithm
- Step 1: Determine the time quantum (time slice) for each process.
- Step 2: Place all processes in the ready queue.
- Step 3: Assign the first process the CPU for the duration of the time quantum.
- Step 4: If the process completes within the time quantum, remove it from the queue; otherwise, place it at the end of the queue.
- Step 5: Move to the next process and repeat the same steps until all processes have completed.
- Step 6: Calculate the average waiting time and average turnaround time for performance evaluation.
Advantages and Disadvantages of Round Robin Scheduling
Advantages | Disadvantages |
---|---|
Simple and easy to implement. | Higher turnaround time due to frequent context switching. |
Prevents process starvation as each process gets CPU time. | Performance is heavily dependent on time quantum. |
Good for time-sharing systems. | Not ideal for processes with varying burst times. |
Ensures fairness by giving each process equal time quantum. | May lead to CPU inefficiency if time quantum is too small. |
Responsive to interactive applications due to frequent preemption. | Higher context switching overhead compared to non-preemptive algorithms. |
Better for systems requiring real-time responsiveness. | Processes with long burst times may need multiple cycles to complete. |
Why Round Robin is Better Than Other Scheduling Algorithms
Round Robin scheduling is often better than other scheduling algorithms like First Come First Serve (FCFS) and Shortest Job Next (SJN) in scenarios that require fairness and responsiveness. By allocating equal time slices, it ensures that no process is starved of CPU time, making it suitable for time-sharing systems. It also allows for quick response times for interactive processes, making it ideal for real-time applications. Its preemptive nature means that long processes do not monopolize the CPU, improving the overall efficiency of multi-tasking environments.
Question 1 : find the average Turn Around Time and Waiting Time of following processes using RR(Round Robin) process scheduling algorithm? Consider the following processes with their Arrival Time, Burst Time (take Quantum Time = 2).
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 4 |
P2 | 1 | 3 |
P3 | 2 | 2 |
P4 | 3 | 1 |
Solution :
Formula:
- Turnaround Time = Completion Time - Arrival Time
- Waiting Time = Turnaround Time - Burst Time
- Average Turnaround Time = Sum of Turnaround Times / Number of Processes
- Average Waiting Time = Sum of Waiting Times / Number of Processes
Gantt Chart
Process | Arrival Time | Burst Time | Completion Time | Turnaround Time | Waiting Time |
---|---|---|---|---|---|
P1 | 0 | 4 | 8 | 8 | 4 |
P2 | 1 | 3 | 10 | 9 | 6 |
P3 | 2 | 2 | 6 | 4 | 2 |
P4 | 3 | 1 | 9 | 6 | 5 |
Average Turnaround Time = (8 + 9 + 4 + 6) / 4 = 6.75
Average Waiting Time = (4 + 6 + 2 + 5) / 4 = 4.25
Question 2: find the average Turn Around Time and Waiting Time of following processes using RR(Round Robin) process scheduling algorithm? Consider the following processes with their Arrival Time, Burst Time (take Quantum Time = 2).
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 6 |
P2 | 1 | 4 |
P3 | 2 | 3 |
P4 | 3 | 5 |
P5 | 4 | 2 |
Solution :
Formula:
- Turnaround Time = Completion Time - Arrival Time
- Waiting Time = Turnaround Time - Burst Time
- Average Turnaround Time = Sum of Turnaround Times / Number of Processes
- Average Waiting Time = Sum of Waiting Times / Number of Processes
Gantt Chart
Process | Arrival Time | Burst Time | Completion Time | Turnaround Time | Waiting Time |
---|---|---|---|---|---|
P1 | 0 | 6 | 17 | 17 | 11 |
P2 | 1 | 4 | 14 | 13 | 9 |
P3 | 2 | 3 | 15 | 13 | 10 |
P4 | 3 | 5 | 20 | 17 | 12 |
P5 | 4 | 2 | 12 | 8 | 16 |
Average Turnaround Time = (17 + 13 + 13 + 17 + 8) / 5 = 13.6
Average Waiting Time = (11 + 9 + 10 + 12 + 6) / 5 = 9.6
Question 3: find the average Turn Around Time and Waiting Time of following processes using RR(Round Robin) process scheduling algorithm? Consider the following processes with their Arrival Time, Burst Time (take Quantum Time = 2).
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 5 |
P2 | 1 | 3 |
P3 | 2 | 4 |
P4 | 3 | 2 |
Solution :
Formula:
- Turnaround Time = Completion Time - Arrival Time
- Waiting Time = Turnaround Time - Burst Time
- Average Turnaround Time = Sum of Turnaround Times / Number of Processes
- Average Waiting Time = Sum of Waiting Times / Number of Processes
Gantt Chart
Calculation
Process | Arrival Time | Burst Time | Completion Time | Turnaround Time | Waiting Time |
---|---|---|---|---|---|
P1 | 0 | 5 | 14 | 14 | 9 |
P2 | 1 | 3 | 11 | 10 | 17 |
P3 | 2 | 4 | 13 | 11 | 7 |
P4 | 3 | 2 | 10 | 7 | 5 |
Average Turnaround Time = (14 + 10 + 11 + 7) / 4 = 10.5
Average Waiting Time = (9 + 7 + 7 + 5) / 4 = 7
Question 4 : find the average Turn Around Time and Waiting Time of following processes using RR(Round Robin) process scheduling algorithm? Consider the following processes with their Arrival Time, Burst Time (take Quantum Time = 1).
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 5 | 4 |
P2 | 1 | 5 |
P3 | 0 | 6 |
P4 | 3 | 2 |
P5 | 4 | 3 |
P6 | 2 | 7 |
Solution :
Formula:
Turnaround Time (TAT) = Completion Time - Arrival Time
Waiting Time (WT) = Turnaround Time - Burst Time
Solution:
Gantt Chart
Calculations:
Process | Completion Time | Turnaround Time (TAT) | Waiting Time (WT) |
---|---|---|---|
P1 | 25 | 20 | 16 |
P2 | 22 | 21 | 16 |
P3 | 23 | 23 | 17 |
P4 | 12 | 9 | 7 |
P5 | 19 | 15 | 12 |
P6 | 27 | 25 | 18 |
Average Turnaround Time:
(20+21+23+9+15+25) / 6 = 18.83
Average Waiting Time:
(16+16+17+7+12+18) / 6 = 14.33
Question 5 : find the average Turn Around Time and Waiting Time of following processes using RR(Round Robin) process scheduling algorithm? Consider the following processes with their Arrival Time, Burst Time (take Quantum Time = 2)
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 2 |
P2 | 1 | 3 |
P3 | 2 | 1 |
P4 | 3 | 2 |
P5 | 4 | 3 |
Solution :
Formula:
- Turnaround Time = Completion Time - Arrival Time
- Waiting Time = Turnaround Time - Burst Time
- Average Turnaround Time = Sum of Turnaround Times / Number of Processes
- Average Waiting Time = Sum of Waiting Times / Number of Processes
Gantt Chart
Process | Completion Time | Turnaround Time | Waiting Time |
---|---|---|---|
P1 | 2 | 2 - 0 = 2 | 2 - 2 = 0 |
P2 | 10 | 10 - 1 = 9 | 9 - 3 = 6 |
P3 | 5 | 5 - 2 = 3 | 3 - 1 = 2 |
P4 | 7 | 7 - 3 = 4 | 4 - 2 = 2 |
P5 | 11 | 11 - 4 = 7 | 7 - 3 = 4 |
Average Turnaround Time:
(2 + 9 + 3 + 4 + 7) / 5 = 5
Average Waiting Time:
(0 + 6 + 2 + 2 + 4) / 5 = 2.8
Question 6: find the average Turn Around Time and Waiting Time of following processes using RR(Round Robin) process scheduling algorithm? Consider the following processes with their Arrival Time, Burst Time (take Quantum Time = 2).
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 3 |
P2 | 1 | 2 |
P3 | 2 | 1 |
P4 | 3 | 2 |
P5 | 4 | 3 |
Solution :
Formula:
- Turnaround Time = Completion Time - Arrival Time
- Waiting Time = Turnaround Time - Burst Time
- Average Turnaround Time = Sum of Turnaround Times / Number of Processes
- Average Waiting Time = Sum of Waiting Times / Number of Processes
Gantt Chart
Process | Completion Time | Turnaround Time | Waiting Time |
---|---|---|---|
P1 | 6 | 6 - 0 = 6 | 6 - 3 = 3 |
P2 | 4 | 4 - 1 = 3 | 3 - 2 = 1 |
P3 | 5 | 5 - 2 = 3 | 3 - 1 = 2 |
P4 | 8 | 8- 3 = 5 | 5 - 2 = 3 |
P5 | 11 | 11 - 4 = 7 | 7 - 3 = 4 |
Average Turnaround Time = (6 + 3 + 3 + 5 + 7) / 5 = 4.8
Average Waiting Time = (3 + 1 + 2 + 3 + 4) / 5 = 2.6
Question 7: find the average Turn Around Time and Waiting Time of following processes using RR(Round Robin) process scheduling algorithm? Consider the following processes with their Arrival Time, Burst Time (take Quantum Time = 2)
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 2 |
P2 | 1 | 3 |
P3 | 2 | 2 |
P4 | 3 | 1 |
P5 | 4 | 2 |
Solution :
Formula:
- Turnaround Time = Completion Time - Arrival Time
- Waiting Time = Turnaround Time - Burst Time
- Average Turnaround Time = Sum of Turnaround Times / Number of Processes
- Average Waiting Time = Sum of Waiting Times / Number of Processes
Gantt Chart
Process | Completion Time | Turnaround Time | Waiting Time |
---|---|---|---|
P1 | 2 | 2 - 0 = 2 | 2 - 2 = 0 |
P2 | 10 | 10 - 1 = 9 | 9 - 3 = 6 |
P3 | 6 | 6 - 2 = 4 | 4 - 2 = 2 |
P4 | 7 | 7 - 3 = 4 | 4 - 1 = 3 |
P5 | 9 | 9 - 4 = 5 | 5 - 2 = 3 |
Average Turnaround Time = (2 + 9 + 4 + 4 + 5) / 5 = 4.8
Average Waiting Time (0 + 6 + 2 + 3 + 3) / 5 = 2.8
Question 8: find the average Turn Around Time and Waiting Time of following processes using RR(Round Robin) process scheduling algorithm? Consider the following processes with their Arrival Time, Burst Time (take Quantum Time = 3)
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0 | 6 |
P2 | 1 | 3 |
P3 | 2 | 7 |
P4 | 3 | 5 |
P5 | 4 | 4 |
Solution:
Given Time Quantum: 3
Formulas:
- Turnaround Time (TAT) = Completion Time - Arrival Time
- Waiting Time (WT) = Turnaround Time - Burst Time
Gantt Chart
Calculation:
Process | Arrival Time | Burst Time | Completion Time | Turnaround Time | Waiting Time |
---|---|---|---|---|---|
P1 | 0 | 6 | 15 | 15 - 0 = 15 | 15 - 6 = 9 |
P2 | 1 | 3 | 6 | 6 - 1 = 5 | 5 - 3 = 2 |
P3 | 2 | 7 | 25 | 25 - 2 = 23 | 23 - 7 = 16 |
P4 | 3 | 5 | 23 | 23 - 3 = 20 | 20 - 5 = 15 |
P5 | 4 | 4 | 24 | 14 - 4 = 20 | 20 - 4 = 16 |
Average Turnaround Time = (15 + 5 + 23 + 20 + 20) / 5 = 16.6
Average Waiting Time = (9 + 2 + 16 + 15 + 16) / 5 = 11.6