Computer multitasking

The term multitasking [ ˌ mʌltitɑ skɪŋ ː ] (English ) or multi- process mode refers to the ability of an operating system to perform multiple tasks (tasks) ( quasi-) concurrently. In general, the processor provides this and supporting hardware structures. The various processes are alternately activated in such short intervals that the impression of simultaneity arises. Multitasking is thus a synonym for time - division multiplexing. If a computer has multiple CPU cores, so that he can really - simultaneously perform multiple tasks, it is called multiprocessing. In modern computers, the two methods are used in combination.

Purpose of multitasking

Multitasking can be useful in different requirements, especially in the optimization of the utilization and for a balanced or priority-based depending on the objective distribution of resources.

The basic idea behind the " optimal use " is that in an average computer the majority of the computation time can not be used because it is often necessary to wait for relatively slow, external events ( for example on the next keystroke of the user). If only one process running (for example, the waiting word processing ), this waiting time would be completely wasted (see "active waiting" ). Multitasking, however, by the waiting time of a process from other processes can be used.

If a computer or its computation time in contrast, largely utilized, for example, by individual compute-intensive processes, as yet, several users or processes receive proportional computing time, rather than having to wait for the end of another process. This is particularly benefits the interactivity.

Because the system at the same time can be considered priorities for the various processes, appropriate weighting is possible, depending on the objective. A server can, for example, prefer the services which he should offer, but prioritize direct user interaction low. A desktop PC is reversed mainly prefer the inputs and outputs from / to the user, and Reset for background processes something.

Precursor and development

Multi programming and TSR programs

Precursor of multitasking is the multi- programming with the goal of a higher CPU usage as opposed to the sequential execution of the tasks for batch processing. In the multi- programming of context switches programs will be held with the access to peripheral devices, since it inevitably waiting time arises. The first approaches based on the concept of Christopher Strachey from the year 1959. Implement practical terms, let such concepts but only with more powerful hardware than the development of TSR programs was made possible with the interrupt.

General sequence

The technical process when multitasking is basically always the same.

An important prerequisite of multitasking is generally considered that a process is interrupted in favor of another, nothing about this other (or possibly even several others) must "know". This is usually achieved by each process has its own so-called process context, describes its condition. A process is always changing only its own process context, never the other process.

In general, the whole process context (the state of the process ) are stored in the interrupt, for example, on the stack ( Sheet Stack). He remains in the memory until the process in question again to get computer time. Immediately before this process becomes active again, the saved state is loaded again, so it appears for the process, as he was not interrupted; regardless of whether, how many and what have been carried for processes in the meantime. This switching between processes is referred to as task switching.

Thus, a process in the further execution after the interruption again find a defined environment, even if subsequently other processes were running.

In cooperative multitasking of task switching is very similar to calling procedures or functions in procedural programming.

Cooperative multitasking

The " cooperative multitasking " multitasking is realized by a central process management system kernel: a simple, so-called scheduler. The scheduler saves the process context of the currently interrupted task, selects the next process of who is to receive CPU time, establishes the process context and returns the processor then off to this new process. The scheduler can maintain lists with different priority tasks, and low-priority according rarely call. In this case, the already consumed computation time of a task are considered. In general operating system -specific tasks are done first before a new task is assigned the processor. It is up to each process itself, when it returns control to the core; usually, each service request is at least connected to the operating system with a task switch.

Advantage of this method is that many system functions (eg the output ) need not be reentrant and therefore need not be synchronized, which means a considerable simplification for the manufacturer. ( However, interrupt routines must always solve this problem. ) This form of multitasking has as well as the TSR concept that programs that do not cooperate bring the disadvantage of the rest of the system to a halt. Reasons for such a program behavior can be:

  • The program contained errors;
  • Intended by the programmer malfunction of a system;
  • Intentional ( advantageous ) " autocracy " of the program, for example, for a time-critical application such as a computer game.

The concept has been used, for example

  • Windows 3.x: Under this system, multitasking is only partially supported, as only the respective memory areas exist side by side and the applications are simply stopped in the background in favor of the active program.
  • In many home computers such as the Commodore Amiga or Atari ST.
  • In graphical user interfaces for MS -DOS and compatibles.
  • ( restricted) in advanced TSR programs for MS -DOS.

This form of multitasking is basically fast and resource efficient, and technically relatively easy to implement. For multi-user capable mainframe it was never a viable alternative and has never been used, for example, on Unix, since a user could block using noncooperative program all the others. Also in the newer Windows operating systems in the NT line, and in Mac OS X, this technique is now regarded as outdated is not used. Partial support similar functionality limited, for example, as a user-mode threads, but in any case only be embedded in pre-emptive multitasking.

Preemptive multitasking

Basis of the nowadays default method used is the pre-emptive multitasking. The processing of each process is also controlled by the scheduler, a part of the operating system core ( see below). Each process is interrupted after a certain processing time. In this case, one speaks also of so-called time slots (or time slices, Eng. Time slices ). Then " sleeps" the process ( is inactive ), and other processes are handled. If it receives another processor allocation, as he continues his work ( is active). Most every process is an "absolute " time slice assigned (all time slices have the same, fixed duration ); alternatively it is defined per unit of time, a certain percentage of that time unit assigned (eg depending on its priority), which he can use at most ( the length of the time slice is so every time redetermined ). Ends its time slice ( " its processor allocation is at an end " ), then interrupts a hardware timer, it will be " put to sleep " again and the operating system regains control. Should he need a function of the operating system before the end of its time slice, it is immediately stopped and marked as " not ready" until the operating system has provided the desired service. Only marked as " ready" processes receive processor time allocations.

A popular implementation of preemptive multitasking is the use of a priority queue in conjunction with the round-robin scheduling policy. There is also the function of the processor task priority assignment, especially in real-time systems such as MicroC / OS -II. For the multitasking which plays only a minor role, since preemptive multitasking kernel and describes the processor control over the processes.

On the hardware side requires preemptive multitasking as opposed to the cooperative variant (see TSR program as a precursor ) is absolutely an interrupt generator (usually a timer ) in the appropriate processor, as the system software side has no way to escape processes the control of the processor. The timer sends a signal (interrupt ) to the CPU, causing them to interrupt the currently running task and the scheduler running regularly or after a preset time. This saves the current interrupted process context, takes necessary administrative tasks and then activated again a (different ) process.

Modern operating systems are also working with a memory protection, which prevents different processes influence each other in memory, or even write about. This protection takes over the PC the Memory Management Unit (MMU ), which the virtualization of the main memory, and various authorization levels (rings ) or modes ( kernel mode versus user mode ) allows and so allows the operating system, various parallel processes within the computer from each other strictly encapsulate. In PC, the MMU was first used in computers with I286 processors from Intel. This technique, however, is for multitasking in the strict sense is not absolutely necessary.

The first widespread computer systems that dominated pre-emptive multitasking, were the Sinclair QL (1984 ) and the Amiga by Commodore International ( 1985) in the home, as well as the previously operated under Unix mainframe computers. Windows dominates the first time in the 3.x versions partially preemptive multitasking, but only there for DOS programs and that too only if they are running on a system with an i386 compatible processor as it allows in such cases hardware-based virtualization. Modern operating systems that support preemptive multitasking completely, are Windows NT (and any successor ), QNX, BeOS and all Unix-based systems such as Linux, HP- UX, Solaris, Mac OS X and more

You also have to between Time slicing ( time-slice method ) and time-sharing differ, the latter allows multiple users or their processes (eg on database servers or mainframes with terminal access ) automatically in proportion to share the available computing time.

Präemptibles multitasking

A special form of preemptive multitasking is the lesser known Präemptible multitasking ( English spelling Preemptible multitasking), which was first implemented in the operating system OS / 2. Many operating system 's own kernel routines are run as the scheduler threads; thus may also receive time slots application processes, whereas actually an operating system action is performed (with exceptions for atomic OS processes). This will allow for faster response times. With version 2.6 it has been found in the Linux kernel input.

485630
de