Sunday, February 20, 2011

OS- CONTEXT SWITCHING

A context switch is the computing process of storing and restoring state (context) of a CPU so that execution can be resumed from the same point at a later time. This enables multiple processes to share a single CPU. The context switch is an essential feature of a multitasking operating system.

A context switch can mean a register context switch, a task context switch, a thread context switch, or a process context switch.


The scheduler is the part of the operating systems that manage context switching, it perform context switching in one of the following conditions:
  1. Multitasking: Within a preemptive multitasking operating system, the scheduler allows every task (according to its priority level) to run for some certain amount of time, called its time slice where a timer interrupt triggers the operating system to schedule another process for execution instead.
    If a process will wait for one of the computer resources or will perform an I/O operation, the operating system schedules another process for execution instead.
  2. Interrupt handling: Some CPU architectures (like the Intel x86 architecture) are interrupt driven. When an interrupt occurs, the scheduler calls its interrupt handler in order to serve the interrupt after switching contexts; the scheduler suspended the currently running process till executing the interrupt handler.
  3. User and kernel mode switching: Context switching can be described in slightly more detail as the kernel suspending execution of one process on the CPU and resuming execution of some other process that had previously been suspended. When a transition between user mode and kernel mode is required in an operating system, a context switch is not necessary; a mode transition is not by itself a context switch. However, depending on the operating system, a context switch may also take place at this time.
for more details visit:   http://www.linfo.org/context_switch.html
                                  http://simple.wikipedia.org/wiki/Context_switch
                                  http://en.wikipedia.org/wiki/Context_switch









No comments:

Post a Comment