Skip to content

OS PrimerOperating systems, in depth, for senior interviews

Build the mental models first, then learn why they matter in real systems and how interviewers probe them.

Chapters ​

I. Foundations

1What an OS IsKernel vs user mode, privilege rings · System calls: the mechanism and the cost · Interrupts, exceptions and traps · Monolithic vs microkernel · The vDSO2Processes & Threadsfork / exec / wait · Process states and the PCB (task_struct) · Threads vs processes: what is shared · Signals, SIGTERM vs SIGKILL, graceful shutdown · Zombies, orphans, reparenting, process groups and sessions3Linking, Loading & Program StartupELF: sections and segments · Static vs dynamic linking · PLT / GOT and lazy binding · LD_PRELOAD and symbol interposition · How exec builds the address space

II. Memory

4Virtual MemoryPages, frames and address translation · Multi-level page tables · The TLB, PCID and shootdowns · Page faults and demand paging · Huge pages5Kernel Memory Managementmmap: file-backed vs anonymous · Copy-on-write and fork · Page cache and reclaim (LRU lists, kswapd) · Swap, overcommit and the OOM killer · RSS vs VSZ vs PSS6User-Space AllocatorsHow malloc gets memory (brk, mmap) · Free lists, size classes, arenas · Fragmentation: internal and external · jemalloc / tcmalloc / mimalloc · Why RSS does not shrink after free()7CPU Caches & NUMACache hierarchy and latency numbers · Cache lines, locality, prefetching · Coherence (MESI) and false sharing · NUMA topology and locality · Data-oriented design in practice

III. CPU & Concurrency

8Scheduling & Context SwitchesFCFS, SJF, round robin, MLFQ · Linux CFS and EEVDF · Context switch: what is saved and what it costs · Priorities, nice, real-time classes · CPU affinity and cgroup CPU limits9Concurrency I: Locks & DeadlockRace conditions and critical sections · Mutexes, spinlocks, condition variables · Semaphores and monitors · Deadlock: conditions, prevention, detection · Priority inversion10Concurrency II: Atomics & Memory OrderingAtomic operations and CAS · Memory ordering: acquire / release / seq_cst · The ABA problem · futex: how user-space locks block · Reader-writer locks and RCU11Inter-Process CommunicationPipes and FIFOs · Unix domain sockets and fd passing · Shared memory · Message queues · Choosing an IPC mechanism

IV. I/O & Storage

12I/O ModelsBlocking vs non-blocking vs async · select / poll / epoll (level vs edge triggered) · io_uring · Zero-copy: sendfile, splice · The C10K problem and event loops13File SystemsInodes, directories, links · File descriptors and the open file table · The page cache and write-back · fsync, fdatasync, O_DIRECT · Journaling and crash consistency14The Storage StackThe block layer and I/O schedulers · HDD vs SSD vs NVMe · SSD internals: FTL, write amplification · What durability actually guarantees · RAID basics15Networking in the KernelSockets and socket buffers · TCP states, TIME_WAIT · SYN and accept queues, backlog · From syscall to NIC: the packet path · Interrupts, NAPI, RSS, kernel bypass

V. Systems

16Time & TimersWall clock vs monotonic clock · clock_gettime and the vDSO · Timer interrupts, tickless kernels · hrtimers and timer wheels · Clock skew and NTP17Security & IsolationUsers, permissions, capabilities · seccomp · ASLR, stack canaries, NX · Spectre, Meltdown and KPTI · Why syscalls got more expensive18Virtualization & ContainersHypervisors: type 1 vs type 2 · Hardware virtualization and nested paging · Namespaces · cgroups · Containers vs VMs vs microVMs19Performance & DebuggingThe USE method · perf and flame graphs · strace, ltrace, bpftrace · Reasoning about tail latency · Latency numbers every engineer should know

Capstone & Appendix

CWhat Happens When……you run ./a.out · …you call read() on a file · …a server accepts a connection · …a process runs out of memoryAInterview Question BankAll questions, indexed by chapter