BIT204 ยท 0 ยท 5 marks
CPU Scheduling Analysis Consider the following set of processes, with the length of CPU burst time given in milliseconds. | Processes | CPU Burst | Priority | |-----------|-----------|----------| | A | 8 | 3 | | B | 13 | 1 (Lowest) | | C | 19 | 2 | | D | 3 | 4 (Highest) | The processes are assumed t
CPU Scheduling Analysis
Consider the following set of processes, with the length of CPU burst time given in milliseconds.
| Processes | CPU Burst | Priority |
|---|---|---|
| A | 8 | 3 |
| B | 13 | 1 (Lowest) |
| C | 19 | 2 |
| D | 3 | 4 (Highest) |
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 = 5) and Priority Algorithm?
[5]
CPU Scheduling: RR (quantum = 5) and Priority
Given
| Process | CPU Burst (ms) | Priority |
|---|---|---|
| A | 8 | 3 |
| B | 13 | 1 (Lowest) |
| C | 19 | 2 |
| D | 3 | 4 (Highest) |
Arrival: all at time 0, order A, B, C, D. Total burst = $8+13+19+3 = 43$ ms.
Solution
Part 1: Round Robin (q = 5)
Ready queue starts A, B, C, D. Track remaining bursts.
| Slot | Proc | Start | End | Remaining after |
|---|---|---|---|---|
| 1 | A | 0 | 5 | 3 |
| 2 | B | 5 | 10 | 8 |
| 3 | C | 10 | 15 | 14 |
| 4 | D | 15 | 18 | 0 (needs 3) |
| 5 | A | 18 | 21 | 0 (needs 3) |
| 6 | B | 21 | 26 | 3 |
| 7 | C | 26 | 31 | 9 |
| 8 | B | 31 | 34 | 0 (needs 3) |
| 9 | C | 34 | 39 | 4 |
| 10 | C | 39 | 43 | 0 |
Gantt:
| A | B | C | D | A | B | C | B | C | C |
0 5 10 15 18 21 26 31 34 39 43
Completion times: A = 21, B = 34, C = 43, D = 18
Turnaround (TAT = Completion โ 0):
| Proc | TAT | WT = TAT โ Burst |
|---|---|---|
| A | 21 | 21 โ 8 = 13 |
| B | 34 | 34 โ 13 = 21 |
| C | 43 | 43 โ 19 = 24 |
| D | 18 | 18 โ 3 = 15 |
$$\text{Avg TAT} = \frac{21+34+43+18}{4} = \frac{116}{4} = 29 \text{ ms}$$
$$\text{Avg WT} = \frac{13+21+24+15}{4} = \frac{73}{4} = 18.25 \text{ ms}$$
Part 2: Priority Scheduling (Non-preemptive)
Highest priority number runs first: D(4) โ A(3) โ C(2) โ B(1)
Gantt:
| D | A | C | B |
0 3 11 30 43
| Proc | Completion | TAT | WT = TAT โ Burst |
|---|---|---|---|
| D | 3 | 3 | 0 |
| A | 11 | 11 | 3 |
| C | 30 | 30 | 11 |
| B | 43 | 43 | 30 |
$$\text{Avg TAT} = \frac{3+11+30+43}{4} = \frac{87}{4} = 21.75 \text{ ms}$$
$$\text{Avg WT} = \frac{0+3+11+30}{4} = \frac{44}{4} = 11 \text{ ms}$$
Summary
| Algorithm | Avg TAT | Avg WT |
|---|---|---|
| RR (q = 5) | 29 ms | 18.25 ms |
| Priority | 21.75 ms | 11 ms |
All values confirmed correct.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.