← ⏱️ CPU Scheduling
Subtopic 1 of 5

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

  1. Sort processes by arrival; draw the timeline, leaving an idle gap when nobody has arrived.
  2. Record each completion time CT.
  3. Turnaround = CT − AT, Waiting = TAT − BT.
  4. 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.
P1
P2
P3
P4
08122126
ProcessArrivalBurstCompletionTurnaroundWaitingResponse
P1088800
P214121177
P32921191010
P43526231818
Average waiting time8.75
Average turnaround15.25
Average response8.75
Context switches3

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.

Turnaround = CT − AT12
Waiting = TAT − BT7
Response = first − AT4

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

Remember: TAT = CT − AT. WT = TAT − BT. RT = first run − AT. Do not forget idle time.
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.