π§ What is a Scheduler?
A Scheduler in an Operating System is the component that selects which process gets access to the CPU or resources next, based on a defined policy or algorithm.
In short: it decides what to run, when, and for how long.
π Types of Schedulers
There are 3 primary types, each working at a different stage of process lifecycle:
1. π§± Long-Term Scheduler (Admission Scheduler)
-
Decides which jobs/processes to admit into the system (i.e., into memory and ready queue).
-
Controls degree of multiprogramming.
-
Used mostly in batch systems or when the OS is under heavy load.
| Role | Admit new processes from Job Queue β Ready Queue |
| Frequency | Infrequent |
| Controlled By | OS policy (e.g., memory limits, system load) |
2. β‘ Short-Term Scheduler (CPU Scheduler)
-
The most important scheduler in modern OS.
-
Decides which ready process gets the CPU next.
-
Operates very frequently (milliseconds or less).
-
Must be fast and efficient.
| Role | Picks from Ready Queue β CPU |
| Frequency | Very high (every context switch, timer interrupt) |
| Examples | Round Robin, Priority Scheduling, SJF, etc. |
3. π Medium-Term Scheduler
-
Optional β used in swapping systems.
-
Temporarily removes processes from memory (RAM) and puts them on disk to free up space.
-
Later, it can resume these processes.
| Role | Moves processes in and out of memory (Ready β Suspended) |
| Used When | System is low on RAM |
| Rare | Used in embedded/legacy or highly loaded systems |
π― Goals of Scheduling
| Goal | Description |
|---|---|
| β±οΈ Maximize CPU Utilization | Keep CPU as busy as possible |
| βοΈ Fairness | No starvation |
| π Maximize Throughput | Complete as many processes as possible |
| π°οΈ Minimize Turnaround Time | From submission β completion |
| β Minimize Waiting Time | Time spent in ready queue |
| π Minimize Response Time | First visible output for interactive users |
π§© Real World Example
Letβs say 5 processes are in the ready queue:
P1, P2, P3, P4, P5
Depending on the scheduling algorithm:
-
FCFS β pick
P1 -
Priority β pick the one with highest priority
-
Round Robin β rotate every
xms -
SJF β pick the one with shortest burst time
The CPU Scheduler (short-term) handles all this, extremely fast.
βοΈ CPU Scheduling Flow Diagram
[ Ready Queue ] β Scheduler β [ CPU ]
β
Based on Scheduling Algorithm
π§ Interview-Ready Definition:
A Scheduler is an OS module that makes decisions about which process or task to run next, based on priority, fairness, and system efficiency. It can be long-term (job admission), short-term (CPU allocation), or medium-term (memory swapper).