Highlights

Contents

Part I
01

OS fundamentals

An operating system turns shared hardware into controlled resources for programs. Without a protected boundary, one process can overwrite another process or keep every other task from running. We will move from the user program through the kernel to the hardware and compare the kernel designs that place services on that path.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1OS fundamentals2Processes3Fork, exec and threads4Synchronization5Deadlocks6CPU scheduling7Paging and memory8Copy-on-write9Filesystems10I/O and IPC11Protection and Linux12Complete server trace

#Section 1OS responsibilities and operating modes

Finch has 1,000 open connections but only 2 cores, so a program cannot simply claim a core, a memory address, or a device forever. An operating system is the privileged software that allocates those resources and presents stable operations to less trusted programs. It schedules execution, translates addresses, names files, moves device data and checks permissions. The word OS is broader than kernel. Shells, libraries, services and utilities are part of the working system, while the kernel is the privileged core that enforces the hardware boundary.

Kernel abstractions still have costs: a descriptor uses a table entry and an idle socket uses memory. Readiness separates waiting connections from actual executing work.

A SYSTEM CALL CROSSES A CONTROLLED PRIVILEGE BOUNDARYA SYSTEM CALL CROSSES A CONTROLLED PRIVILEGE BOUNDARYuser spaceapplication intentread(fd, buffer, size)privilege boundarychecked entrykernel spacepermissions and resource statevalidate → perform → returnCPUcoresmemory
Figure 3.1Illustrative machine cutaway. Application intent crosses the controlled system-call boundary before the kernel validates the request and acts on cores, memory or devices.

Resource management answers who runs, where bytes live and which device receives a request. Isolation keeps those answers local to each process or container. Protection fails if a user process can write a page-table entry or program a device without a kernel check.

OS types

Multiprogramming keeps programs available while others wait. Multitasking switches among runnable tasks. Multiprocessing adds simultaneous processors or cores; multithreading adds shared-process execution contexts.

A single core can multitask without parallel execution. Time-sharing emphasizes response, batch processing emphasizes queued throughput, and real-time contracts add deadlines. Distributed coordination adds machine boundaries rather than removing them automatically.

TAKING TURNS AND RUNNING TOGETHER HAVE DIFFERENT SHAPESTAKING TURNS AND RUNNING TOGETHER HAVE DIFFERENT SHAPEScoreconcurrency on one coreABABABcorecoreparallelism on separate coresAAABBB
Figure 3.2Illustrative execution strips. One core interleaves A and B, while separate cores can execute them together. The strips show the distinction rather than measured task durations.

The distinction matters when a claim says “the server handles 1,000 connections at once.” It may mean 1,000 descriptors exist, 20 descriptors are ready, or 2 callbacks are executing. Those are different counts with different memory and CPU costs. The OS turns the workload into states and queues before any performance claim is meaningful.

#Section 2Kernel architectures

A faulty driver can damage shared privileged state or fail inside a separate service, depending on its placement. A monolithic kernel places many services in one privileged address space. Linux is broadly monolithic but supports loadable modules, so “monolithic” does not mean every feature is compiled into one immutable binary. A microkernel keeps the privileged core small and moves more services into isolated processes that communicate through messages. A hybrid kernel combines choices, retaining some services in privileged space for performance while using separate boundaries elsewhere.

Isolated services add communication and scheduling costs but bound some failures. In-kernel services access shared state directly, while their bugs can damage that shared privilege. Modules change deployment units, not necessarily isolation.

WHERE THE SERVICES LIVE DECIDES HOW MANY TIMES A READ CROSSESWHERE THE SERVICES LIVE DECIDES HOW MANY TIMES A READ CROSSESuser spacekernel spacefsnetdrvschedhardwaremonolithic2 crossings per readuser spacekernel spacefsnetdrvschedhardwaremodular2 crossings per readuser spacekernel spacefsnetdrvschedhardwaremicrokernel4 crossings per readuser spacekernel spacefsnetdrvschedhardwarehybrid4 crossings per readdashed: loadable module
Figure 3.3Illustrative architecture cutaways compare placement of services and the cost of crossing between them. Orange marks the monolithic path used as the running reference.

History explains why no design won universally. Early systems valued direct hardware control, while later systems needed drivers, portability and stronger fault boundaries. Modern operating systems also use hardware virtualization, sandboxing and namespaces, so a production system can combine monolithic kernel services with many user-space isolation layers.

#Section 3System calls and controlled entry

When Finch calls read, the application does not receive permission to inspect arbitrary RAM. The call enters a kernel-controlled path with arguments that the kernel validates. User space is the less privileged execution environment for applications and libraries. Kernel space is the privileged environment where the OS can configure page tables, service devices and change scheduling state.

The processor enforces privilege state. Kernel entry validates descriptors, pointers, lengths, and authority before returning a result or error. A normal function call changes execution position without necessarily changing privilege.

The boundary is not a security guarantee by itself. A kernel bug, a confused-deputy interface or a leaked capability can still expose data. Isolation requires page permissions, address-space separation, identity checks and careful device access. The useful mental model is an actor with authority, not a magical wall.

READ() LOADS REGISTERS, TRAPS THROUGH ONE GATE, AND RETURNS A COUNTREAD() LOADS REGISTERS, TRAPS THROUGH ONE GATE, AND RETURNS A COUNTuser mode: the applicationkernel moden = read(fd, buf, 4096);rax0rdi3rsibufrdx4096arguments travel in registers;rax names the callsyscallthe only door: CPU switches mode heresyscall table0read1write2open3closecheck fd 3 is open and readable,check buf is user memorydevice or page cacherax = bytes readrax=0
Figure 3.4Illustrative syscall trace labels the argument handoff, number dispatch, kernel validation and return path. The orange arrow is the controlled mode transition.

A privileged instruction is one the processor restricts to kernel mode, such as changing address-translation controls or configuring interrupt delivery. The exact list depends on the architecture. Linux’s system-call ABI and entry instructions vary by architecture, so a portable explanation should describe the contract rather than claim one universal opcode.

#Section 4Interrupts, exceptions and traps

A packet can arrive while Finch executes an unrelated instruction. The CPU needs a way to enter the kernel without waiting for that program to call a library. An interrupt reports an asynchronous event, such as device completion or a timer tick. An exception arises from the current instruction, such as an illegal access or division error. A trap is a synchronous entry used for purposes such as a deliberate system call or debugging; exact terminology varies by architecture.

An event handler updates kernel state and can make a waiter runnable. Returning to the interrupted code and scheduling another task are separate decisions.

THREE WAYS INTO THE KERNEL: A DEVICE INTERRUPTS, AN INSTRUCTION FAULTS, A PROGRAM ASKSTHREE WAYS INTO THE KERNEL: A DEVICE INTERRUPTS, AN INSTRUCTION FAULTS, A PROGRAM ASKSinstruction stream on one coremovadddiv r0loadsyscallcmpkernel: one handler table, three reasonsNICinterruptasynchronous: arrivesbetween any two instructionsexceptiondivide by zero, page faulttrapdeliberate requestIRQ handlerfault handlersyscall entryreturnsynchronous: caused bythe current instruction
Figure 3.5Illustrative interrupts arrive independently of the current instruction, while exceptions and deliberate traps arise synchronously. Orange marks the deliberate entry used by the syscall model.

A packet arrival changes socket state, not core capacity. Identify its buffer and connection, keep interrupt work bounded, and let the scheduled application perform its own processing.