What is a context switch, and why does it cost anything?

2 stars Asked often.

In one or two sentences
The CPU saves the state of the task it was running, loads the state of another task and continues there. While that happens, the CPU does no user work.

Think of your own answer first

Say it out loud, or type it below. What you type never leaves this device.

Follow-up questions

These are likely next questions from an interviewer. Think of your answer first, then press the button.

  1. 1 / 3

    Which is more expensive, a process switch or a thread switch?

Sources checked

This is a textbook level concept, so no outside source is listed.