Scheduling begins with state

One CPU, one burst per task, FIFO ready queue.

Track time, remaining work, next arrival, and completed tasks.

Prediction: does a new arrival interrupt the current slice?

No. It waits until the running task finishes or exhausts its quantum.

1 / 7

The boundary decides the queue

Quantum 2; A starts with burst 4. B arrives exactly at time 2.

  1. A runs 0–2, leaving 2 units.
  2. Enqueue B, then requeue A: [B,A].
  3. Charge a context switch because a competitor is ready.

Requeueing A first changes the policy.

2 / 7

Trace the handoff

A: arrival 0, burst 5. B: arrival 1, burst 2. C: arrival 3, burst 1.

Quantum 2; context 1.

A 0–2 → switch 2–3 → B 3–5 → switch 5–6 → A 6–8

At time 3, the queue is [B,A,C]. C joins behind already queued work.

3 / 7

Finish the accounting

switch 8–9 → C 9–10 → switch 10–11 → A 11–12

Completion: A=12, B=5, C=10.

Useful work 8 + switching 4 + idle 0 = elapsed 12.

Why is B's completion 5, not 6? B is already finished before the handoff.

4 / 7

Three different metrics

For C: arrival 3, first run 9, completion 10, burst 1.

  • Turnaround: 10−3 = 7.
  • Response: 9−3 = 6.
  • Waiting: 7−1 = 6 in this single-burst model.

Response describes first service; turnaround describes the whole lifetime.

5 / 7

Where no switch is charged

  • An unfinished task is the only ready task.
  • A task finishes and the CPU becomes idle.
  • The final task finishes.

Task arrival 4, burst 5, quantum 2, context 3: completion is 9.

6 / 7

Reconstruct before implementing

At a slice end: advance time → append arrivals → complete or requeue → charge handoff if another task was ready → append switch-time arrivals.

Check conservation: useful work + overhead + idle = elapsed time.

Smaller quantum means more frequent turns and potentially more overhead, not a guaranteed turnaround improvement.

7 / 7
←/→ or click edges to navigate · ? help · N notes · F fullscreen