2.1Scheduling metrics and the Gantt chart
The idea
A scheduling question is arithmetic on a Gantt chart: draw who runs when, then read completion times and derive turnaround, waiting and response.
Think of it like this: A queue at a counter with a stopwatch for each person: how long from joining to leaving (turnaround), how long standing idle (waiting), how long before the first word with the clerk (response).
Why it exists
The CPU is shared, and choosing who goes next determines how long everyone else waits. The three metrics tell you what each policy optimises.
How it works
- Sort processes by arrival; draw the timeline, leaving an idle gap when nobody has arrived.
- Record each completion time CT.
- Turnaround = CT − AT, Waiting = TAT − BT.
- Response = first CPU time − AT. Average over processes.
Worked example: AT = 2, BT = 5, runs first at 6, completes at 14
TAT = 14 − 2 = 12. WT = 12 − 5 = 7. RT = 6 − 2 = 4.
Now play with it
- →Change the arrival times in the table so everything arrives at 0 and watch the idle gap vanish.
- →Use the small calculator with your own numbers.
| Process | Arrival | Burst | Completion | Turnaround | Waiting | Response |
|---|---|---|---|---|---|---|
| P1 | 0 | 8 | 8 | 8 | 0 | 0 |
| P2 | 1 | 4 | 12 | 11 | 7 | 7 |
| P3 | 2 | 9 | 21 | 19 | 10 | 10 |
| P4 | 3 | 5 | 26 | 23 | 18 | 18 |
Turnaround = completion − arrival. Waiting = turnaround − burst. Response = first run − arrival. Ties go to the earlier arrival, then the earlier row. In round robin, a process that arrives while another runs joins the queue before the preempted one.
Memorise the three differences: they are the whole of the arithmetic in most scheduling questions.
Check yourself
A process arrives at 1 with burst 4 and completes at 12. Its waiting time is
Exam notes (the dense version)
Arrival time (AT), burst time (BT), completion time (CT). Turnaround = CT − AT. Waiting = Turnaround − BT. Response = first CPU time − AT. Draw a Gantt chart left to right and note the idle gaps when no process has arrived. The scheduler picks from the ready queue; the dispatcher does the switch. Preemptive policies can take the CPU away; non-preemptive ones wait for the burst to end or block.
Previous year questions: CPU Scheduling (13)
PYQs are grouped by topic, so this is the full set for CPU Scheduling; try the ones that match this subtopic. Open all 13 on the topic page.