Preemptive Multitasking Article Index for
Preemptive
 

Information About

Preemptive Multitasking




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'').



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:
# completed processing.
# become blocked on a shared resource.
# 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. In general, pre-emption means "prior seizure of". When the high priority task at that instance seize the currently running task, it is known as pre-emptive scheduling.

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 s), 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.


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 but if it is too long then processes may not be able to respond to external events quickly enough.

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.


EXTERNAL LINKS