Preemption (computing)

Preemption (computing)

Pre-emption or preemption in computing is the act of temporarily interrupting a task being carried out by a computer system, without requiring its cooperation, and with the intention of resuming the task at a later time. Such a change is known as a context switch. It is normally carried out by a privileged task or part of the system known as a preemptive scheduler, which has the power to pre-empt, or interrupt, and later resume, other tasks in the system.

User mode and kernel mode

In any given system design, some operations performed by the system may not be preemptible. This usually applies to kernel functions and service interrupts which, if not permitted to run to completion, would tend to produce race conditions resulting in deadlock. Barring the scheduler from preempting tasks while they are processing kernel functions simplifies the kernel design at the expense of system responsiveness. The distinction between user mode and kernel mode, which determines privilege level within the system, may also be used to distinguish whether a task is currently preemptible.

Some modern systems have preemptive kernels, designed to permit tasks to be preempted even when in kernel mode. Examples of such systems are Windows NT, the Linux kernel 2.6 and some BSD systems.

Other systems improve responsiveness by a microkernel design which in some cases may substantially reduce the need for preemption of processes.

Preemptive multitasking

The term preemptive multitasking is used to distinguish a multitasking operating system, which permits preemption of tasks, from a cooperative multitasking system wherein processes or tasks must be programmed to yield when they do not need system resources.

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.

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. In general, pre-emption means "prior seizure of". When the high priority task at that instance seizes the currently running task, it is known as pre-emptive scheduling.

The term "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 and no-user control systems (like those in robotic spacecraft), 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.

Time slice

The period of time for which a process is allowed to run in a preemptive multitasking system is generally called the "time slice". The scheduler is run once every time slice to choose the next process to run. If the time slice is too short then the scheduler will consume too much processing time.

An interrupt is scheduled to allow the operating system kernel to switch between processes when their time slices expire, effectively allowing the processor’s time to be shared between a number of tasks, giving the illusion that it is dealing with these tasks simultaneously, or concurrently. The operating system which controls such a design is called a multi-tasking system.

ystems supporting preemptive multitasking

Examples of pre-emptive operating systems include AmigaOS, the Windows NT family (including XP and Vista), Linux, *BSD, Mac OS X and Windows 95/98/ME (32-bit applications only) [http://support.microsoft.com/kb/117567 How 16-Bit and 32-Bit Programs Multitask in Windows 95 (Q117567)] ] . Unix and Unix-based systems, and VMS, as well as other systems used in the academic and medium-to-large business markets, have always supported pre-emptive multitasking, but for a long time were beyond the reach of most users either because of the costs of licensing or the expensive hardware required to support them.

Examples of older, non-pre-emptive (cooperative) operating systems include Windows 1.x, 2.x, 3.x, Windows for Workgroups, Windows 95/98 (when running 16-bit applications), NetWare, and Classic Mac OS versions (system 5.0 and up). Non-multitasking operating systems include older versions of Mac OS, MS DOS, and Commodore 64 OS which could only execute one program at a time.

Amiga OS, based on the preemptive multitasking TRIPOS system, was the first such system widely available to home users (1985). Running on Motorola 68000-based Amiga systems without memory management, the system used dynamic loading of relocatable code blocks ("hunks" in Amiga jargon) to pre-emptively multitask all processes in the same flat address space.

Early PC operating systems such as MS-DOS and DR-DOS, did not support multitasking at all. Novell NetWare, Microsoft Windows and OS/2 systems introduced cooperative multitasking to the PC, but did not support preemptive multitasking. In the case of the PC, the slow start was partly because of the need to support a large legacy code base of DOS software written to run in single-user mode on a 8086-based PC, whereas the Amiga system was designed to multitask from the beginning.

The earliest version of Windows to support a limited form of preemptive multitasking was Windows 2.1x, which used the Intel 80386's Virtual 8086 mode to run DOS applications in virtual 8086 machines--commonly known as "DOS boxes"--which were preemptible. In Windows 95 and its successors, Windows 98 and Windows Me, 32-bit applications were made preemptible by running each one in a separate address space, but 16 bit applications remained cooperative. Windows NT, which ran processes in a 32-bit paged address space from the outset, has always supported preemptive multitasking, and this has been inherited by the NT line of Windows systems, including Windows 2000, Windows XP and Windows Vista.

Although there were plans to upgrade the cooperative multitasking Mac OS to a preemptive model, these were abandoned in favor of Mac OS X, a re-engineered system based on the BSD-derived Darwin kernel, which supports preemptive multitasking.

OS/2 Warp, IBM's rewrite of an earlier IBM/Microsoft collaboration, OS/2, targeted at 386 systems, supported preemptive multitasking of native applications, and also permitted several different Windows sessions to be multitasked preemptively.

References


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Preemption — or pre emption may refer to: Legal Federal preemption, displacement of U.S. state law by U.S. Federal law Preemption is also sometimes used in the United States to refer to the displacing effect state laws might have on ordinances enacted by… …   Wikipedia

  • Scheduling (computing) — This article is about processes assignment in operating systems. For other uses, see Scheduling (disambiguation). Scheduling is a key concept in computer multitasking, multiprocessing operating system and real time operating system designs.… …   Wikipedia

  • Hibernation (computing) — Hibernation in computing is powering down a computer while retaining its state. Upon hibernation, the computer saves the contents of its random access memory (RAM) to a hard disk or other non volatile storage. Upon resumption, the computer is… …   Wikipedia

  • Computer multitasking — In computing, multitasking is a method where multiple tasks, also known as processes, share common processing resources such as a CPU. In the case of a computer with a single CPU, only one task is said to be running at any point in time, meaning… …   Wikipedia

  • Cyclic executive — A cyclic executive is an alternative to a real time operating system. It is a form of cooperative multitasking, in which there is only one task. The sole task is typically realized as an infinite loop in main(), e.g. in C/C++. The basic scheme is …   Wikipedia

  • Deadlock — This article is about the computer science concept. For other uses, see Deadlock (disambiguation). A deadlock is a situation where in two or more competing actions are each waiting for the other to finish, and thus neither ever does. It is often… …   Wikipedia

  • Operating system — Operating systems …   Wikipedia

  • Linux kernel — Linux Linux kernel 3.0.0 booting Company / developer Linus Torvalds and thousands …   Wikipedia

  • Concurrent data structure — In computer science, a concurrent data structure is a particular way of storing and organizing data for access by multiple computing threads (or processes) on a computer. Historically, such data structures were used on uniprocessor machines with… …   Wikipedia

  • L4 microkernel family — L4 is a family of second generation microkernels, generally used to implement Unix like operating systems, but also used in a variety of other systems. L4 was a response to the poor performance of earlier microkernel base operating systems.… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”