1. Introduction to Schedulers
In a multiprogramming system, the CPU must efficiently manage multiple processes.
Schedulers in an Operating System (OS) decide which process to execute and when.
π‘ Why Schedulers?
- Ensure efficient CPU utilization.
- Manage process execution through scheduling queues.
- Reduce waiting time and increase throughput.
2. Types of Schedulers
There are three main types of schedulers in an OS:
Scheduler | Function |
---|---|
Long-Term Scheduler (Job Scheduler) | Controls the number of processes entering the system. |
Short-Term Scheduler (CPU Scheduler) | Selects which process gets CPU time. |
Medium-Term Scheduler (Swapper) | Temporarily removes processes from memory to free up space. |
Letβs discuss them in detail.
π 1. Long-Term Scheduler (Job Scheduler)
β
Manages process admission β decides which jobs (processes) enter the Ready Queue.
β
Controls the degree of multiprogramming (number of processes in memory).
β
Used in Batch Operating Systems (jobs are submitted in bulk).
β Example:
- If 100 users submit jobs, the Long-Term Scheduler selects only 20 to enter memory to prevent overloading.
π‘ Slow but critical! This scheduler runs infrequently but plays a key role in system performance.
π 2. Short-Term Scheduler (CPU Scheduler)
β
Decides which process gets CPU next from the Ready Queue.
β
Runs very frequently (every few milliseconds).
β
Uses scheduling algorithms like FCFS, Round Robin, Priority Scheduling.
β Example:
- If five processes are waiting in the Ready Queue, the CPU Scheduler picks one for execution.
π‘ Fastest scheduler! Runs hundreds of times per second to manage process execution.
π 3. Medium-Term Scheduler (Swapper)
β
Temporarily removes processes from RAM (Swapping).
β
Helps in memory management by reducing CPU load.
β
Suspended processes are moved to disk and resumed later.
β Example:
- If RAM is full, a background music player may be swapped out while a video editing app runs.
π‘ Used in modern OS to balance CPU and memory usage.
3. Comparison of Schedulers
Feature | Long-Term Scheduler | Short-Term Scheduler | Medium-Term Scheduler |
---|---|---|---|
Function | Selects jobs for execution | Selects process for CPU | Swaps processes in/out of RAM |
Speed | Slow (minutes) | Fast (milliseconds) | Medium (seconds) |
Runs | Infrequently | Very frequently | Occasionally |
Controls | Multiprogramming | CPU scheduling | Memory management |
Example | Job selection in batch OS | Process execution in CPU | Swapping in Virtual Memory |
4. How These Schedulers Work Together?
1οΈβ£ User submits jobs β Long-Term Scheduler selects jobs for execution
2οΈβ£ Ready Queue fills β Short-Term Scheduler picks processes for CPU execution
3οΈβ£ RAM gets full β Medium-Term Scheduler swaps out processes
4οΈβ£ Swapped processes return β Short-Term Scheduler resumes execution
β This cycle repeats, ensuring efficient CPU and memory management!
5. Conclusion
β Schedulers manage process execution at different levels (Job, CPU, Memory).
β Long-Term Scheduler controls how many processes enter the system.
β Short-Term Scheduler decides which process runs on the CPU.
β Medium-Term Scheduler swaps processes to optimize memory usage.