What is Context Switching (or Preemption )?

Context switching is a mechanism, that involves the switching from one runnable task to another, is handled by the context_switch() function defined in kernel/sched.c. It use to call by schedule() when a new process has been selected to run. In other words, we can say as the current running process is preempted by another process, which we can refer as Pre-emption.

It does two basic stuffs:
• Calls switch_mm() to switch the virtual memory mapping from the previous process’s to that of the new process which is going to run. This method is declared in <asm/mmu_context.h>.

• Calls switch_to() to switch the processor state from the previous process’s to the current’s which is going to run. 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. This method is declared in <asm/system.h>.
Previous Post Next Post

Contact Form