Context change

from Wikipedia, the free encyclopedia

Context switch or task switching ( English context switch ) is called the operation in an operating system , wherein the processing of the current process (or threads , tasks or program ) is interrupted (for. Example, after a specified period of time by a timer interrupt or System calls ) and switch to another routine. The context (essentially the processor register) of the current process / thread / task is saved and the context of the new one is restored. This process enables multitasking , as several processes can be executed more or less simultaneously on a single CPU core using the time division multiplex method.

Context changes are usually time-consuming and therefore the design of operating systems is optimized to carry out as few context changes as possible. Switching from one process to the next requires a certain administrative effort, such as saving and loading registers and internal tables for managing the processes.

The strategy for the context change is determined by the scheduler , while the dispatcher itself takes care of it.

Trigger for context change

multitasking

One of the most important triggers for context changes is multitasking. A scheduler ensures that all processes running in the system get their share of the total processor time. This change of context is either triggered by the process itself, for example by waiting for I / O operations to be completed. In a preemptive multitasking system , a context change is triggered even if the process is still executable, but the scheduler decides that another process has its turn.

Interrupts

An interrupt is an interruption in normal program execution, for example due to an event triggered by the hardware. If an interrupt is triggered, most CPUs automatically save the most important contextual information (at least enough to allow you to jump back to the actual program flow after the interrupt). If necessary, further information can be saved in the interrupt routine , but mostly only a minimal context is created in order to save valuable resources and to be able to continue with the actual program more quickly.

See also

literature

  • Andrew S. Tanenbaum: Modern Operating Systems . Prentice Hall, Englewood Cliffs, New Jersey 1992, ISBN 0-13-595752-4 .

Web links