Operating Systems6h estimated

CPU Scheduling

Difficulty
Importance

The problem

There are usually more runnable threads than CPU cores, so the operating system must decide, many times per second, which thread gets to run next — a decision that determines whether the system feels responsive or sluggish under load.

Why now

Processes and threads establish that many independent units of execution exist; scheduling is the missing decision procedure for sharing a scarce resource (CPU time) among them, without which 'many threads' would just mean whichever one happened to grab the CPU first, forever.

Mental model

A scheduler is a queue-management policy: which waiting thread goes next, and for how long, before being paused and put back in line. Round-robin gives everyone a fair fixed slice; priority scheduling lets some threads jump the queue; both are just different rules layered on top of the same waiting-queue idea.

Requires

Helps

Unlocks

Used in

Projects

  • Simulate round-robin scheduling on paper for five processes with given burst times, computing average wait time
  • Compare round-robin and shortest-job-first scheduling on the same workload and explain why their average wait times differ

Examples

  • A video call app is typically given higher scheduling priority than a background file indexer, so audio doesn't stutter
  • Kubernetes deciding which node runs a new pod is conceptually the same problem as an OS deciding which core runs a new thread

Resources

Mastery checklist