voluntary context switch
also: blocking context switch
A context switch that occurs when a running process explicitly yields the CPU to the scheduler, allowing other processes to run. Unlike involuntary switches triggered by interrupts or time-slice expiration, the process chooses to relinquish control.
A voluntary context switch happens when a process makes a system call that blocks or pauses its execution. Common examples include read() waiting for input, write() waiting for I/O completion, sleep() deliberately pausing, or wait() for child processes.
When the kernel processes such a call, it recognizes the process cannot proceed and removes it from the CPU, saving its state and scheduling another runnable process instead. The original process remains in a wait queue until its blocking condition is satisfied.
For example, a process reading from a file waits for the disk to respond; rather than wasting CPU cycles, it voluntarily relinquishes the processor so other work can proceed. This contrasts with involuntary context switches, where the scheduler forcibly interrupts a running process after its time quantum expires.
Voluntary context switches are generally efficient—they represent processes being good citizens and not hogging CPU resources. Too many involuntary switches can indicate CPU contention and scheduling overhead.