A process is a program that is currently running on a computer. Most computers run dozens of processes simultaneously, but a CPU with one core can only execute one instruction at a time. The operating system's process scheduler decides which process gets CPU time and for how long — giving the illusion of true simultaneous execution.

What is a process and how is it different from a program?

A program is the static set of instructions stored on disc — the code file. A process is what a program becomes when it is loaded into memory and executed. The same program can spawn multiple processes (for example, opening a web browser twice creates two separate browser processes).

Each process has:

  • Its own section of RAM for its data and code
  • A program counter (the CPU register that remembers which instruction is next)
  • A process state — typically Running, Ready (waiting for CPU time), or Waiting (waiting for I/O or another event)

The operating system maintains a process control block (PCB) for each process — a data structure that stores all information about that process, including its state, program counter value, and register contents.

Why does the OS need to schedule processes?

A single-core CPU can only execute one instruction at a time. Without scheduling, the first process to run would monopolise the CPU until it finished — meaning a hung browser could freeze your entire computer for minutes. Scheduling solves this by sharing CPU time among all running processes.

The process scheduler is the part of the OS that decides:

  1. Which process to run next
  2. How long to let it run before switching to another

The goal is to make the system feel responsive: even with many processes competing, each one should make progress and no single process should starve the others.

What is context switching?

When the scheduler switches from one process to another, it must:

  1. Save the current process's state (program counter, register values) to its PCB.
  2. Load the next process's state from its PCB into the CPU.
  3. Resume the next process from exactly where it left off.

This swap is called a context switch. It takes a small but non-zero amount of time — during a context switch, the CPU is doing housekeeping rather than useful work. If context switches happen too frequently, they waste CPU time; if too infrequently, the system feels sluggish.

What are the main scheduling algorithms?

Algorithm How it works Pros Cons
Round robin Each process gets a fixed time slice (quantum). At the end of the quantum, it moves to the back of the queue. Simple, fair, good response time Choosing the right quantum is hard
Priority scheduling Each process has a priority number. The scheduler always runs the highest-priority process. Critical tasks get CPU first Low-priority processes may never run (starvation)
First-come first-served (FCFS) Processes run in arrival order, each running to completion Simple, no starvation Long jobs delay short ones ("convoy effect")
Shortest job first (SJF) The process with the shortest estimated run time goes first Minimises average waiting time Requires knowing run time in advance; long jobs may starve

How does round-robin scheduling work in practice?

Round robin is the most commonly tested algorithm at GCSE. Imagine four processes arrive at approximately the same time with a quantum (time slice) of 2ms:

Process Run time needed
P1 5 ms
P2 3 ms
P3 7 ms
P4 2 ms

The scheduler cycles through them in order:

  1. P1 runs for 2ms → has 3ms left, goes to back of queue
  2. P2 runs for 2ms → has 1ms left, goes to back of queue
  3. P3 runs for 2ms → has 5ms left, goes to back of queue
  4. P4 runs for 2ms → finished
  5. P1 runs for 2ms → has 1ms left
  6. P2 runs for 1ms → finished
  7. P3 runs for 2ms → has 3ms left
  8. P1 runs for 1ms → finished
  9. P3 runs for 2ms → has 1ms left
  10. P3 runs for 1ms → finished

Every process eventually completes. No single process monopolised the CPU for more than 2ms at a time — keeping the system responsive.

What role does scheduling play in real systems?

Modern operating systems use multi-level feedback queues — a sophisticated combination of priority and round-robin scheduling. Processes start in a high-priority queue with a short quantum; if they use their full quantum repeatedly, they are moved to a lower-priority queue with a longer quantum. Interactive processes (like typing in a text editor) tend to use short bursts and stay in the high-priority queue, giving them snappy responses. CPU-intensive background tasks (like video encoding) naturally drift to lower queues with longer quanta, getting thorough CPU time without blocking interactive use.

Frequently asked questions

What is a time slice / quantum and how is it chosen?

A time slice (quantum) is the maximum amount of CPU time a process can use before the scheduler preempts it and passes control to another process. A typical quantum is 10–100 milliseconds. If it is too short, the system wastes time on context switches; if it is too long, the system feels unresponsive to users. Modern OSes tune the quantum dynamically depending on workload.

What is the difference between preemptive and non-preemptive scheduling?

In preemptive scheduling, the OS can forcibly remove a running process from the CPU at any time — for example, when its time slice expires or a higher-priority process becomes ready. Round-robin is preemptive. In non-preemptive scheduling, a process runs until it finishes or voluntarily gives up the CPU (by waiting for I/O, for example). FCFS is non-preemptive. Modern operating systems are preemptive.

Does scheduling work the same way on multi-core CPUs?

With multiple cores, several processes can run truly simultaneously — one per core. The scheduler must assign each ready process to an available core. The scheduling algorithms are similar in principle, but the implementation is more complex because the OS must balance the load across cores and handle processes that move from one core to another. For GCSE, questions focus on single-core scheduling concepts.

How does process scheduling relate to multitasking?

Multitasking is the OS capability to run multiple processes "at the same time". On a single-core CPU, this is an illusion maintained by fast context switching — processes take turns so quickly that it appears simultaneous. Process scheduling is the mechanism that makes multitasking work. Without a scheduler, only one process could run at a time, making the computer unusable for interactive work.


Work through scheduling algorithm trace problems step by step with Professor Turing at aitutors.me.