$linuxjunkies
>

involuntary context switch

also: preemptive context switch, forced context switch

A context switch forced by the kernel scheduler when a process's time slice expires or a higher-priority process becomes runnable, regardless of whether the current process is willing to yield control.

An involuntary context switch occurs when the Linux kernel preempts a running process and switches execution to another process without the running process requesting it. This happens when the process's allocated CPU time quantum (time slice) expires or when a higher-priority process becomes ready to run.

Unlike voluntary context switches, where a process explicitly yields the CPU (for example, by blocking on I/O or calling sched_yield()), an involuntary switch interrupts the process's execution mid-stream. The kernel saves the process's state and restores another process's state to continue running.

You can observe involuntary context switches using vmstat or by examining /proc/[pid]/stat, which tracks the number of context switches. For example, vmstat 1 shows columns cs (context switches) and distinguishes voluntary from involuntary switches in detailed process statistics.

Related terms