A context switch is the process by which a computer's central processing unit (CPU) saves the execution state (or context) of a currently running task and loads the saved state of a different task to resume its execution. This operation is core to multitasking in both general-purpose and Real-Time Operating Systems (RTOS), allowing a single processor to concurrently manage multiple threads or processes. The overhead—the time and computational resources consumed by the save/restore operation—is a critical performance metric, especially in hard real-time systems where predictable, low-latency execution is mandatory for safety and control stability.




