University of Melbourne · FACULTY OF COMPUTER SCIENCE

COMP30023 · Computer Systems

- one subject, every graph, every model, every mark
Computer Science14 Chapters8-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 4 of 13 · COMP30023

CPU Scheduling

Week 3 covers how the scheduler picks which ready process runs — First-Come First-Served, Shortest-Job-First, Round-Robin with a quantum, priority and multi-level feedback queues — and how to compute waiting, turnaround and response times from a Gantt chart. Tracing execution order and computing average turnaround/response for several policies on a given burst/arrival table is a flagship Part C exam question.

In this chapter

What this chapter covers

  • 01Why scheduling is needed; context switch (thread vs process, including flushing the TLB) and its overhead
  • 02CPU-bound vs I/O-bound processes; preemptive (quantum + clock interrupt) vs non-preemptive scheduling
  • 03Metrics: turnaround = completion − arrival, response = first-run − arrival, and their averages; fairness and throughput
  • 04First-Come First-Served (FCFS): FIFO order, simplicity, and the convoy effect
  • 05Shortest-Job-First (SJF): optimal average turnaround when all jobs are ready together; risk of starving long jobs
  • 06Round-Robin (RR): one quantum per turn, good response time, no starvation, and the quantum trade-off
  • 07Priority scheduling and dynamic priority (e.g. priority = 1/fraction-of-quantum-used) to favour I/O-bound jobs
  • 08Multi-Level Feedback Queue (MLFQ): longer quanta at lower levels, no a-priori knowledge, priority boosting
Worked example · free

Round-Robin turnaround and response times

Q [4 marks]. Three processes all arrive at time 0 in queue order A, B, C with CPU bursts A = 6, B = 3, C = 4 (ms). Using Round-Robin with quantum = 3, build the Gantt chart and compute the average turnaround time and the average response time. (4 marks)
  • +1Build the Gantt chart, giving each ready process one quantum (3 ms) per turn and re-queuing it at the tail if work remains. A runs 0-3 (3 ms left), B runs 3-6 (done), C runs 6-9 (1 ms left), A runs 9-12 (done), C runs 12-13 (done). Strip: A[0-3] B[3-6] C[6-9] A[9-12] C[12-13].
  • +1Read completion times off the chart: B finishes at 6, A finishes at 12, C finishes at 13.
  • +1Turnaround = completion − arrival, and all arrive at 0: A = 12, B = 6, C = 13. Average turnaround = (12 + 6 + 13) ÷ 3 = 31 ÷ 3 ≈ 10.33 ms.
  • +1Response = first-run start − arrival: A first runs at 0, B first runs at 3, C first runs at 6. Average response = (0 + 3 + 6) ÷ 3 = 9 ÷ 3 = 3 ms. Round-Robin gives a low response time (every process runs within one cycle) but a poorer average turnaround, and it never starves any process.
Gantt: A[0-3] B[3-6] C[6-9] A[9-12] C[12-13]. Completion times A = 12, B = 6, C = 13, so average turnaround = 31 ÷ 3 ≈ 10.33 ms. First-run times A = 0, B = 3, C = 6, so average response = 9 ÷ 3 = 3 ms. RR trades better responsiveness for worse turnaround and guarantees no starvation.
Sia tip — Always draw the Gantt strip first and read completion and first-run times straight off it — do not compute in your head. Watch the quantum: too long and RR degenerates to FCFS; too short and context-switch overhead dominates. Ask Sia to set a fresh burst table with staggered arrivals and check that your queue re-insertion order is right.
Glossary

Key terms

Turnaround time
Completion time − arrival time for a process; the total time from submission to finish. Average turnaround is the mean over all processes and is the headline metric for batch scheduling.
Response time
Time of first run − arrival time; how long a process waits before it first gets the CPU. Interactive scheduling aims to minimise it, which is why Round-Robin is favoured there.
First-Come First-Served (FCFS)
Non-preemptive scheduling that runs ready processes in arrival order (FIFO). Simple with low overhead, but suffers the convoy effect: short jobs stuck behind a long CPU-bound job get large turnaround times.
Shortest-Job-First (SJF)
Run the ready process with the shortest next CPU burst. It gives the optimal average turnaround when all jobs are available together, but needs burst-length estimates and can starve long jobs.
Round-Robin (RR)
Preemptive scheduling that gives each ready process one time quantum in turn, re-queuing it if unfinished. Good response time and no starvation; the quantum trades responsiveness (short) against context-switch overhead (long).
Multi-Level Feedback Queue (MLFQ)
Several priority queues where lower-priority queues get longer quanta; processes start high and sink a level when they use up their quanta. It favours short/interactive jobs, needs no a-priori burst knowledge, and uses priority boosting to avoid starvation.
FAQ

CPU Scheduling FAQ

How do I compute average turnaround and response time?

Draw the Gantt chart for the policy first. Turnaround for each process is its completion time minus its arrival time; response time is when it first starts running minus its arrival time. Average each over all processes. The commonest slips are forgetting to subtract a non-zero arrival time, and reading completion times wrong from the chart — so always build the strip and read the numbers off it rather than doing arithmetic in your head.

Which scheduling policies can cause starvation?

Shortest-Job-First (and strict priority) can starve long/low-priority jobs, because a steady stream of shorter or higher-priority jobs keeps jumping ahead. FCFS and Round-Robin do not starve: FCFS runs everyone in arrival order, and RR gives every process a turn each cycle. This yes/no pattern (FCFS no, SJF yes, RR no) is a frequent MCQ.

Why is SJF optimal for average turnaround?

When all jobs are ready at time 0, running the shortest burst first means each short job's time is added into fewer of the running completion totals, so the total (and hence average) waiting is minimised. Intuitively, making a long job wait behind several short ones costs less total waiting than making the short ones wait behind the long one. The catch is that it needs to know or estimate burst lengths and can starve long jobs.

How should I choose the Round-Robin quantum?

Long enough to amortise the context-switch cost but short enough to stay responsive. If the quantum is much larger than typical bursts, RR degrades into FCFS (poor response); if it is tiny, context-switch overhead dominates and throughput drops. A common design picks a quantum so that most interactive bursts complete within one or two quanta.

Can AI help me with CPU scheduling problems in COMP30023?

Yes. Sia can generate practice burst/arrival tables, check your Gantt charts for FCFS/SJF/RR, and explain the turnaround-vs-response trade-offs and starvation behaviour step by step. It is a study aid to help you master the method and rehearse for the exam; it does not do your graded MST, exam, quizzes or projects, and University of Melbourne academic-integrity rules apply.

Study strategy

Exam move

Scheduling is one of the most reliably examined quantitative topics — a Part C Gantt question is very likely — and it also sits in the mid-semester test, so drill it until the mechanics are automatic. Practise building Gantt charts for FCFS, SJF and Round-Robin from the same burst/arrival table, then reading completion, turnaround and response times off the chart; do a set with staggered arrivals so you handle 'only ready jobs compete' correctly for SJF and RR. Memorise the qualitative summary (FCFS: convoy effect; SJF: optimal average turnaround but starvation; RR: good response, no starvation; MLFQ: no a-priori knowledge, longer quanta lower down) and the starvation yes/no table. There is no calculator in the exam, so keep the arithmetic to clean small sums. Confirm the MST and exam dates on Canvas; mastering this topic protects your WAM because it recurs in tutorials and the projects' concurrency reasoning.

Working through CPU Scheduling in COMP30023? Sia is AskSia’s AI Computer Science tutor — ask any COMP30023 CPU Scheduling question and get a clear, step-by-step explanation grounded in how COMP30023 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 14 of your University of Melbourne subjects - and 1,000+ Bibles across every Australian university.
Sia - your COMP30023 tutor, unlimited, worked the way the exam marks it
The full 8-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$25/ month
30-day money-back · cancel in one tap · how it works
Unlock the full COMP30023 Bible + 14 University of Melbourne subjects解锁完整 COMP30023 Bible + University of Melbourne 14 门科目
$25/mo