A1.3.3 CPU scheduling: comparing the methods
SL + HLCommand term: Compare1. 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
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:
- Explain why the operating system schedules processes and allocates CPU time.
- Define performance measures such as waiting time, turnaround time and response time.
- Describe first-come first-served, round robin, multilevel queue and priority scheduling.
- Calculate waiting and turnaround times for a set of processes under different scheduling approaches.
- 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
| Algorithm | How it works | Advantages | Disadvantages | Good 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 switches | Long jobs make everyone wait (convoy effect); poor response time | Batch 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 starvation | Many context switches; average waiting can be high; performance depends on quantum size | Time-sharing and interactive systems |
| Priority | The ready process with the highest priority runs first (preemptive or non-preemptive). | Important tasks run first; flexible | Low-priority processes may wait for ever (starvation); fixed by aging (raising priority the longer a process waits) | Real-time and system tasks |
| Multilevel queue | Processes 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 responsive | More complex; lower queues can starve; a process can't move between queues (unless it is a feedback queue) | General-purpose operating systems |
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]
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]
3. Repeat question 2 using round robin with a time quantum of 2. [3]
4. Explain what is meant by starvation in priority scheduling and how it can be prevented. [3]
5. Compare round robin and first-come first-served scheduling for an interactive system such as a school laptop. [4]