๐ง What is a Short-Term Scheduler?
The Short-Term Scheduler selects one process from the Ready Queue and allocates the CPU to it.
It operates very frequently, often at every context switch, I/O event, or timer interrupt.
๐ How It Fits Into the Process Lifecycle
[ Ready Queue ] --(Short-Term Scheduler)--> [ CPU ]
-
Maintains high CPU utilization
-
Picks from only processes in memory
-
Must be extremely fast and efficient
๐ฆ Characteristics of the Short-Term Scheduler
| Characteristic | Description |
|---|---|
| โก Frequency | Very high (milliseconds) |
| โฑ๏ธ Speed | Must be very fast (microseconds) |
| ๐ง Scope | Chooses only from the Ready Queue |
| ๐ Repeated Execution | Runs at every context switch or timer interrupt |
| ๐ Algorithm Based | Implements policies like Round Robin, Priority, etc. |
๐ฏ Goals of Short-Term Scheduling
| Goal | Description |
|---|---|
| โ Maximize CPU usage | Keep the CPU busy |
| ๐ Optimize performance | Reduce response/wait times |
| โ๏ธ Ensure fairness | Prevent starvation |
| ๐ง Enforce priorities | Let important processes run sooner |
๐ Trigger Events for the Short-Term Scheduler
| Event | Example |
|---|---|
| ๐ฐ๏ธ Time slice expired | Round Robin timeout |
| ๐ I/O completes | Process returns from disk read |
| ๐ชซ Process blocks | Waiting for I/O |
| ๐ Process terminates | CPU becomes free |
| ๐ New process admitted | Higher priority may preempt |
๐งฉ Scheduling Algorithms Used by the Short-Term Scheduler
| Type | Examples |
|---|---|
| ๐งฎ Non-Preemptive | FCFS, SJF |
| โก Preemptive | Round Robin, Priority, SRTF, Multilevel Queue |
โ๏ธ Real World Analogy
Imagine a CPU as a single chair, and a line of students waiting to present.
The short-term scheduler decides:
Who gets to sit next
How long they stay
Whether someone can interrupt mid-way (preemption)
๐ Real OS Example
In Linux, the Short-Term Scheduler is implemented as the CFS (Completely Fair Scheduler).
It uses a Red-Black Tree to balance load and fairness among processes.
๐ง Interview-Ready Definition:
The Short-Term Scheduler, also known as the CPU Scheduler, is responsible for selecting a process from the ready queue and allocating the CPU to it. It executes frequently and quickly, using a scheduling algorithm to optimize performance, fairness, and responsiveness.