Context Switching


Switching from one runnable task to another, is handled by context_switch() function defined in kernel/sched.c

context_switch() is called by schedule() when a new process has been selected to run. It does two things:

  1. Calls switch_mm(), which is declared in <asm/mmu_context.h>, to switch the virtual memory mapping from the previous process’s to that of the new process.
  2. Calls switch_to(), declared in <asm/system.h>, to switch the processor state from the previous process’s to the current’s. This involves saving and restoring stack information and the processor registers and any other architecture-specific state that must be managed and restored on a per-process basis.

results matching ""

    No results matching ""