What is context switching?
One of the biggest steps forward in the design and operation of Central processing units (CPU) came when designers of computer operating systems developed techniques that allow multitask users. Multitasking with reference to computers is the practice of running two or more programs at the same time. From the end -user point of view, this may not seem complicated or remote, but in fact it is a significant jump in the design of the system. In multitasking, the CPU must juggle all operations for various active programs and record where it is with each program, because the user switches back and forth between them. Switching context is a process that allows CPU to remember and restore states for various active programs, allowing it to complete this juggling.
During the switching of the CPU context, he abandons any program that is currently manipulating, and deposits the specific location in which he was in this program to restore his progress later. Put it in perspective, switching context is troChu as reading more books at the same time, constantly switching between them back and forth, while you always remember the page numbers for each of them. Information about the "page number" for programs during the context switching operation is held by the process control block (PCB). PCB is also sometimes referred to as "switch". This information is stored in the memory within the actual CPU until it is necessary again.
Context switching occurs in three possible situations: manipulation of interruption, multitasking and user switching. When interrupting the manipulation of interruption, another program "interrupts" the current program when it runs. Once the CPU has received an interruption, it performs a context switch to juggle between the running program and the program requiring immediate data. During multitasking, the processor falls back and forth between programs, giving the time piece of processing to each and performing the context switching operation between them. For some operating systems, a context switch for the operating system is also performed during the user switch, although this is not explicitly required.
Either operating system or computer hardware can control context switching. Some modern operating systems A are designed to control context through the operating system itself and ignore any built -in hardware support for procedure. This allows the operating system to save additional information during the context switch, allowing it to maintain more information about the switch.