microZEUS
The whole stack, hand-drawn.

◄ Wiki / OS

context switch

The kernel saving one thread's full state and loading another's, so a single CPU can juggle many tasks.

A CPU core runs one thread at a time, so to share it the operating system freezes a thread — saving its registers, program counter, and stack pointer — and restores a different thread's saved state to resume it. That swap is a context switch, and doing it fast and correctly is central to multitasking. The kernel-mode resume path is where the restored state is put back into effect.

See also

  • cloneA system call that creates a new process or thread, letting the child share chosen resources with its parent.
  • critical sectionA stretch of code that must be run by only one thread at a time to avoid corruption.
  • calling conventionThe agreed rulebook for how one function passes arguments to another and gets a result back.

Referenced by

bootloader / mzBIOS · calling convention · clone · CNTP · code-segment selector · core · CPU exception / trap · critical section