Difference between dispatcher and scheduler

1. Scheduler
  • Role: Selects processes from the ready queue and loads them into memory for execution.

  • Purpose: Aims to balance system resources and optimize performance (e.g., maximize CPU utilization, minimize response time).

  • Frequency: Runs relatively less frequently.

  • Types of Scheduling:

    • Long-Term Scheduler (Job Scheduler): Decides which jobs or processes from the job pool are admitted into the ready queue.

    • Short-Term Scheduler (CPU Scheduler): Selects which of the ready processes should be executed next by the CPU. It's invoked frequently.

    • Medium-Term Scheduler: Often involved in swapping processes out of main memory (and back in) to manage the degree of multiprogramming.

  • Action: Deals with queues and policies for process selection.

2. Dispatcher
  • Role: Gives control of the CPU to the process selected by the Short-Term Scheduler.

  • Purpose: Facilitates context switching and allows the selected process to run.

  • Frequency: Runs very frequently, typically whenever a process needs to be switched out for another.

  • Functionalities:

    • Context Switch: Saves the state of the old process and loads the saved state of the new process.

    • Switching to User Mode: Changes the CPU mode from kernel mode to user mode.

    • Jumping to the proper location in the user program: Restarts the user program at the correct instruction.

  • Dispatch Latency: The time it takes for the dispatcher to stop one process and start another running. It's the time taken during context switching.

  • Action: Provides the mechanism for actual execution of the selected process.