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 are a scheduler and a dispatcher in OS?
In operating systems, the scheduler and dispatcher work together to manage process execution. The scheduler decides which process should run next, while the dispatcher actually transfers control to the selected process. Understanding their roles is crucial for comprehending how an OS efficiently manages multiple processes.
Scheduler
A scheduler is a system component that selects processes from various queues and determines their execution order. Its primary function is to decide which process runs first based on specific scheduling algorithms and system policies.
Types of Schedulers
There are three different types of schedulers, each operating at different levels of the system −
Long-Term Scheduler (Job Scheduler)
The long-term scheduler controls the degree of multiprogramming by determining which processes are admitted to the ready queue. It manages the transition of processes from the new state to the ready state, ensuring the system doesn't become overloaded with too many processes.
Medium-Term Scheduler (Swapper)
The medium-term scheduler handles swapping processes between main memory and secondary storage. It temporarily removes processes from memory when the system is overloaded and brings them back when resources become available.
Short-Term Scheduler (CPU Scheduler)
The short-term scheduler selects which process from the ready queue should be executed next by the CPU. It runs frequently and must be very fast since it directly affects system performance.
Dispatcher
The dispatcher is the module that gives control of the CPU to the process selected by the short-term scheduler. It performs the actual context switching and mode transitions required for process execution.
Functions of Dispatcher
The dispatcher performs several critical functions −
Context switching − Saves the state of the currently running process and loads the state of the next process.
Switching to user mode − Changes the processor from kernel mode to user mode for process execution.
Jumping to the proper location − Transfers control to the appropriate instruction in the user program.
Comparison
| Aspect | Scheduler | Dispatcher |
|---|---|---|
| Primary Function | Selects which process to run next | Actually gives CPU control to selected process |
| Operation Time | Takes more time (algorithm execution) | Very fast (direct context switch) |
| Type of Work | Decision making and policy implementation | Mechanism implementation |
| Frequency | Less frequent | Very frequent |
| Dependency | Independent decision maker | Depends on scheduler's selection |
How They Work Together
The scheduler and dispatcher work in sequence −
Scheduler analyzes all processes in the ready queue
Applies scheduling algorithm (FCFS, SJF, Round Robin, etc.)
Selects the most appropriate process for execution
Dispatcher performs context switching
Transfers CPU control to the selected process
Process begins or resumes execution
Conclusion
The scheduler and dispatcher are essential components of process management in operating systems. The scheduler makes intelligent decisions about which process should run next, while the dispatcher efficiently implements those decisions through context switching. Together, they ensure optimal CPU utilization and smooth multitasking operations.
