Dispatcher
- It is a component of operating system involved in CPU scheduling.
- Dispatcher is a program responsible for assigning the CPU to the process, which has been selected by the short-term scheduler.
- Dispatching a process involves three functions:
- Context switching
- Switching to user mode from monitor mode
- Jumping to the proper location in the user program to restart that program.
1. Context Switching:
It means switching of CPU from one process to another.
- This involves saving the state of old process (one that was running previously) and loading the saved state, if any, for this ready process (scheduled to be run now).
- There will be no saved state if this ready process has been newly created and is being allocated to CPU for the first time.
- If this ready process was previously in the blocked state (because of I/O), then the process registers and memory must be loaded with all the previously saved data.
2. Switching to user mode from monitor mode
A user process must be run in user mode. For this it is necessary to change its mode from monitor to user.
3. Restart the execution of process
- The execution of process should be restarted by jumping to the instruction that was supposed to be executed when this process was last interrupted.
- In case, if the process is being executed for the first time after creation, jump should be made to the first instruction.