Each time a process is removed from access to the processor, sufficient information on its current operating state must be stored such that when it is again scheduled to run on the processor it can resume its operation from an identical position. This operational state data is known as its context and the act of removing the process's thread of execution from the processor (and replacing it with another) is known as a process switch or context switch.
The distinction is made here between the condition where a process is removed from the processor completely and is replaced by another process (a process switch) and the case where the process state is stored while execution is interrupted temporarily (a context switch). Note that a process switch performs a superset of the operations required for the context switch. The latter case may be when an external interrupt is serviced or when a system call necessitates a switch from user mode to system mode. In the case of the process switch much more information must be saved in order to later restore the process context than in the second case where the process remains resident in memory while it's thread of execution is interrupted.
The context of a process includes its address space, stack space, virtual address space, register set image (e.g. Program Counter (PC), Stack Pointer (SP), Instruction Register (IR), Program Status Word (PSW) and other general processor registers), updating profiling or accounting information, making a snapshot image of its associated kernel data structures and updating the current state of the process (waiting, ready, etc).
This state information is saved in the process's process control block which is then moved to the appropriate scheduling queue. The new process is moved to the CPU by copying the PCB info into the appropriate locations (e.g. the program counter is loaded with the address of the next instruction to execute).
|
|
|
|
|
|
|
|
|