Schedulers in OS

Schedulers in operating systems are crucial for managing process execution and resource allocation. They determine which processes run at any given time, significantly impacting system performance and responsiveness. There are three primary types of schedulers: Long-Term Scheduler, Short-Term Scheduler, and Medium-Term Scheduler.


1. Long-Term Scheduler (Job Scheduler)

Functionality: The Long-Term Scheduler, selects processes from the job queue (secondary memory) and loads them into the ready queue (main memory) for execution.

  • Process Admission: It decides which processes are admitted into the system for processing. The LTS aims to maintain an optimal level of multiprogramming by selecting a balanced mix of CPU-bound and I/O-bound processes.
  • Frequency: The Long-Term Scheduler operates less frequently compared to other schedulers, as it focuses on the overall system load and resource availability.
  • Impact on Multiprogramming: By controlling the number of processes in memory, the LTS influences the degree of multiprogramming. An optimal mix ensures that the CPU remains busy and minimizes idle time.

2. Short-Term Scheduler (CPU Scheduler)

Functionality: The Short-Term Scheduler, selects processes from the ready queue and allocates CPU time to them.

  • Process Selection: It picks one of the processes that are ready to execute and dispatches it to the CPU. This decision is typically made using a scheduling algorithm (e.g., Round Robin, Priority Scheduling).
  • Speed: The Short-Term Scheduler operates at a high frequency, often every few milliseconds, to ensure quick context switching between processes.
  • Impact on Performance: The efficiency of the Short-Term Scheduler is critical; a process with a long CPU burst time, can lead to process starvation.

3. Medium-Term Scheduler

Functionality: The Medium-Term Scheduler manages the swapping of processes in and out of main memory, particularly when processes are blocked or waiting for I/O operations.

  • Swapping: It takes processes in a running state and suspends them, moving them to secondary storage to free up memory for other processes. This operation is known as swapping.
  • State Management: The Medium-Term Scheduler helps manage the states of processes, transitioning them from running to waiting, and vice versa when resources become available.
  • Impact on Multiprogramming: By reducing the number of processes in memory, it helps maintain system responsiveness and manage the overall degree of multiprogramming.