Learning outcomes
- Differentiate between long‑, medium‑ and short‑term schedulers and describe the contents of a process control block.
Differentiate between long-, medium-, and short-term schedulers and describe the contents of a Process Control Block (PCB).
In a multiprogramming operating system, several processes may exist at the same time. Some are waiting to enter memory, some are ready for execution, some are waiting for I/O, and one may be running on the CPU. The operating system therefore needs mechanisms to select processes at different stages. These selection mechanisms are called schedulers.
Along with scheduling, the operating system must also maintain complete information about every process. This information is stored in a data structure called the Process Control Block (PCB). Without the PCB, the operating system would not be able to stop, resume, schedule, or manage a process correctly.
Schedulers decide which process should move forward. The PCB stores all essential information about that process.
Process management in an operating system does not happen at only one stage. A process may first be admitted into the system, then selected for CPU execution, and later even be removed from memory and brought back again. Since these tasks are different in purpose and frequency, operating systems use different schedulers.
Also called the job scheduler, it decides which jobs should be admitted into the system for execution. It selects processes from the job pool on secondary storage and loads them into memory.
Also called the CPU scheduler, it selects one process from the ready queue and allocates the CPU to it. This scheduler is central to CPU multitasking.
Associated with virtual memory and swapping. It temporarily removes a process from main memory to reduce congestion and later brings it back.
| Scheduler | Main Function | Execution Frequency | Speed Requirement |
|---|---|---|---|
| Long-Term | Admits jobs into main memory | Less frequent (minutes/seconds) | Moderate |
| Short-Term | Selects process for the CPU | Very frequent (milliseconds) | Very Fast |
| Medium-Term | Swaps processes in and out | Occasional | Moderate |
Each process in the operating system is represented by a Process Control Block (PCB), sometimes called a Task Control Block. It is the core data structure that stores all essential, unique information about a specific process.
The PCB is the "ID badge and medical chart" for a process. It stores everything the OS needs to pause a process, go do something else, and restart it later without losing progress.
A context switch occurs when the CPU changes from one process to another. During this operation, the state of the currently running process is saved into its PCB, and the saved state of the next process is loaded from its respective PCB.
Because of this, the PCB is central to multitasking. Without it, the OS would not know where to resume a suspended process.
Consider three processes: P1, P2, and P3.
An OS uses different schedulers because process selection occurs at varying frequencies and stages:
A Process Control Block (PCB) is the data structure representing a process. It tracks everything needed to manage execution, including: Process state, Program Counter, CPU registers, Memory limits, and I/O status.
The PCB is heavily utilized during a context switch. When the CPU swaps processes, the outgoing process writes its current progress to its PCB, and the incoming process reads its progress from its own PCB to resume execution seamlessly.