Operating Systems Advanced: Scheduling, Deadlocks, and Concurrency
Lesson Promise
By the end of this lesson, you will understand how CPU schedulers choose which process runs next, the four conditions for deadlock and how to prevent them, and the concurrency primitives that protect shared data.
Narration Draft
Part 1 — CPU Scheduling (6:00) Why scheduling matters. FCFS, SJF, Round Robin. The convoy effect. Multilevel feedback queues. Linux's CFS (red-black tree, virtual runtime).
Part 2 — Deadlock Theory (6:00) The four Coffman conditions. Prevention strategies. Banker's algorithm for avoidance. Detection and recovery.
Part 3 — Concurrency Primitives (7:00) Mutexes, semaphores, condition variables. Race conditions and the lost-update problem. Lock-free alternatives.
Part 4 — Virtual Memory Deep Dive (5:00) Page tables, TLB, page faults. Demand paging. Swapping.
Part 5 — Real-World Patterns (4:00) Lock ordering to prevent deadlocks. Read-write locks. Thread pools.
Visual Sequence
- Scheduler decision diagram: ready queue → which process next?
- CFS red-black tree: insert by virtual runtime, pick leftmost
- Deadlock cycle: P1→R1→P2→R2→P1
- Banker's algorithm: safe state simulation
- Race condition: two threads incrementing a shared counter
Companion Material
Related articles
Deadlocks: Conditions and Prevention
How deadlocks form under four necessary conditions, and the strategies (prevention, avoidance, detection) to manage them.
Concurrency Basics: Locks and Semaphores
How threads share memory safely using mutexes, semaphores, condition variables, and the race conditions they prevent.
Scheduling: How the OS Chooses What Runs Next
CPU scheduling algorithms from first-come-first-served to modern multi-level feedback queues and the Completely Fair Scheduler.
More in Operating Systems
Operating Systems Foundations
A beginner walkthrough of what an OS does, how processes work, and how processes differ from threads.
DetailsOperating Systems Intermediate
Dive into system calls, concurrency with locks and semaphores, process management, and virtual memory.
DetailsWhat Happens During a read() System Call
A planned trace separates the userspace wrapper, kernel entry, descriptor lookup, cached data, I/O wait, and return value.
DetailsNew lessons by email
Get new articles and notes on the systems behind everyday software.
One technical dispatch per week. No noise.
Not started
Sign in to save your learning progress.