Round Robin Scheduling
Each process is provided a fix time to execute called quantum.
Once a process is executed for given time period. Process is preempted and other process executes for given time period.
Context switching is used to save states of preempted processes.
Example:
Process | Arrival Time | Execute Time |
---|---|---|
P0 | 0 | 5 | P1 | 1 | 3 | P2 | 2 | 8 | P3 | 3 | 6 |
P0 |
P1 |
P2 |
P3 |
P0 |
P2 |
P3 |
P2 |
0 | 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 |
Wait time of each process is following
Process | Wait Time : Service Time - Arrival Time |
---|---|
P0 | (0-0) + (12-3) = 9 |
P1 | (3-1) = 2 |
P2 | 6-2) + (15-9) = 10 |
P3 | (9-3) + (18-12) = 12 |
Average Wait Time: (9+2+10+12) / 4 = 8.25