Operating System - Long term,medium term and short term schedulers
What are Schedulers in OS?
Schedulers are components of the operating system that decide which processes should be executed and when. They manage process states: new, ready, running, waiting, and terminated.
There are three types of schedulers:
1. Long-Term Scheduler (Job Scheduler)
Purpose:
-
Decides which processes are admitted into the system (from job pool to ready queue).
-
Controls the degree of multiprogramming (i.e., how many processes are in memory).
-
Low frequency of execution.
-
Selects few processes at a time.
-
Runs when a process terminates or exits.
Example:
-
In a batch processing system, it chooses 5 jobs from 1000 waiting in a job queue to load into memory.
2. Medium-Term Scheduler (Swapper)
Purpose:
-
Temporarily removes (swaps out) processes from memory to reduce load or free space.
-
Later, swaps in the processes to continue execution.
Key Features:
-
Manages suspended processes.
-
Helps in load balancing and memory optimization.
-
Not always present in all systems.
Example:
-
A background process that uses too much memory is swapped to disk to allow a foreground task to run.
3. Short-Term Scheduler (CPU Scheduler)
Purpose:
-
Selects which ready process will run next on the CPU.
-
Executes very frequently and quickly (milliseconds).
-
Highest frequency of execution.
-
Directly affects system responsiveness and performance.
-
Must be fast and efficient.
Example:
-
In Round Robin scheduling, it selects the next process after every time quantum.
Comparison Table
Feature | Long-Term Scheduler | Medium-Term Scheduler | Short-Term Scheduler |
---|---|---|---|
Also Called | Job Scheduler | Swapper | CPU Scheduler |
Main Function | Selects processes to admit | Swaps processes in/out of memory | Selects next ready process for CPU |
Execution Frequency | Low | Medium | High |
Speed | Slow | Moderate | Fast |
Controls | Degree of multiprogramming | Memory and load balancing | CPU allocation |
Presence | Present in batch systems | Optional (depends on OS) | Always present |
Example Action | Choose 5 of 100 jobs to run | Move a suspended process to disk | Pick the next ready process |