Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
What is dispatcher and difference between dispatcher and scheduler?
The dispatcher is a crucial component of the operating system that works after the scheduler has made its decision. It gives control of the CPU to the process selected by the short-term scheduler by performing the actual context switching and transferring CPU control to the chosen process.
Functions of Dispatcher
The dispatcher performs several critical functions to transfer CPU control −
Context switching − Saving the current process state and loading the selected process state.
Switching to user mode − Changing from kernel mode to user mode for process execution.
Jumping to the proper location − Setting the program counter to resume execution at the correct instruction.
Dispatch latency − The time taken to stop one process and start another is called dispatch latency.
Difference Between Scheduler and Dispatcher
| Aspect | Scheduler | Dispatcher |
|---|---|---|
| Function | Decides which process to execute next | Actually transfers CPU control to selected process |
| Operation | Uses scheduling algorithms (FCFS, SJF, RR, etc.) | Performs context switching and mode changes |
| Time Involvement | Takes time to analyze and select process | Should be as fast as possible to minimize overhead |
| Process State | Works with processes in ready state | Moves process from ready to running state |
| Type | Policy mechanism (what to do) | Implementation mechanism (how to do) |
Role of Dispatcher in CPU Scheduling
The dispatcher plays a vital role in CPU scheduling by acting as the bridge between scheduling decisions and actual process execution. When the scheduler selects a process, the dispatcher must −
Save the context of the currently running process (if any)
Load the context of the newly selected process
Switch from kernel mode to user mode
Jump to the proper instruction in the user program
The dispatch latency is the time consumed by this entire switching process. Since dispatching occurs frequently in multitasking systems, minimizing dispatch latency is crucial for system performance. Modern operating systems optimize dispatcher code to reduce this overhead and improve overall system responsiveness.
Conclusion
The dispatcher is the execution component that works after the scheduler's decision-making process. While the scheduler determines which process should run next, the dispatcher actually performs the context switch to make it happen. Together, they enable efficient CPU scheduling and multitasking in modern operating systems.
