Context switch

Context switching or task switching ( English contextSwitch ) is the process in an operating system, wherein the processing of the current process (or thread, task or program ) is interrupted (for example, after a specified period of time by a timer interrupt or system calls ) and will be changed to a different routine. Here, the context is (essentially the processor registers ) secured the current process / thread / task and restored the context of the new. Through this process, multitasking is possible, in that it allows multiple processes in the time - multiplexed on a single CPU core, more or less simultaneously execute.

Context switches are usually very time consuming and therefore the design of operating systems is optimized to perform as few context switches. Changing from one process to the next requires some administrative work, such as saving and loading of registers and internal tables to manage the processes.

The strategy of the context switch is determined by the scheduler during the execution itself is performed by the dispatcher.

Trigger for context switching

Multitasking

One of the main triggers for context switching is the multitasking. In this case, a scheduler cares about that all get their share of the total processor time in the system running processes. This context switch is either triggered by the process itself, for example by waiting for the completion of I / O operations. In a preemptive multitasking system, a context switch is also triggered when the process is still run, but the scheduler decides that another process 's turn.

Interrupts

When an interrupt is disruption of normal program execution as by a triggered by the hardware event. If an interrupt is triggered, most CPUs automatically back up the most important contextual information (at least so much so that You can rewind to the actual program flow after the interrupt again). In the interrupt routine if necessary, further information can be backed up, but usually only a minimal context is created in order to save valuable resources and can resume more quickly with the actual program.

485368
de