Context switch

A context switch is the computing process of saving and restoring the state (context) of a CPU such that multiple processes can share a single CPU resource. The context switch is an essential feature of a multitasking operating system. 
Context switches are usually time consuming and much of the design of operating systems is to minimize the time of context switches. 
A context switch can mean a register context switch, a task context switch, a thread context switch, or a process context switch. What will be switched is determined by the processor and the operating system.
The scheduler is the part of the operating systems that manage context switching, it perform context switching in one of the following conditions:
Context switching can be performed primarily by software or hardware. Some CPUs have hardware support for context switches, else if not, it is performed totally by the operating system software. In a context switch, the state of a process must be saved somehow before running another process, so that, the scheduler resume the execution of the process from the point it was suspended; after restoring its complete state before running it again.