Home › Theme A › A1 › A1.3 › A1.3.3

A1.3.3 CPU scheduling: comparing the methods

SL + HLCommand term: Compare

1. Set up the processes

Each process arrives at a certain time and needs the CPU for a burst time. A lower priority number means more important. Edit the table, or load a preset.

2. Choose an algorithm and run it

🧠 CPU running
–
time = 0
📊 Gantt chart

3. Compare all four

Run every algorithm on the same processes and compare the averages. Lower is better.

Learning objectives

By the end of this page you should be able to:

  1. Explain why the operating system schedules processes and allocates CPU time.
  2. Define performance measures such as waiting time, turnaround time and response time.
  3. Describe first-come first-served, round robin, multilevel queue and priority scheduling.
  4. Calculate waiting and turnaround times for a set of processes under different scheduling approaches.
  5. Compare the scheduling approaches, including their fairness and the risk of starvation.

Why schedule?

A single CPU core can run only one process at a time, but many processes are ready to run. The OS scheduler decides which one runs next and for how long. Good scheduling keeps the CPU busy, keeps the system responsive, is fair, and finishes work quickly (high throughput).

  • Non-preemptive: once a process starts, it runs until it finishes (or waits for I/O).
  • Preemptive: the OS can interrupt a running process and give the CPU to another one. Switching between processes is a context switch: the OS saves one process's registers and loads another's, which takes a little time.

Measuring performance

  • Turnaround time = completion time − arrival time
  • Waiting time = turnaround time − burst time (time spent in the ready queue)
  • Response time = first time on the CPU − arrival time (important for interactive programs)

The four approaches

AlgorithmHow it worksAdvantagesDisadvantagesGood for
First-come first-served (FCFS)Processes run in order of arrival, each to completion (non-preemptive). A simple FIFO queue.Simple; fair in arrival order; no starvation; few context switchesLong jobs make everyone wait (convoy effect); poor response timeBatch jobs, print queues
Round robin (RR)Each process gets a fixed time quantum. If it isn't finished, it goes to the back of the queue (preemptive).Fair; good response time; no starvationMany context switches; average waiting can be high; performance depends on quantum sizeTime-sharing and interactive systems
PriorityThe ready process with the highest priority runs first (preemptive or non-preemptive).Important tasks run first; flexibleLow-priority processes may wait for ever (starvation); fixed by aging (raising priority the longer a process waits)Real-time and system tasks
Multilevel queueProcesses are split into separate queues (e.g. system / interactive / batch), each with its own algorithm. Higher queues run first.Different process types get suitable treatment; system tasks stay responsiveMore complex; lower queues can starve; a process can't move between queues (unless it is a feedback queue)General-purpose operating systems
Exam tip: when asked to "compare", give a similarity and differences on the same criteria (fairness, response time, starvation, overhead), and draw a Gantt chart with times underneath to support your answer.

Use the 中文 button at the top to show or hide the Chinese terms.

Term中文Meaning

Choose an answer. You get instant feedback.

Score: 0 /

Write your answer first, then reveal the markscheme. These are exam-style practice questions written for this site. Use the simulator to check your Gantt charts.

1. Outline the purpose of process scheduling. [2]

To decide which process uses the CPU and for how long [1]; so that CPU time is shared fairly / efficiently and the system stays responsive / performance is optimised [1].

2. Processes P1 (arrival 0, burst 5), P2 (arrival 1, burst 3) and P3 (arrival 2, burst 1) are scheduled with first-come first-served. Draw the Gantt chart and calculate the average waiting time. [3]

Gantt: P1 0–5, P2 5–8, P3 8–9 [1]; waiting: P1 = 0, P2 = 5 − 1 = 4, P3 = 8 − 2 = 6 [1]; average = 10 ÷ 3 ≈ 3.33 [1].

3. Repeat question 2 using round robin with a time quantum of 2. [3]

Gantt: P1 0–2, P2 2–4, P3 4–5, P1 5–7, P2 7–8, P1 8–9 [1]; waiting: P1 = 9 − 0 − 5 = 4, P2 = 8 − 1 − 3 = 4, P3 = 5 − 2 − 1 = 2 [1]; average = 10 ÷ 3 ≈ 3.33 [1]. (Check with the simulator.)

4. Explain what is meant by starvation in priority scheduling and how it can be prevented. [3]

Starvation: a low-priority process waits indefinitely [1]; because higher-priority processes keep arriving and are always chosen first [1]; prevented by aging: gradually increasing the priority of processes that have waited a long time [1].

5. Compare round robin and first-come first-served scheduling for an interactive system such as a school laptop. [4]

Award [1] for each, up to [4]: both are fair and neither causes starvation; FCFS is non-preemptive, RR is preemptive; with FCFS a long task can block short interactive tasks (convoy effect), whereas RR gives every process a regular time slice so all programs respond; RR has more context-switching overhead; RR's performance depends on the quantum size; conclusion: RR is more suitable for an interactive system.