Types of Schedulers & the Process Control Block
Press Next → or use ← → arrow keys
The Story That Explains Schedulers & PCB
And clipped to the foot of every bed is a patient file — vitals, medicines, assigned doctor. That file is the Process Control Block. Without it, every shift change would be chaos.
Schedulers answer "which process runs next?" The PCB answers "how do we remember exactly where a paused process was?" Together they make multitasking on a single CPU possible.
Five-State Process Model
Watch process P1 travel the legal path: admitted to Ready, dispatched to Running, bounced back on an interrupt or sent to Waiting for I/O, then back to Ready. Only one process runs per core at any instant.
The PCB — What & Why
A Process Control Block (also called a Task Control Block) is a per-process record the kernel keeps, storing everything needed to pause a process now and resume it later exactly where it left off — as if it never stopped.
fork().The PCB also stores priority, queue pointers and scheduling policy — the fourth job. It is created when the process is created and destroyed when it terminates: exactly one PCB per process, never before or after.
Inside a PCB — Field by Field
Identity (PID/PPID/UID), the saved CPU context (PC + registers), scheduling data, memory limits, accounting and I/O status. Save all of this and a process can be frozen and thawed perfectly.
Three Schedulers, Three Speeds
The more often a scheduler runs, the less time it can spend deciding. Long-term is slowest and rarest; short-term is fastest and constant. As frequency goes up, the decision-time budget goes down.
Each Scheduler Fires at Its Own Rate
The long-term orb crawls; the short-term orbs whizz past around a thousand times faster. That gap is why the short-term scheduler must be ruthlessly efficient — it runs while the long-term one has barely moved.
Long-Term & Short-Term Up Close
It runs every time the CPU frees up — a clock interrupt (~10 ms), an I/O wait, or a process exit. If a decision took 10 ms and the OS scheduled every 100 ms, 10% of the CPU would vanish into scheduling. Real kernels decide in microseconds. Also: the scheduler decides who runs; the dispatcher performs the switch — don't confuse them.
Common CPU-Scheduling Algorithms
| Algorithm | Selects | Preemptive? | Typical use |
|---|---|---|---|
| FCFS | Oldest process in the queue | No | Batch systems |
| SJF | Shortest next CPU burst | Optional | Batch, theory |
| Priority | Highest-priority process | Optional | Real-time systems |
| Round Robin | Next in queue, time-slice enforced | Yes | Time-sharing (UNIX, Windows) |
| Multilevel Queue | Highest non-empty queue | Yes | Systems with process classes |
Non-preemptive (FCFS, basic SJF) lets a process keep the CPU until it blocks or exits. Preemptive (Round Robin, priority with preemption) can yank the CPU away on a timer or a higher-priority arrival — the basis of responsive time-sharing.
Round-Robin With Three Processes
Each process gets a fixed 10 ms quantum on the CPU, then goes to the back of the ready queue while the next one runs. The timeline fills P1, P2, P3, P1… A shorter quantum feels snappier but adds more context-switch overhead — the classic throughput vs latency trade-off.
Medium-Term Scheduler — Swap Out & In
Under memory pressure, P3's user-space image slides out to disk and slides back later. Swapping is expensive (milliseconds), so modern systems prefer paging individual pages. Crucially, a swapped-out process keeps its PCB in kernel memory — the PCB is small and precious.
All Three Schedulers Working Together
The long-term scheduler feeds the ready queue, the short-term scheduler dispatches to the CPU, I/O sends a process to Waiting and back, and the medium-term scheduler swaps processes to disk and back. The pipeline never stops.
The Three Schedulers Compared
| Property | Long-Term | Short-Term | Medium-Term |
|---|---|---|---|
| Also called | Job Scheduler | CPU Scheduler / Dispatcher | Swapper |
| Speed | Slowest | Fastest | Medium |
| Frequency | Seconds–minutes | Milliseconds | Occasional |
| Transition | NEW → READY | READY → RUNNING | READY ↔ SUSPENDED |
| Controls multiprogramming | Yes | No | Yes |
| In time-sharing OS? | Rarely | Always | Sometimes |
| Goal | Good process mix | Max CPU use, low latency | Relieve memory pressure |
Context Switching With the PCB
The Textbook Is the Real Thing — task_struct
Linux's PCB is a kernel struct called task_struct. The Galvin fields map almost one-to-one onto it — the textbook is not academic fluff, it's what real kernels implement.
| Galvin PCB field | Linux task_struct | Notes |
|---|---|---|
| PID | pid, tgid | Process & thread-group id |
| State | state | TASK_RUNNING, TASK_INTERRUPTIBLE… |
| CPU context | thread_struct | Saved registers & PC |
| Memory info | mm_struct *mm | Address space, page tables |
| Open files | files_struct *files | File-descriptor table |
| Priority | prio, se | CFS scheduling entity |
| Accounting | utime, stime | User/system CPU time |
ps -o pid,ppid,stat,pri,etime,comm reads these fields for every process, and
cat /proc/<pid>/status dumps a live snapshot of one task's task_struct.
Seven Ideas Worth Remembering
Deciders and the Memory That Serves Them
The three schedulers decide which process runs and when; the PCB remembers exactly where each one paused. Together — with the dispatcher performing each context switch — they turn one CPU into the illusion of many.
Study the CPU-scheduling algorithms in depth — FCFS, SJF, priority, Round Robin, and multilevel-feedback queues — with their turnaround, waiting and response-time metrics. Then explore process synchronisation and semaphores.
🗓️ End of tutorial · Press ← to review, or click Restart