Operating Systems
A free operating system course for beginners, in teaching order. It starts with what an OS does and the main kinds of systems, then follows a system call from an application into the kernel. Each lesson works one example by hand, the way an exam question would.
The OS concepts come next: processes and threads, CPU scheduling, synchronization and deadlocks, memory management and page replacement, then files, storage, disk scheduling and protection. Read it top to bottom as an operating system tutorial, or jump to the topic you need.
Operating systems
Understand what happens when code executes. An operating system bridges software and hardware.
- Introduction to Operating Systemslesson
Services, resources, protection, and the path from an application to hardware.
- Operating System Serviceslesson
The nine services an OS provides, the system calls that reach them, and the system programs built on top.
- Types of Operating Systemslesson
Batch, time-sharing, real-time, distributed, mobile, and embedded systems.
- Multiprocessor Systemslesson
SMP vs AMP, tightly and loosely coupled systems, UMA vs NUMA, and coherent caches.
- Kernel, User Mode, and System Callslesson
Privilege levels, APIs, traps, kernel services, and return to user mode.
- Interrupts in OSlesson
Hardware interrupts, traps and exceptions, the vector table, priority and nested interrupts.
- Monolithic Kernelslesson
One address space for every subsystem: why calls are cheap and why any driver bug is a kernel bug.
- Microkernelslesson
Keeping only address spaces, threads, and IPC privileged, and why IPC cost decides the design.
- Operating System Boot Processlesson
Reset vector to init: the firmware handoff, why a bootloader exists, and Secure Boot's chain of trust.
- Distributed Operating Systemslesson
The transparency goals, why partial failure defeated the single-system image, and what replaced it.
Processes, threads, and CPU scheduling
Follow a program as the OS creates it, schedules it, pauses it, and lets multiple threads share work.
- Processes, Threads, and CPU Schedulinglesson
Process state, threads, context switches, ready queues, and scheduling decisions.
- Multithreading Modelslesson
Many-to-one, one-to-one, many-to-many and two-level: how user threads map onto kernel threads.
- Thread Poolslesson
Reuse a fixed set of worker threads fed by a task queue, and size the pool for the workload.
- Process States and the PCBlesson
New, ready, running, waiting, and terminated states plus the data saved during a switch.
- Context Switching in OSlesson
Save one process's registers, load the next one's, and count the time lost while neither runs.
- Types of Schedulers in OSlesson
Long-, short- and medium-term schedulers: who is admitted, who runs next, and who is swapped out.
- fork() System Calllesson
One call, two returns: what the child copies, 2ⁿ processes from n forks, and fork–exec–wait.
- CPU Scheduling Algorithmslesson
First-come-first-served, shortest-job-first, priority, round robin, and response-time trade-offs.
- Multiprocessor Schedulinglesson
SMP vs AMP, per-CPU run queues, processor affinity, and push and pull migration.
- Earliest Deadline First Schedulinglesson
Dynamic deadline priorities, the 100% utilisation bound, and why EDF collapses under overload.
- Deadline Monotonic Schedulinglesson
Fixed priority ordered by relative deadline, with exact response time analysis.
- Real-Time Operating Systemslesson
Hard, firm, and soft deadlines, WCET, and the priority inversion that stalled Mars Pathfinder.
- FCFS Schedulinglesson
Run processes in arrival order, work out waiting and turnaround times, and meet the convoy effect.
- Shortest Job First Schedulinglesson
Pick the shortest ready burst next, and see why the optimal average wait needs a length nobody knows.
- Round Robin Schedulinglesson
Give every process one time quantum in turn, and see how the size of the quantum decides the result.
- Priority Schedulinglesson
Run the most important ready process first, and stop low priorities starving with aging.
- Lottery Schedulinglesson
Give each process tickets and draw one per quantum for a proportional share of the CPU.
- Multilevel Feedback Queue Schedulinglesson
Learn each process's behaviour from how it uses its quantum, and move it between queues.
- Completely Fair Scheduler (CFS)lesson
Linux's weighted fair scheduler: vruntime, nice weights, and a red-black tree that always runs the task furthest behind.
- Inter-Process Communicationlesson
Pipes, shared memory, message queues, and sockets.
Synchronization and deadlocks
See why shared data can become incorrect and how operating systems coordinate threads and processes.
- Race Conditions and Critical Sectionslesson
Identify interleavings that produce wrong results and isolate the code that needs protection.
- Peterson's Solutionlesson
Two flags and a turn variable give two processes mutual exclusion in software, and why modern CPUs break it.
- Bakery Algorithmlesson
Lamport's take-a-number solution to the critical-section problem for n processes, with ties broken by process id.
- Test-and-Set and Spinlockslesson
The atomic instruction behind every lock, the spinlock it builds, and why plain test-and-set can starve a CPU.
- Mutexes, Semaphores, and Monitorslesson
Control access to shared resources and coordinate producers with consumers.
- Producer Consumer Problemlesson
A bounded buffer guarded by three semaphores so neither side runs past the other.
- Readers Writers Problemlesson
Many readers share the data, a writer needs it alone, and the first fix starves writers.
- Dining Philosophers Problemlesson
Five forks, five philosophers, and the circular wait that freezes the table until one rule breaks it.
- Sleeping Barber Problemlesson
One barber, a few waiting chairs, and the semaphores that stop wake-ups getting lost.
- Cigarette Smokers Problemlesson
Wake exactly the smoker who can use two ingredients, without changing the agent.
- Deadlockslesson
Mutual exclusion, hold-and-wait, no preemption, circular wait, prevention, avoidance, and recovery.
- Banker's Algorithmlesson
Deadlock avoidance: grant a request only if some order still lets every process finish.
Memory management
Learn how the OS gives every process a private address space while using a limited amount of physical memory.
Address spaces
How a process gets memory that looks private and contiguous when the hardware offers neither.
- Memory Hierarchylesson
Registers to tape: why each level is bigger and slower, and how hit ratio sets the access time.
- Memory Management and Virtual Memorylesson
Allocation, paging, page tables, translation, page faults, and replacement.
- Virtual Memorylesson
Give every process a private address space larger than RAM, translated page by page on demand.
- Swapping in OSlesson
Roll whole processes out to the backing store and back in, and calculate what each swap costs.
- Segmentation and Paginglesson
Divide addresses into logical regions or fixed-size pages and compare their costs.
- Page Table Structureslesson
Why one flat table per process does not fit, and the three layouts that shrink it.
- Multilevel Paginglesson
Page the page table so unmapped regions cost one empty outer entry.
- Hashed Page Tablelesson
Hash the page number into a bucket so the table grows with mapped pages only.
- Inverted Page Tablelesson
One entry per physical frame, shared by every process, and the lookup cost that brings.
- Translation Lookaside Buffer (TLB)lesson
Cache recent translations so most memory accesses skip the page-table walk.
- Demand Paginglesson
Load a page only when it is first touched, and work out what each page fault costs.
Fragmentation
Free memory that cannot be used. Start with the overview, then take each kind on its own — they have different causes, different sizes and different cures.
- Memory Fragmentation and Compactionoverview
The two wastes, how they differ, and when sliding blocks together is possible at all.
- Internal Fragmentationlesson
Waste inside a block you were given: under one page per allocation, half a page on average.
- External Fragmentationlesson
Enough free memory in total, no single run long enough to use it.
Allocation strategies
Given a list of free holes and a request, which hole do you take? Start with the overview, then take each strategy on the same hole list so the outcomes compare directly.
- Memory Allocation Algorithmsoverview
Four placement rules on one hole list: searches, leftovers and failures compared.
- First Fitlesson
Take the first hole that fits and stop scanning: short searches, usable leftovers.
- Best Fitlesson
Take the tightest hole: big holes survive for big requests, slivers pile up.
- Worst Fitlesson
Take the largest hole on purpose, and have none left when a large request comes.
- Next Fitlesson
Resume the scan where the last one ended instead of restarting at the front.
Page replacement
When memory is full and a new page is needed, something resident has to go. Start with the overview, then take the four algorithms in turn — each is traced on the same reference string, so the fault counts compare directly.
- Page Replacement Algorithmsoverview
How the OS chooses a resident page to evict when memory is full.
- Optimal Page Replacementlesson
Evict the page needed furthest ahead — the floor no real algorithm can beat.
- FIFO Page Replacementlesson
Evict the oldest arrival, and meet Belady's anomaly.
- LRU Page Replacementlesson
Evict the least recently used page, and why exact LRU is unaffordable.
- Clock Page Replacementlesson
Second chance: one free hardware bit buys LRU's fault count at FIFO's cost.
- Thrashing in OSlesson
When every process faults on its next access, the CPU idles on disk, and the working set explains why.
Files, storage, I/O, and protection
Complete the picture with persistent data, device communication, access control, and isolated execution.
Files on disk
How data is laid out on a device, and how the system finds it again.
- File Systemslesson
Files, directories, metadata, allocation, free-space tracking, and journaling.
- File Access Methodslesson
Sequential, direct and indexed access, and how many disk reads each lookup costs.
- File Allocation Methodslesson
Contiguous, linked and indexed allocation, compared by what it costs to reach a file's last block.
- Inodes in OSlesson
The per-file record of size, owner and block pointers, kept apart from the name.
- Disk Managementlesson
Formatting, partitions, the boot block, bad-block sparing, and swap space.
- Directory Structurelesson
Single-level to general graph: paths, links, and deletion by link count.
- RAID Levelslesson
Striping, mirroring and XOR parity: RAID 0, 1, 5, 6 and 10 compared.
Disk scheduling algorithms
Seek time dominates a spinning disk, so the order requests are served in decides the cost. Start with the overview, then take each policy on the same queue.
- Disk Scheduling and I/Ooverview
How a request reaches the device, and why the order it is served in decides the cost.
- Device Driverslesson
How a driver turns a generic read into register writes, and why interrupts and DMA both exist.
- Spooling and Bufferinglesson
Single, double and circular buffers, and the print spooler that shares one device.
- FCFS Disk Schedulinglesson
Serve requests in arrival order, with no reordering at all.
- SSTF Disk Schedulinglesson
Always take the nearest pending request, and the starvation that buys.
- SCAN Disk Schedulinglesson
Sweep to the edge of the disk and reverse, like a lift.
- C-SCAN Disk Schedulinglesson
Sweep in one direction only, jumping back without serving.
- LOOK Disk Schedulinglesson
Turn at the last request rather than at the disk edge.
- C-LOOK Disk Schedulinglesson
One-directional LOOK: jump to the lowest request, not to zero.
Protection and isolation
Who is allowed to touch what, and how one machine safely runs another inside itself.