Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
Difference between dispatcher and scheduler
Next article icon

Difference between dispatcher and scheduler

Last Updated : 28 Dec, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Scheduler and the Dispatcher are the two most important terms in an operating system. which are critical in the management of processes as well as the execution of processes. While the scheduler chooses processes that must be run, the dispatcher is in charge of passing these processes to the CPU. Despite the interrelation that might be observed when comparing the roles of these elements, they serve different direct purposes, which are aimed at optimizing CPU usage. A scheduler and a dispatcher are two important concepts that are used in operating systems when it comes to multitasking and executing processes. 

What is a Scheduler? 

Schedulers are a special type of operating system software that manages process scheduling in a variety of ways. Its main function is to select the jobs that are to be submitted to the system and decide which process will run.

There are three types of schedulers, which are as follows:

  1. Long-Term (job) Scheduler: Due to the small size of the main memory, initially all the programs are stored in secondary memory. When they are loaded or stored in main memory, then they are known as processes. The long-term scheduler decides how many processes will remain in the ready queue. So, in simple words, the long-term scheduler decides the degree of multiprogramming of the system.
  2. Medium-Term Scheduler: Often a running process needs an I/0 operation that does not require CPU time. That is why when a process needs I/O operation during its execution, the operating system sends that process to a blocked queue. When that process completes its I/O operation, then it is again shifted to the ready queue . All these decisions are taken by the medium-term scheduler. Medium-term scheduling is part of swapping.
  3. Short-Term (CPU) Scheduler: When there are many processes initially in the main memory, all are present in the ready queue. Out of all these processes, only one is selected for execution. This decision is in the hands of the short-term scheduler or CPU scheduler.

Advantages of a Scheduler 

  • Optimized CPU Utilization: It helps to check that the CPU is loaded to the maximum possible extent by frequently choosing tasks to execute.
  • Fair Process Handling: Demands a fixed amount of CPU time for each process like FCFS, SJF, and RR in order to offer equal opportunity for processes in the system.
  • Process Management: Oversees the processes in different states (for instance, ready, blocked, or running).

Disadvantages of a Scheduler 

  • Complexity: They may also not be well suited for all system designs and can also be very hard to actually schedule.
  • Overhead: There are some drawbacks in maintaining the scheduler, as the latter could present some overhead to the system, and this could be especially so in a real-time environment where decisions require to be made rapidly.

Scheduler

What is a Dispatcher? 

Dispatcher is a special type of program whose work starts after the scheduler. When the scheduler completes its task of selecting a process, it is the dispatcher that moves the process to the queue it needs to go to.

The dispatcher is the module that hands over control of the CPU to the process that has been selected by the short-term scheduler.

The following things happen in this function:

  1. switching context: Cores the current process and restores the state of the process to be run next.
  2. Switching to User Mode: Makes sure that it runs in the user mode and not kernel mode, which is for security and privilege break-
  3. Jumps to the correct location in the user program from where the program can be restarted.

Advantages of a Dispatcher 

  • Fast Process Switching: Evaluates circumstances where a procedure shifts from the ready queue to the execution phase in a way that causes less delay.
  • Efficient CPU Time Allocation: Is important in making sure that processes receive CPU time, hence giving the necessary support for multitasking to occur.

Disadvantages of a Dispatcher 

  • Dispatch Latency: Although the time taken is considerably small, this lateness in dispatching the requests can slow down the system.
  • Dependent on Scheduler: The dispatcher hence cannot work on her own since she is reliant on the decisions made by the scheduler.

Difference Between Dispatcher and Scheduler

Consider a situation, where various processes are residing in the ready queue waiting to be executed. The CPU cannot execute all of these processes simultaneously, so the operating system has to choose a particular process on the basis of the scheduling algorithm used. So, this procedure of selecting a process among various processes is done by the scheduler. Once the scheduler has selected a process from the queue, the dispatcher comes into the picture, and it is the dispatcher who takes that process from the ready queue and moves it into the running state. Therefore, the scheduler gives the dispatcher an ordered list of processes which the dispatcher moves to the CPU over time.

Example - There are 4 processes in the ready queue, P1, P2, P3, P4; Their arrival times are t0, t1, t2, t3 respectively. A First in First out (FIFO) scheduling algorithm is used. Because P1 arrived first, the scheduler will decide it is the first process that should be executed, and the dispatcher will remove P1 from the ready queue and give it to the CPU. The scheduler will then determine P2 to be the next process that should be executed, so when the dispatcher returns to the queue for a new process, it will take P2 and give it to the CPU. This continues in the same way for P3, and then P4. Dispatcher

PropertiesDISPATCHERSCHEDULER
DefinitionDispatcher is a module that gives control of CPU to the process selected by short term schedulerScheduler is something which selects a process among various processes
TypesThere are no different types in dispatcher.It is just a code segment.There are 3 types of scheduler i.e. Long-term, Short-term, Medium-term
Dependency Working of dispatcher is dependent on scheduler.Means dispatcher have to wait until scheduler selects a process.Scheduler works independently. It works immediately when needed
AlgorithmDispatcher has no specific algorithm for its implementationScheduler works on various algorithm such as FCFS, SJF, RR etc.
Time TakenThe time taken by dispatcher is called dispatch latency.Time taken by scheduler is usually negligible.Hence we neglect it.
FunctionsDispatcher is also responsible for:Context Switching, Switch to user mode, Jumping to proper location when process again restartedThe only work of scheduler is selection of processes.
TasksDispatcher allocates  the CPU to the process selected by the short-time scheduler.Scheduler performs three task. Job scheduling (Long-term scheduler), CPU scheduling (Short-term scheduler) and swapping (Medium-term scheduler).
Purpose To move the process from the ready queue to the CPU To select the process and decide which process to run
 
Execution time It takes a very short execution time It takes longer execution time than dispatcher
 
Interaction The dispatcher works with the CPU and the selected process The scheduler works with the ready queue and the dispatcher
 

Conclusion 

The scheduler and the dispatcher play very important roles in AOS in that they help the operating system to coordinate the processes well. The scheduler is the one that determines what processes are executed and when, while the dispatcher is the one that swaps out those processes into the CPU. It is important to understand process or task workload and how the two are different when getting to know how an operating system deals with such processes effectively. Together, they protect the system from getting slow and unproductive and make sure that it is able to handle multitasking. 


Next Article
Difference between dispatcher and scheduler

H

himanshukumarpatel
Improve
Article Tags :
  • Operating Systems
  • GATE CS

Similar Reads

    Difference between Process and Thread
    Process and threads are the basic components in OS. Process is a program under execution whereas a thread is part of process. Threads allows a program to perform multiple tasks simultaneously, like downloading a file while you browse a website or running animations while processing user input. A pro
    7 min read
    Difference between Short-Term and Medium-Term Scheduler
    Prerequisite – Process Schedulers 1. Short-Term Scheduler : Short term scheduler is also known as CPU scheduler. Its main objective is to boost the system performance according to certain set criteria. Short term scheduler helps to select the group of processes that are ready to execute and allocate
    2 min read
    Difference between Table-driven and Cyclic Scheduling
    Clock-driven scheduling is the scheduling algorithm in which the scheduling points are determined by the clock interrupts. Clock-driven scheduling is of two types: 1. Table-driven Scheduling : In table-driven scheduling, the start timing of all tasks are precomputed and it is stored in a table at th
    2 min read
    Difference between Long-Term and Medium-Term Scheduler
    Prerequisite - Process Schedulers Long-Term Scheduler: Long-term schedulers are called job schedulers. The long-term scheduler controls the programs that are selected within the system for processing. In this, programs are found during a queue and therefore the best job is chosen as per the need it
    4 min read
    Difference between FCFS and Priority CPU scheduling
    1. First Come First Served (FCFS) : First Come First Served (FCFS) is the simplest type of algorithm. It is a non-preemptive algorithm i.e. the process cannot be interrupted once it starts executing. The FCFS is implemented with the help of a FIFO queue. The processes are put into the ready queue in
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences