Distributed Computing Notes
Distributed Computing Notes
Monday, March 01, 2004 1. 2. 3. 4. Process switch vs. Context Switching (partly covered) Operating Systems and user Processes Micro Kernels Processes and Threads
What is the difference between a context switch and a process switch? Therefore what is a process switch and what is a context switch? Process Switching When/How? A process switch occurs whenever the operating system has gained control from the currently running process. 1. Interrupts (These are external to the running program) a. Clock Interrupt The OS determines whether the currently running process has been executing for the maximum allowable time slice. If so the process is switched to a ready state and another process dispatched. b. IO interrupt - The OS determines what IO action has occurred. If it is an event for which one or more processes are waiting then the OS moves all the corresponding blocked processes to the ready state and blocked suspended processes to the ready suspended state. The OS then decides whether to continue execution of the process currently in the running state or to preempt that process for a higher priority ready process c. Memory Fault The processor encounters a virtual memory address reference for data that is not in main memory. The OS must bring in the block (i.e. page or segment) of memory containing the reference from secondary memory to main memory. The process is placed in a blocked state. After the desired block is brought into main memory the process is shifted to ready state. 2. Trap With a trap the OS determines whether the error is fatal. If so the currently running process is moved to the exit state. If the error is not fatal the OS may attempt some recovery procedure, or it may simply notify the user. It may or may not do a process switch. 3. Supervisor Call When the OS is activated by a Supervisor call from the program that is being executed e.g. for a file open instructions. This results to a transfer to a routine that is part of the OS code. Generally the use of a system/supervisor call results in placing the user process in the blocked state. Context Switching In most OS the occurrence of an interrupt does not necessarily result in a process switch. After the interrupt handler has executed the currently running process may resume execution. So only the processor state information needs to be saved when the interrupt occurs. The saving and restoring functions are performed in hardware. A process switch is more expensive in terms of performance overhead.
of the user processes. Implementing the OS as a set of processes is useful in a multiprocessor or multi-computer environment. In which some of the OS services can be shipped out to dedicated processors to improve performance.