BIT204 ยท 2078 ยท 5 marks
CPU Scheduling Analysis Consider the following set of processes, with the length of CPU burst time given in milliseconds. The processes are assumed to have arrived in the order A, B, C and D all at time 0. What is the turnaround time and waiting time for the scheduling algorithms, RR (quantum = 3) a
CPU Scheduling Analysis
Consider the following set of processes, with the length of CPU burst time given in milliseconds. The processes are assumed to have arrived in the order A, B, C and D all at time 0. What is the turnaround time and waiting time for the scheduling algorithms, RR (quantum = 3) and Priority Algorithm.
| Process | CPU Burst | Priority |
|---|---|---|
| A | 8 | 3 |
| B | 9 | 1 (Lowest) |
| C | 10 | 2 |
| D | 6 | 4 (Highest) |
[5]
CPU Scheduling: RR (q=3) and Priority
Given
| Process | CPU Burst | Priority |
|---|---|---|
| A | 8 | 3 |
| B | 9 | 1 (Lowest) |
| C | 10 | 2 |
| D | 6 | 4 (Highest) |
All arrive at time 0, in order A, B, C, D.
Formulas: $TAT = CT - AT$, $WT = TAT - Burst$.
Solution
1. Round Robin (Quantum = 3)
Ready queue starts: A, B, C, D. A process that still has remaining burst rejoins the tail of the queue after its slice.
Tracing execution (remaining bursts A=8, B=9, C=10, D=6):
| Slot | Proc | Range | Remaining after |
|---|---|---|---|
| 1 | A | 0-3 | A=5 |
| 2 | B | 3-6 | B=6 |
| 3 | C | 6-9 | C=7 |
| 4 | D | 9-12 | D=3 |
| 5 | A | 12-15 | A=2 |
| 6 | B | 15-18 | B=3 |
| 7 | C | 18-21 | C=4 |
| 8 | D | 21-24 | D=0 โ |
| 9 | A | 24-26 | A=0 โ |
| 10 | B | 26-29 | B=0 โ |
| 11 | C | 29-32 | C=1 |
| 12 | C | 32-33 | C=0 โ |
Gantt:
| A | B | C | D | A | B | C | D | A | B | C | C |
0 3 6 9 12 15 18 21 24 26 29 32 33
| Process | Burst | CT | TAT | WT |
|---|---|---|---|---|
| A | 8 | 26 | 26 | 18 |
| B | 9 | 29 | 29 | 20 |
| C | 10 | 33 | 33 | 23 |
| D | 6 | 24 | 24 | 18 |
$$\text{Avg TAT} = \frac{26+29+33+24}{4} = \frac{112}{4} = 28 \text{ ms}$$ $$\text{Avg WT} = \frac{18+20+23+18}{4} = \frac{79}{4} = 19.75 \text{ ms}$$
2. Priority Scheduling (Non-Preemptive)
Higher number = higher priority. Execution order: D (4) โ A (3) โ C (2) โ B (1)
Gantt:
| D | A | C | B |
0 6 14 24 33
| Process | Burst | CT | TAT | WT |
|---|---|---|---|---|
| D | 6 | 6 | 6 | 0 |
| A | 8 | 14 | 14 | 6 |
| C | 10 | 24 | 24 | 14 |
| B | 9 | 33 | 33 | 24 |
$$\text{Avg TAT} = \frac{6+14+24+33}{4} = \frac{77}{4} = 19.25 \text{ ms}$$ $$\text{Avg WT} = \frac{0+6+14+24}{4} = \frac{44}{4} = 11 \text{ ms}$$
Summary
| Algorithm | Avg TAT | Avg WT |
|---|---|---|
| RR (q=3) | 28 ms | 19.75 ms |
| Priority | 19.25 ms | 11 ms |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.