IB Computer Science2027 syllabus
Level view
A1.3.3

Approaches for scheduling

SL & HL35 min readLesson

In one sentence: Process scheduling allocates CPU time across competing tasks in the ready queue, balancing simplicity, fairness, responsiveness, and priority using strategies such as first-come first-served, round robin, priority scheduling, and multilevel queue scheduling.

What you will learn

By the end of this lesson, you should be able to:

  • Explain why an operating system schedules CPU execution time across ready processes to optimize performance and prevent resource monopolization.
  • Distinguish non-pre-emptive from pre-emptive scheduling and account for context-switching overhead.
  • Trace, compare, and evaluate first-come first-served (FCFS), round robin (RR), priority scheduling, and multilevel queue scheduling.
  • Explain how OS task scheduling supports responsive network packet and request handling and network security monitoring.

Before you begin

Review The role of operating systems (A1.3.1) and Functions of an operating system (A1.3.2), especially how the OS runs multiple user applications and background services concurrently on limited CPU cores.

Key words

TermSimple meaning
Ready queueThe waiting list of processes loaded in RAM that are ready to run as soon as a CPU core becomes available.
MonopolizeAllowing one process or user to dominate a shared resource (such as CPU time), delaying or starving others.
Pre-emptive vs. non-pre-emptivePre-emptive scheduling can interrupt a running process mid-execution; non-pre-emptive scheduling waits until the running process finishes or enters an I/O wait.
Context switchingSaving the CPU state (registers, program counter) of the outgoing process and loading the state of the next process so multitasking can switch cleanly.
Time quantumA fixed short time slice assigned to each process before preemption in round robin scheduling.
Convoy effectA slowdown in FCFS where several short processes wait behind one long CPU-heavy process.
StarvationA condition in which low-priority processes wait indefinitely because higher-priority tasks keep taking the CPU.
AgeingGradually increasing the priority of waiting processes over time so they are guaranteed CPU time and avoid starvation.
Waiting time and turnaround timeWaiting time is the total time a process spends waiting in the ready queue; turnaround time is total completion duration (waiting time + burst time).

The idea, step by step

Why CPU scheduling is essential

Even on a multi-core CPU, far more software tasks (interactive applications, background daemons, network handlers, and file transfers) are ready to execute than there are available CPU cores. The operating system's scheduler decides which process in the ready queue gets a CPU core next and for how long. Good scheduling prevents a single heavy program from monopolizing the processor, reduces waiting delays, keeps interactive interfaces responsive, and maximizes overall CPU throughput.

Whenever a pre-emptive scheduler switches the CPU from one task to another, it performs a context switch: storing the outgoing task's register values and loading the incoming task's saved state. Although context switching enables responsive multitasking, switching too often wastes measurable CPU time purely on saving and restoring state instead of finishing actual user work.

1. First-come first-served (FCFS)

First-come first-served (FCFS) executes processes strictly in the order they arrive at the back of the ready queue. The scheduler selects the process at the front, lets it run until it finishes (or pauses for an I/O operation), and then dispatches the next process.

  • Pre-emption: Non-pre-emptive. Once a process starts executing on the CPU, no later arrival interrupts it before completion or I/O wait.
  • Advantages: Simple to implement with minimal scheduling overhead; processes requests fairly by arrival order without starvation.
  • Disadvantages: Vulnerable to the convoy effect: if a long-running calculation arrives just ahead of ten short tasks, every short task stalls behind it, inflating average waiting time and hurting interactive responsiveness.

2. Round robin (RR)

Round robin (RR) is a pre-emptive scheduling algorithm designed for fair time-sharing across interactive systems. Every ready process receives an equal, fixed CPU turn called a time quantum (for example, 2 ms or 10 ms). If the process finishes early, the scheduler moves directly to the next task; if it is still running when the quantum expires, the scheduler pre-empts it, pushes it to the back of the ready queue, and runs the next process in line.

  • Pre-emption: Pre-emptive (driven by a hardware timer expiring at the end of each quantum).
  • Advantages: Fair CPU sharing, high interactive responsiveness, and no single task can monopolize the CPU.
  • Disadvantages: Selecting an appropriate time quantum requires a balance:
    • Quantum too short: Frequent context switches waste CPU cycles purely on bookkeeping overhead.
    • Quantum too long: Processes finish before being pre-empted, turning RR back into sluggish FCFS.

3. Priority scheduling

Priority scheduling assigns every process a numerical or named priority level (High, Medium, Low). Whenever the scheduler selects the next task, it picks the ready process with the highest priority (breaking ties by arrival order using FCFS). Priorities may be static (fixed when created) or dynamic (adjusted over time).

  • Advantages: Ensures urgent or time-critical work, such as audio processing, emergency interrupts, or security checks, runs promptly ahead of routine background tasks.
  • Disadvantages:
    • Starvation: If high-priority tasks arrive continuously, low-priority tasks can wait indefinitely. Operating systems counter starvation using ageing, which gradually raises a waiting process's priority the longer it sits idle in the queue.
    • Priority inversion: A bug where a high-priority task must wait because a low-priority task currently holds a locked resource that it needs.
    • Higher complexity: Requires more tracking and management than FCFS or plain RR.

4. Multilevel queue scheduling

Multilevel queue scheduling splits the single ready queue into multiple distinct queues, each dedicated to a category of process (such as Interactive/Foreground, Batch, and Background/Maintenance) with its own priority level and its own internal scheduling algorithm:

Priority levelQueueInternal scheduling algorithm
Highest priorityQ1: Interactive queueRound robin (for example, q = 2 ms)
Medium priorityQ2: Batch queueFirst-come first-served (FCFS)
Lowest priorityQ3: Background queueFirst-come first-served (FCFS)

The scheduler drains the highest-priority non-empty queue first (Q1), moving down to Q2 or Q3 only when higher queues are empty, and immediately switching back up if a new interactive job arrives in Q1. In strict multilevel queue scheduling, processes are permanently assigned to one queue based on fixed traits (process type, priority, or memory need).

  • Advantages: Lets the OS tailor each workload type cleanly (fast RR responsiveness for interactive windows alongside low-overhead FCFS for batch jobs) while still protecting urgent system work.
  • Disadvantages: Complex to tune and maintain, lower-priority queues risk starvation if upper queues stay busy, and fixed queue assignment becomes inflexible if a task's behaviour changes over time.

Side-by-side comparison

ApproachPre-emptive?Core ruleBest forKey risk / trade-off
FCFSNoRuns strictly in arrival orderSimple batch queues with uniform burstsConvoy effect; poor interactive latency
Round robinYesFixed cyclic time quantum per processMulti-user / time-sharing interactive systemsOverhead if quantum is too short; FCFS-like lag if too long
PriorityEitherHighest priority runs first (ties broken by FCFS)Systems with clear urgency/criticality tiersStarvation (needs ageing); priority inversion
Multilevel queueAcross/within queuesSeparate category queues, each with its own algorithmMixed workloads (interactive + batch + background)Complex setup; lower-queue starvation; rigid assignment

Connecting OS scheduling to network traffic and security

Process scheduling does not operate in isolation from computer networks:

  • Managing network traffic and packet requests (A2.3.3): Network servers receive bursts of incoming packets and client requests across socket threads. Using Round Robin or multilevel queues keeps active packet-handling and interactive request threads moving smoothly instead of letting one slow file-transfer thread create a convoy delay for every connected client.
  • Maintaining network security (A2.4): Firewalls, intrusion detection monitors, and encryption services run as OS processes alongside user applications. Priority or multilevel scheduling ensures security inspection tasks receive prompt CPU time so malicious packets or port scans are detected immediately rather than queuing behind bulk background work.

Worked example

Suppose three processes P1, P2, and P3 enter the ready queue in that arrival order at t = 0 ms:

ProcessArrival order (at t = 0 ms)CPU burst timePriority
P11st6 msLow
P22nd2 msHigh
P33rd4 msMedium

Compare how three schedulers execute the exact same workload:

  1. FCFS (non-pre-emptive): Executes P1 (0–6 ms), then P2 (6–8 ms), then P3 (8–12 ms).
    • Waiting times: P1 = 0 ms, P2 = 6 ms, P3 = 8 ms.
    • Average waiting time = (0 + 6 + 8) / 3 ≈ 4.67 ms.
    • Even though P2 only needs 2 ms and is High priority, it stalls for 6 ms behind P1 (convoy effect).
  2. Round robin (quantum = 2 ms): Cycles 2 ms slices in order P1, P2, P3:
    • 0–2 ms: P1 (4 ms left)
    • 2–4 ms: P2 (finishes at 4 ms, total wait = 2 ms)
    • 4–6 ms: P3 (2 ms left)
    • 6–8 ms: P1 (2 ms left)
    • 8–10 ms: P3 (finishes at 10 ms, wait = 10 - 4 = 6 ms)
    • 10–12 ms: P1 (finishes at 12 ms, wait = 12 - 6 = 6 ms)
    • Average waiting time = (6 + 2 + 6) / 3 ≈ 4.67 ms, yet every process begins executing within 4 ms and short interactive P2 finishes twice as fast as under FCFS.
  3. Priority scheduling (High > Medium > Low): Executes P2 (0–2 ms), then P3 (2–6 ms), then P1 (6–12 ms).
    • Waiting times: P2 = 0 ms, P3 = 2 ms, P1 = 6 ms.
    • Average waiting time = (0 + 2 + 6) / 3 ≈ 2.67 ms, prioritizing urgent P2 immediately, although if more High or Medium jobs kept arriving, P1 would need ageing to avoid starvation.

Check your understanding

  1. What is the convoy effect, and why does it occur in non-pre-emptive FCFS scheduling?
  2. Why does choosing an overly short time quantum harm performance in Round Robin scheduling?
  3. How does ageing solve starvation in priority scheduling?
  4. Distinguish priority scheduling from multilevel queue scheduling in terms of how ready queues and algorithms are structured.

Common mix-up

It is easy to think: Making the Round Robin time quantum as tiny as possible always improves overall speed, or priority scheduling and multilevel queue scheduling are identical.

Instead, remember: A tiny quantum creates excessive context switching, so the CPU spends significant time saving and loading process states instead of executing useful code. Furthermore, while plain priority scheduling orders processes inside one ranking system, multilevel queue scheduling partitions processes into separate category queues that each run their own distinct scheduling algorithm (for example, RR in the foreground queue and FCFS in the background queue).

Quick recap

  • CPU scheduling governs ready-queue order and execution duration to keep hardware utilized and applications responsive.
  • FCFS uses non-pre-emptive arrival order; it is simple, but suffers from the convoy effect.
  • Round robin uses pre-emptive fixed time quantum cycling; it is fair and interactive, trading off context-switch overhead against quantum length.
  • Priority scheduling runs highest-priority tasks first; it requires ageing to prevent starvation and careful locking to avoid priority inversion.
  • Multilevel queue scheduling organizes processes permanently into priority-ranked queues, each using an algorithm tailored to its workload class.
  • Scheduling choices directly affect how quickly servers process network packet threads and security monitors.

Textbook reading

  • Computer Science (Baumgarten, Ganea, Turland, 2025), A1 Computer fundamentals > A1.3 Operating systems and control systems > A1.3.3 Approaches for scheduling, Book pp. 79–84 (PDF pp. 89–94).
  • Read these pages to inspect the timeline diagrams and Python FCFS waiting and turnaround simulation; this original explanation does not replace the textbook.

Sources and further learning

  • IB Computer Science Guide (first assessment 2027), A1.3.3: Compare different approaches to scheduling (Guide p. 30; PDF p. 36), and Theme A linking question (A1 to A2.3.3, A2.4): OS task scheduling in managing network traffic and requests.
  • Computer Science (Baumgarten, Ganea, Turland, 2025), A1.3.3 Approaches for scheduling, Book pp. 79–84 (PDF pp. 89–94). All tables and worked calculations above are original.
Check your understanding5 questions · 9 marks · 12 min
Take the lesson check
Something not right?