Skip to content

preemptive multitasking

Preemptive multitasking is a CPU scheduling approach in which the operating system can interrupt a running task and hand the CPU to another, without the task’s cooperation. A component called the scheduler decides which task runs next and forces the switch on its own schedule.

The mechanism rests on a hardware timer that fires an interrupt at regular intervals. Each task gets a small slice of CPU time, called a time slice or quantum.

When the slice expires, the timer interrupt suspends the current task, the scheduler picks another runnable task, and a context switch saves the old task’s state and restores the new one. The interrupted task resumes later from exactly where it left off, and the whole cycle repeats on the next timer tick:

A timer interrupt ends a task's turn, the scheduler saves its state, picks the next task, restores it, and the cycle repeats.
Timer Ticks Force Every CPU Handoff

Capping how long any single task can hold the CPU keeps the whole system responsive. A task that gets stuck in a loop or a blocking call can’t freeze everything else, unlike under cooperative multitasking, which relies on each task to yield voluntarily. Preemptive multitasking underpins Windows, macOS, and Linux, along with the time-sharing of threads within a process.

Speed Up Your Python Program With Concurrency

Tutorial

Speed Up Your Python Program With Concurrency

In this tutorial, you'll explore concurrency in Python, including multi-threaded and asynchronous solutions for I/O-bound tasks, and multiprocessing for CPU-bound tasks. By the end of this tutorial, you'll know how to choose the appropriate concurrency model for your program's needs.

advanced best-practices

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated July 16, 2026 • Reviewed by Leodanis Pozo Ramos