Dispatcher in Operating System. Write Functions of Dispatcher

Dispatcher provides control of the CPU to the process picked by the short-term scheduler. When the scheduler finishes its task of selecting a process, then the dispatcher takes that process to the destination state. 

For example,

Suppose there are 5 processes P1, P2, P3, P4, and P5

The arrival times of these processes are T1, T2, T3, T4, and T5.

Here, FIFO (first in first out) algorithm is used. So, P1 comes first, and then the scheduler will choose that it is the first process that is going to execute. The dispatcher will eliminate P1 from ready queue and take it to the CPU.

Now, the scheduler will select P2, which will be executed after P1. The dispatcher removes P2 from the ready queue and gives it to the CPU.

This carries on in a similar way for processes P3, P4, and P5. 

This is how a dispatcher works. The scheduler provides the dispatcher with an ordered list of processes that the dispatcher gives to the CPU. The dispatcher does many tasks such as memory mapping, context switching and setting up user registers.

Functions of Dispatcher

  • Switching Context
  • Switching to User mode
  • Jumping to the proper location in the user program to reboot that program
  • Managing dispatch latency (time consumed by dispatcher is referred as dispatch latency)