Log in Sign up
Back to Discover
💻

Preemption (computing)

technology Maturity 9-11

A computer can do many jobs. It can switch jobs very fast. It stops one job to start another. This helps you do many things at once. It makes your computer feel fast. Do you like playing games and listening to music?

42 words

A computer can do many jobs at once. Sometimes, one job needs to stop for a moment. A special part of the system makes this happen. It stops one task to start a new one. This is called a switch. The system gives each job a tiny bit of time. This bit of time is a slice. The computer switches tasks very quickly. This makes it feel like it does everything at the same time. It helps the computer stay fast and ready.

86 words

A computer can do many jobs at once. This is called multitasking. Sometimes, one job must stop so another can work. This is called preemption. An external scheduler manages this. A scheduler is a part of the system that picks which job runs next. It can pause a task without the task's help. This pause and restart is called a context switch.

The scheduler gives each task a tiny bit of time. This bit of time is called a time slice. The scheduler runs every time a slice ends. This lets every job get some time on the CPU. The CPU is the main brain of the computer.

Preemption helps a computer stay fast. It lets the system handle important new data right away. Some jobs wait for things like a keyboard or a disk. These are called I/O bound tasks. The system can put these tasks on hold. This lets other jobs use the CPU instead. Most modern systems use this. This includes Windows, Linux, and macOS.

171 words

Computers often seem to do many things at once. This is called multitasking. To make this work well, systems use something called preemption. Preemption is when a scheduler pauses a running task. This happens without the task asking for help. The goal is to resume the task later. This allows the computer to stay fast and responsive.

This process works through a method called context switching. A scheduler manages the work by using tiny bits of time. Each bit is called a time slice or a quantum. When a slice ends, an interrupt tells the system to switch. The scheduler then picks the next task to run. This gives every process a regular slice of time. It creates the illusion that many tasks happen at once.

In the past, computers used cooperative multitasking. In those systems, tasks had to give up control themselves. This was different from the preemptive way. Early microcomputer systems like OS-9 used preemption. Sinclair QDOS and AmigaOS also offered this as a core feature. These systems ran on Motorola 68000-family microprocessors. They helped computers manage many jobs more reliably.

Many famous systems now use preemptive multitasking. Modern versions of Windows, Linux, and macOS all use it. Linux has used it since version 2.5.4. Windows NT has always supported this method. Even Android uses it because it is based on Linux. Some early systems, like MS-DOS, did not support it at all. However, other systems like MP/M-86 did support it in 1981.

Preemption is very helpful for different types of tasks. Some tasks are CPU bound, which means they use the processor a lot. Other tasks are I/O bound, meaning they wait for things like a keyboard. In old systems, waiting tasks would just sit there and use the CPU. With preemption, the system can block these waiting tasks. This lets the CPU work on other important things instead. This makes the whole computer much more efficient.

325 words

In computing, preemption is a method used to manage how a processor handles different tasks. It is the act of an external scheduler temporarily interrupting a running task. This interruption happens without any assistance or cooperation from the task itself. The scheduler intends to resume the interrupted task at a later time. This process is highly secure because the scheduler usually runs in the most privileged protection ring. When the processor changes which task it is currently executing, this is known as context switching. Preemption is essential for modern multitasking, ensuring that no single process holds the processor hostage.

To understand how this works, we must look at the mechanism of the scheduler and interrupts. In a preemptive multitasking system, the operating system uses an interrupt mechanism to function. This interrupt suspends the currently executing process. Once suspended, the scheduler is invoked to determine which process should execute next. This ensures that every process receives some amount of CPU time. The scheduler can also initiate a context switch to satisfy priority constraints. If a high-priority task needs to run, it can seize control from the current task. This specific type of scheduling is called preemptive scheduling.

Processes are often categorized by how they use system resources. Some tasks are known as CPU bound because they fully utilize the processor. Other tasks are called I/O bound, meaning they are waiting for input or output. This might include waiting for a keyboard, a disk, or network input. In early computing systems, I/O bound processes would often "poll" or "busy-wait." This meant they maintained complete control of the CPU while doing no useful work. With preemption, these processes can be "blocked" or put on hold. This allows the CPU to work on other tasks until the necessary data arrives via an interrupt.

Managing these tasks requires a careful balance of time. The period a process is allowed to run is called a time slice or a quantum. The scheduler runs once every time slice to choose the next process. The length of this slice is critical for system performance. If the time slice is too short, the scheduler consumes too much processing time. If the time slice is too long, processes take longer to respond to user input. By using interrupts when time slices expire, the system shares the processor among many tasks. This creates the illusion that the computer is dealing with all tasks in parallel.

System design also involves different levels of privilege, known as user mode and kernel mode. In some designs, certain operations are not preemptable. This often applies to kernel functions and service interrupts. If these are not allowed to run to completion, they might produce race conditions. These conditions can lead to a deadlock, where the system stops working. Some designs simplify the kernel by barring preemption during these functions, though this reduces responsiveness. However, most modern operating systems use preemptive kernels. These are designed to permit tasks to be preempted even while in kernel mode.

The history of multitasking shows a shift from cooperative to preemptive models. In cooperative multitasking, processes must be explicitly programmed to yield control. Early microcomputer systems like Microware's OS-9 provided preemptive multitasking. Sinclair QDOS and AmigaOS were also early examples that used preemption as a core feature. These systems often ran on Motorola 68000-family microprocessors. In contrast, early IBM PC systems like MS-DOS did not support multitasking at all. However, other systems like MP/M-86 supported it as early as 1981. Windows eventually introduced limited preemption with Windows/386 2.0 using virtual 8086 machines.

Today, preemptive multitasking is a standard feature in almost all major operating systems. This includes Windows NT, all versions of Linux, and the Linux kernel from version 2.5.4 and newer. It is also found in Solaris 2.0, AIX, and various BSD systems like NetBSD. Apple's operating systems, such as macOS and iOS, are based on the Mach kernel and derive from BSD. Even Android uses this technology because it is based on Linux. This widespread support allows a single user to run multiple applications at once. It also allows the system to handle important external events rapidly, making modern computing reliable and efficient.

694 words
Up Next
💻
Computer multitasking
Technology
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.