Context is basically the state or situation of any particular event .when this word is used in technical terms then it refers to the state of the instruction or thread or task or any mode. Context switching can be defined as the storing of the current state of any thread to be performed at a later stage.
Why to switch?
Context switching is done for the better efficiency of the execution. Context switching comes into play in a condition when the need for the immediate change of mode or process occurs. For such condition we are required to save the current status of the ongoing process, so that we can access this data later after the immediate chance in successfully served.
When to switch?
There are various conditions for context switching.
1) When the timer interrupt stops the current running process to fulfil the timely scaling algorithm.
2) When the processor prefers to run the high priority process over the current running program.
3) When the process is executed completely and the next command is still not read.