Monday, 16 September 2013

CONTEXT SWITCHING

CONTEXT SWITCHING:
   
A Context switch is the switching of the CPU from one  process to another.It can Occur only in kernel mode.

A Process is an executing instance of a program.


A context is the contents of a CPU's Register and Program Counter at any point in Time.

A Register is a small amount of very fast memory inside of a CPU that is used to speed the execution  of computer programs by providing quick access.

A Program Counter is a specialized register that indicates the position of the CPU in its instruction sequence and which holds either the address of the instruction being executed or the address of the next instruction to be executed,depending on the specific system.

If we go in detail,The kernel(Core of the operating system)performing the following activities with regard to the process.

1.Suspending the progression of one process and storing the CPU's state(Context)for that process somewhere in memory.

2.Retrieving the context of the next process from memory and restoring it in the CPU's Registers.

3.Returning to the Location indicated by the Program counter(Returning the lines of code at which the process was interrupted)in order to resume the process.

Simply telling A context switch is the kernel suspending execution of one process on the CPU and resuming execution of some other process that had previously been suspended

No comments: