Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Round Robin Scheduling with different arrival times
Round Robin (RR) is a preemptive CPU scheduling algorithm where each process is allocated a fixed time slice called a quantum. Unlike standard Round Robin with zero arrival times, this variant handles processes that arrive at different times, making scheduling more complex as the ready queue changes dynamically.
In preemptive scheduling, a running process can be interrupted and moved back to the ready queue. Round Robin ensures fairness by giving each process an equal share of CPU time, preventing starvation while maintaining good response times for interactive systems.
How Round Robin Works with Different Arrival Times
When processes have different arrival times, the algorithm follows these steps:
Processes enter the ready queue based on their arrival time
The CPU serves the first available process for the quantum duration
If the process completes within the quantum, it terminates
If not completed, it moves to the end of the ready queue
New arrivals join the ready queue and wait for their turn
Context switching saves the state of preempted processes
Key Features
Prevents starvation Every process gets CPU time eventually
Fair scheduling Equal time quantum for all processes
Good response time Suitable for interactive and real-time systems
Context switching overhead Smaller quantum increases switching cost
Example 1 Quantum Time = 2
Consider three processes with different arrival and burst times:
| Process | Arrival Time | Burst Time |
|---|---|---|
| P1 | 0 | 4 |
| P2 | 1 | 3 |
| P3 | 2 | 7 |
Step-by-Step Execution
| Time | Process | Ready Queue | Action |
|---|---|---|---|
| 0-2 | P1 | P1 | P1 runs for 2 units, P2 arrives at t=1 |
| 2-4 | P2 | P2, P1 | P2 runs for 2 units, P3 arrives at t=2 |
| 4-6 | P3 | P3, P1 | P3 runs for 2 units |
| 6-8 | P1 | P1, P2, P3 | P1 completes remaining 2 units |
| 8-9 | P2 | P2, P3 | P2 completes remaining 1 unit |
| 9-14 | P3 | P3 | P3 completes remaining 5 units |
Calculating Average Times
| Process | Arrival | Burst | Completion | Turnaround | Waiting |
|---|---|---|---|---|---|
| P1 | 0 | 4 | 8 | 8 | 4 |
| P2 | 1 | 3 | 9 | 8 | 5 |
| P3 | 2 | 7 | 14 | 12 | 5 |
Average Turnaround Time = (8 + 8 + 12) / 3 = 9.33 units
Average Waiting Time = (4 + 5 + 5) / 3 = 4.67 units
Example 2 Quantum Time = 4
With a larger quantum size:
| Process | Arrival Time | Burst Time |
|---|---|---|
| P1 | 2 | 8 |
| P2 | 0 | 7 |
| P3 | 1 | 9 |
| Process | Arrival | Burst | Completion | Turnaround | Waiting |
|---|---|---|---|---|---|
| P1 | 2 | 8 | 24 | 22 | 14 |
| P2 | 0 | 7 | 15 | 15 | 8 |
| P3 | 1 | 9 | 20 | 19 | 10 |
Average Turnaround Time = (22 + 15 + 19) / 3 = 18.67 units
Average Waiting Time = (14 + 8 + 10) / 3 = 10.67 units
Conclusion
Round Robin scheduling with different arrival times provides fair CPU allocation while handling dynamic process arrivals. The quantum size significantly affects performance ? smaller quantums improve response time but increase context switching overhead, while larger quantums may reduce fairness but improve throughput.
