This article is about computer task switching. For the term in human cognition, see Human multitasking.
In computing, a context switch is the process of storing the state of a process or thread, so that it can be restored and resume execution at a later point, and then restoring a different, previously saved, state.[1] This allows multiple processes to share a single central processing unit (CPU), and is an essential feature of a multiprogramming or multitasking operating system. In a traditional CPU, each process - a program in execution - utilizes the various CPU registers to store data and hold the current state of the running process. However, in a multitasking operating system, the operating system switches between processes or threads to allow the execution of multiple processes simultaneously. For every switch, the operating system must save the state of the currently running process, followed by loading the next process state, which will run on the CPU. This sequence of operations that stores the state of the running process and the loading of the following running process is called a context switch.
The precise meaning of the phrase "context switch" varies. In a multitasking context, it refers to the process of storing the system state for one task, so that task can be paused and another task resumed. A context switch can also occur as the result of an interrupt, such as when a task needs to access disk storage, freeing up CPU time for other tasks. Some operating systems also require a context switch to move between user mode and kernel mode tasks. The process of context switching can have a negative impact on system performance.[2]: 28
^Douglas Comer; Timmothy V. Fossum (1988). "4 Scheduling and Context Switching". Operating System Design. Vol. I: The XINU Approach (PC Edition). Prentice Hall. p. 67. ISBN 0-13-638180-4. Context switching lies at the heart of the process juggling act. It consists of stopping the current computation, saving enough information so it may be restarted later, and restarting another process.
^Tanenbaum, Andrew S.; Bos, Herbert (March 20, 2014). Modern Operating Systems (4th ed.). Pearson. ISBN 978-0133591620.
In computing, a contextswitch is the process of storing the state of a process or thread, so that it can be restored and resume execution at a later point...
Perform a contextswitch to the next process in the ready queue. While the writing takes place, the operating system will contextswitch to other processes...
29 clock cycles per memory access). On an address-space switch, as occurs when contextswitching between processes (but not between threads), some TLB entries...
computer multitasking in which the operating system never initiates a contextswitch from a running process to another process. Instead, in order to run...
saved state of another program and transferring control to it. This "contextswitch" may be initiated at fixed time intervals (pre-emptive multitasking)...
(R13) for every interrupt mode. x86 processors use contextswitching and fast interrupt for switching between instruction, decoder, GPRs and register files...
perform a rapid contextswitch before executing a different thread. This fast contextswitch is sometimes referred to as a thread switch. There may or may...
similar to interrupt routines. In response to an interrupt, there is a contextswitch, and the code for the interrupt is loaded and executed. The job of a...
processor to track memory accesses for a specific address. However, if a contextswitch occurs between calls to LDREX and STREX, the documentation notes that...
is used to track process information, the PCB plays a key role in contextswitching. An operating system kernel stores PCBs in a process table. The current...
thread to be executed on that processor and dispatcher to perform a contextswitch. Since the clock interrupt occurs at a much higher IRQL, it will be...
program should perform process scheduling, which is also known as a contextswitch. The kernel creates a process control block when a program is selected...
is equivalent to a contextswitch at the operating system level. The difference is that a multithreaded CPU can do a thread switch in one CPU cycle instead...
remainder of its scheduling quantum and forces a contextswitch. The overhead of repeated contextswitches and underutilization of scheduling quanta degrade...
concurrency known as cooperative multitasking and, therefore, do not incur contextswitch when yielding to another thread. Within a protothread, yielding is accomplished...