A1.3.3 · Operating systems and control systems
Scheduling
By the end you can
Compare first-come first-served, round robin, priority and multilevel queue scheduling, and work out waiting and turnaround times for each.
On a busy computer hundreds of processes are ready to run, but each core can run only one at a time. The is the part of the OS that decides who goes next and for how long. Different methods trade off different goals: getting through as much work as possible, keeping waiting times short, responding quickly to the user, and treating every process fairly.
Measuring a schedule#
- : how much CPU time a process needs.
- = finish time − arrival time: how long the whole job took, from the process's point of view.
- = turnaround time − burst time: time spent ready but not running.
- Response time: from arriving to first getting the CPU. It matters most for interactive programs.
- : how many processes are completed per unit of time.
- : the percentage of time the CPU is doing useful work rather than sitting idle or switching between processes.
A good schedule keeps CPU utilisation and throughput high and turnaround, waiting and response times low, while treating every process fairly. No method wins on all of these at once, which is why there are several.
Some methods let a process run until it finishes or blocks. Others are pre-emptive: the scheduler can take the CPU away mid-task (). Every switch from one process to another is a : the leaving process's registers are saved and the next one's restored. It is necessary, but time spent switching does no useful work.
Four approaches#
First-come, first-served (FCFS)
Processes run in the order they arrive, each until it finishes. It is the simplest method and fair in the sense of a queue at a shop. But it is not pre-emptive, so one long job holds up everything behind it: the convoy effect. Short jobs, which could have finished almost at once, wait a long time, so the average waiting time is high.
Round robin (RR)
Each process gets a fixed (say 10 ms). If it has not finished when the quantum ends, it is pre-empted and goes to the back of the queue. No process can hog the CPU, and every process gets a turn regularly, so the system feels responsive. Choosing the quantum is a balance: too short and the CPU spends a large share of its time on context switches; too long and round robin turns back into FCFS.
Priority scheduling
Every process has a priority (here, 1 is the most important) and the highest-priority ready process runs. In the pre-emptive version, a more important process that arrives takes the CPU at once; in the non-pre-emptive version it waits for the current one to finish. Urgent work is handled quickly, but a low-priority process can wait for ever if more important ones keep arriving: . The usual cure is , raising a process's priority the longer it waits.
A static priority is set when the process is created and never changes; a dynamic one is adjusted as it runs (ageing is one example; another is raising the priority of a process that has just been woken by user input). Priority also interacts badly with shared resources: if a low-priority process holds a lock that a high-priority one needs, the important process is stuck behind the unimportant one. That is , covered in A1.3.5.
Multilevel queue
Processes are sorted into separate queues by type, for example system processes, interactive programs and background jobs, and each queue has its own method (round robin for interactive work, FCFS for background jobs). A lower queue only gets the CPU when every higher queue is empty. This handles a mix of very different processes well, but it is more complicated, processes are stuck in the queue they were put in, and the bottom queue can starve.
Mixing them: the multilevel feedback queue
Real operating systems combine these ideas. In a multilevel feedback queue, processes can move between queues according to how they behave. A process that uses up its whole quantum (a long calculation) drops to a lower queue with a longer quantum; one that keeps giving up the CPU early to wait for input (an interactive program) stays high; and one that has waited a long time is moved up, which is ageing. The result is round robin's responsiveness for interactive work, few context switches for long jobs, and no starvation. Windows, macOS and Linux all use hybrids of this kind.
| Process | Arrives | Burst | Priority | Queue | Waiting | Turnaround | |
|---|---|---|---|---|---|---|---|
| P1 | 0 | 7 | |||||
| P2 | 6 | 9 | |||||
| P3 | 8 | 12 | |||||
| P4 | 11 | 13 |
Average waiting time
6.25
Average turnaround time
10.25
Context switches
3
Waiting = turnaround − burst. Turnaround = finish time − arrival time.
Worked example#
Four processes (the simulator's starting set). For round robin and the top queue of the multilevel queue, the quantum is 2. In the multilevel queue P2 and P4 are in the top queue and P1 and P3 in the lower one.
| Process | Arrives | Burst | Priority | Queue |
|---|---|---|---|---|
| P1 | 0 | 7 | 3 | lower |
| P2 | 1 | 3 | 1 | top |
| P3 | 2 | 4 | 2 | lower |
| P4 | 3 | 2 | 1 | top |
Under FCFS they simply run in order: P1 0–7, P2 7–10, P3 10–14, P4 14–16. P2 arrives at 1 but finishes at 10, so its turnaround is 9 and its waiting time 6. Under round robin the order is P1 0–2, P2 2–4, P3 4–6, P1 6–8, P4 8–10, P2 10–11, P3 11–13, P1 13–16. The results of all five methods:
| Method | Order | Avg waiting | Avg turnaround |
|---|---|---|---|
| First-come, first-served | P1 0–7, P2 7–10, P3 10–14, P4 14–16 | 6.25 | 10.25 |
| Round robin | P1 0–2, P2 2–4, P3 4–6, P1 6–8, P4 8–10, P2 10–11, P3 11–13, P1 13–16 | 7 | 11 |
| Priority (non-pre-emptive) | P1 0–7, P2 7–10, P4 10–12, P3 12–16 | 5.75 | 9.75 |
| Priority (pre-emptive) | P1 0–1, P2 1–4, P4 4–6, P3 6–10, P1 10–16 | 3.5 | 7.5 |
| Multilevel queue | P1 0–1, P2 1–3, P4 3–5, P2 5–6, P1 6–12, P3 12–16 | 4.25 | 8.25 |
Choosing a method#
| FCFS | Round robin | Priority | Multilevel queue | |
|---|---|---|---|---|
| Pre-emptive? | No | Yes, at the end of each quantum | Either version exists | Yes, between queues |
| Fairness | Fair in arrival order | Very fair: equal turns | Favours important work | Favours higher queues |
| Starvation? | No, but long waits behind long jobs | No | Possible, unless ageing | Possible in low queues |
| Overhead | Lowest: few switches | High if the quantum is short | Moderate | Highest: several queues to manage |
| Suits | Simple batch work of similar lengths | Interactive, time-sharing systems | Real-time or urgent tasks | Mixed workloads, such as a desktop OS |
Check yourself
Scheduling: methods and waiting times
Quick questions, made fresh every time and marked here. Do a few until they feel easy.
Exam practice
Paper 1-style questions
6 questions · 22 marks
Write your answer as you would in the exam, then show the mark points and tick each one your answer made. These are our own questions in the style of the exam, not past-paper questions.
1.The processes below are scheduled first-come, first-served. Calculate the waiting time of each process and the average waiting time.
[3]A: arrives 0, burst 8 B: arrives 1, burst 2 C: arrives 2, burst 4
Calculate: Work out the number, showing the working.
2.The same processes are scheduled by round robin with a time quantum of 3. Construct the order in which they run, and state B’s waiting time.
[3]A: arrives 0, burst 8 B: arrives 1, burst 2 C: arrives 2, burst 4
Construct: Draw or write it out (a table, a diagram, a program).
3.Explain how the length of the time quantum affects round robin scheduling.
[3]Explain: Give reasons: say what happens AND why, or how one thing causes another.
4.Explain how priority scheduling can lead to starvation, and how this can be prevented.
[3]Explain: Give reasons: say what happens AND why, or how one thing causes another.
5.Compare round robin and priority scheduling.
[4]Compare: Similarities and differences, about both things, point by point.
6.A desktop operating system must keep the user interface responsive while also running long background jobs such as backups. Evaluate the use of multilevel queue scheduling for this.
[6]Evaluate: Weigh the strengths against the weaknesses (or the benefits against the costs) and reach a judgement that you back up.
Past papers
Old exam questions on this topic
From HL Paper 1, May 2014 to November 2025. These papers were set on the previous syllabus, so the wording may differ from today's exam, but the topic is the same. Find the questions and markschemes in your school's past-paper pack.
| Paper | Question | Marks | About |
|---|---|---|---|
| November 2018 | 7 | 3 | Time slicing versus priorities |
In a nutshell
- The scheduler decides which ready process gets the CPU, aiming for good CPU use, high throughput, short waiting and turnaround times, quick responses and fairness.
- FCFS: in order of arrival, each to completion. Simple and fair in order, but short jobs get stuck behind long ones (the convoy effect). Not pre-emptive.
- Round robin: each process gets a fixed time quantum in turn, then goes to the back of the queue. Fair and responsive; too short a quantum wastes time on context switches.
- Priority: the most important process runs first (pre-emptive or not). Urgent work is quick, but low priorities can starve; ageing fixes this.
- Multilevel queue: separate queues for different kinds of process (system, interactive, background), each with its own method, served in priority order.
- Real systems use a multilevel feedback queue: processes move between queues by behaviour, which keeps interactive work responsive and prevents starvation.
- Turnaround = finish − arrival. Waiting = turnaround − burst. Average them over all processes to compare methods.
