Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Last Updated: Mar 27, 2024

Difference between Dispatcher and Scheduler

Author Jainish Patel
0 upvote
gp-icon
Operating system track
Free guided path
14 chapters
83+ problems
gp-badge
Earn badges and level up
Operating Systems

Introduction

As we all know, the modern generation’s computer is way better than earlier generations in terms of multitasking. The improvements in multi-tasking performance are due to the efficient scheduling of the process assigned to a computer. Scheduling further relies on two major concepts: Scheduler and DispatcherThe scheduler selects a process from a list of processes by applying some process scheduling algorithm. On the other hand, the dispatcher transfers the process selected by the short-term scheduler from one state to another.

In this article, we’ll be discussing what exactly the scheduler and dispatcher are in detail. 

Multiprogramming vs Multitasking

Scheduler

A scheduler is essentially a software system. It can handle the scheduling of processes in a variety of ways. A scheduler's major responsibility is to select a process from several processes that need to be entered into a system for execution.  

Types of scheduler

Types of Scheduler

Long-term Scheduler

Due to the small size of the main memory(RAM), we initially store all of the programs in the secondary memory. These are known as processes when they are loaded or kept in the main memory. A long-term scheduler is granted control over how many processes must remain in the ready queue. To put it another way, a long-term scheduler is in charge of determining the amount of multiprogramming that is accessible in a system.

Long Term Scheduler

Short-term Scheduler

When there are many processes in the main memory, all of them appear in the ready queue at first. However, only one process must be chosen for execution from among all of these processes. All of these decisions are handled by a short-term scheduler.

Short Term Scheduler 

Medium-term Scheduler (swapper)

The majority of the time, a running process needs an I/O operation that does not involve the use of a CPU. As a result, when an I/O operation is required during the execution of a process, the OS (Operating System) moves the targeted process from the running queue to the blocked queue. We must relocate a process back to the ready queue whenever it completes its initial I/O activity. All of these decisions are handled by a medium-term scheduler. Swapping is essentially the practice of medium-term scheduling.

Medium Term Scheduler

You can also read about layered structure of operating system, Open Source Operating System.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Dispatcher

It's a unique form of application that only comes in after the scheduler. The dispatcher then takes that targeted process to its specified queue/state when the scheduler has finished picking its processes. A dispatcher is a module that allows a process to have complete control over the CPU (after the short-term scheduler finally selects it). This function needs the following:

  • Context switching is an activity of switching between processes in the CPU.
  • Switching to the user mode
  • Jumping into the user program’s proper location for restarting that given program.

 

Let’s understand the Dispatcher and Scheduler by an example

P1, P2, P3, P4, P5, and P6 are the six processes in the ready queue, with arrival times of t0, t1, t2, t3, t4, t5 respectively. The scheduling technique is based on the First in First Out (FIFO) principle. 

FIFO

Because P1 was the first to arrive, the scheduler will determine that it should be the first process to run, and the dispatcher will remove P1 from the ready queue and pass it to the CPU. When the dispatcher returns to the queue for a new process, it will take P2 and give it to the CPU, because the scheduler has determined that P2 is the next process that should be executed. The same procedure is followed for P3 till P6.

FCFS Scheduling

Difference between Scheduler and Dispatcher

Now that we've learned about the Scheduler and Dispatcher, let's now discuss the difference between them:

Dispatcher v/s Scheduler

 

Check out this problem - Queue Implementation

Frequently Asked Questions

Why does a short-term scheduler run more frequently than a long-term scheduler?

Because the creation of a process is less frequent than the switching of the CPU from one process to another. As a result, short-term schedulers run more frequently than long-term schedulers.

Does every operating system have all the types of schedulers?

No, Windows and Unix do not have a long-term scheduler since processes are immediately shifted to the ready queue as soon as they are formed in these operating systems.

What is the main difference between the short-term scheduler and the long-term scheduler?

A short-term scheduler picks a process from the ready queue and assigns it to the CPU, whereas a long-term scheduler transfers a process into the ready queue and so occurs less frequently.

Conclusion

This article discusses the concept of the scheduler, the concept of the dispatcher, and also the difference between them.

Recommended Readings: 


Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, Uber, Microsoft, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Previous article
Measure the Time Spent in Context Switch
Next article
FCFS Scheduling
Guided path
Free
gridgp-icon
Operating system track
14 chapters
83+ Problems
gp-badge
Earn badges and level up
Live masterclass