i

JAVA Complete Course

Context Switching

Context Switching is the process of keeping the state of context or state of a process in order to be able to reload when it will be required and execution can be resumed from previous point. Context switching is a functionality of a multitasking operating system to allow a single CPU to be shared by multiple processes

Below are listed the major triggers for context switching.

Multitasking: In this environment, a process is switched out of the CPU which means that another process can be run. The state of the old process will be saved and and state of the new process will be loaded.

Interrupt Handling: This is the case when hardware switches a part of the context when during the interruption. This happens automatically.

User and Kernel Switching: When a transition between the user mode and kernel mode is required in the operating system a context switch may happen in that time.