Jump to content

Preemption (computing): Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
Noddycr (talk | contribs)
No edit summary
Line 5: Line 5:
The schedulers used in most modern operating systems, such as various flavours of [[Unix]], can preempt user processes. This is called ''preemptive multitasking'', and is in contrast to ''[[cooperative multitasking]]'' wherein a process "gives away" its time by utilizing kernel resources or by specifically calling a kernel routine to allow other processes time to run. Some operating systems' schedulers (including [[Linux]] as of the 2.6 series) have the ability to preempt a process while it is processing a [[system call]] as well (a ''preemptible kernel'').
The schedulers used in most modern operating systems, such as various flavours of [[Unix]], can preempt user processes. This is called ''preemptive multitasking'', and is in contrast to ''[[cooperative multitasking]]'' wherein a process "gives away" its time by utilizing kernel resources or by specifically calling a kernel routine to allow other processes time to run. Some operating systems' schedulers (including [[Linux]] as of the 2.6 series) have the ability to preempt a process while it is processing a [[system call]] as well (a ''preemptible kernel'').


[[Windows XP]], [[Linux]], [[Unix]], *BSD, [[Mac OS X]], and [[Windows NT]] are all examples of operating systems that utilize preemptive multitasking; [[NetWare]], [[Windows for Workgroups]], and Macintosh System 9 are all examples of cooperative multitasking operating systems.
[[Windows XP]], [[Linux]], [[Unix]], [[AmigaOS]], *BSD, [[Mac OS X]], and [[Windows NT]] are all examples of operating systems that utilize preemptive multitasking; [[NetWare]], [[Windows for Workgroups]], and Macintosh System 9 are all examples of cooperative multitasking operating systems.


==Pre-emptive multitasking==
==Pre-emptive multitasking==

Revision as of 14:48, 13 February 2007

Pre-emption as used with respect to operating systems means the ability of the operating system to preempt or stop a currently scheduled task in favour of a higher priority task. The scheduling may be one of, but not limited to, process or I/O scheduling, among others.

Non-preemptability arises, for instance, when handling an interrupt. In this case, scheduling is avoided until the interrupt is handled. Making a scheduler preemptible has the advantage of better system responsiveness and scalability.

The schedulers used in most modern operating systems, such as various flavours of Unix, can preempt user processes. This is called preemptive multitasking, and is in contrast to cooperative multitasking wherein a process "gives away" its time by utilizing kernel resources or by specifically calling a kernel routine to allow other processes time to run. Some operating systems' schedulers (including Linux as of the 2.6 series) have the ability to preempt a process while it is processing a system call as well (a preemptible kernel).

Windows XP, Linux, Unix, AmigaOS, *BSD, Mac OS X, and Windows NT are all examples of operating systems that utilize preemptive multitasking; NetWare, Windows for Workgroups, and Macintosh System 9 are all examples of cooperative multitasking operating systems.

Pre-emptive multitasking

Pre-emptive multitasking is a form of multitasking. To understand the concept, compare to cooperative multiprocessing, in which only the active task (also known as process) may initiate a context switch because the task has:

  1. completed processing.
  2. become blocked on a shared resource.
  3. yielded the processor to another, similarly cooperative, task.

In pre-emptive multitasking, the operating system kernel can also initiate a context switch to satisfy the scheduling policy's priority constraint, thus pre-empting the active task.

Pre-emptive multitasking is sometimes mistakenly used when the intended meaning is more specific, referring instead to the class of scheduling policies known as time-shared scheduling, or time-sharing.

Preemptive multitasking allows the computer system to more reliably guarantee each process a regular "slice" of operating time. It also allows the system to rapidly deal with important external events like incoming data, which might require the immediate attention of one or another process.

At any specific time, processes can be grouped into two categories: those that are waiting for input or output (called "I/O bound"), and those that are fully utilizing the CPU ("CPU bound"). In early systems, processes would often "poll", or "busywait" while waiting for requested input (such as disk, keyboard or network input). During this time, the process was not performing useful work, but still maintained complete control of the CPU. With the advent of interrupts and preemptive multitasking, these I/O bound processes could be "blocked", or put on hold, pending the arrival of the necessary data, allowing other processes to utilize the CPU. As the arrival of the requested data would generate an interrupt, blocked processes could be guaranteed a timely return to execution.

Although multitasking techniques were originally developed to allow multiple users to share a single machine, it soon became apparent that multitasking was useful regardless of the number of users. Many operating systems, from mainframes down to single-user personal computers, have recognized the usefulness of multitasking support for a variety of reasons. Multitasking makes it possible for a single user to run multiple applications at the same time, or to run "background" processes while retaining control of the computer.

In simple terms: Pre-emptive multitasking involves the use of an interrupt mechanism which suspends the currently executing process and invokes a scheduler to determine which process should execute next. Therefore all processes will get some amount of CPU time at any given time.