Building Software

Engineering Fundamentals for the Agent Era

Contents Section 3, The Machine

Hardware and the Operating System

Mistakes to catch in review

  1. A whole file or table loaded into memory when the job needed to stream it, which works in testing and crashes on real data.

  2. Success reported as soon as a write call returns, with no flush or sync to make sure the data survives a crash.

  3. A background job that takes three minutes on a platform that kills anything over thirty seconds, so it finishes locally and never in production.

  4. A script that ignores exit codes, so a failed step looks like success to everything downstream.

What the CPU, memory, storage and operating system actually do when a program runs, and why their costs differ by orders of magnitude.

Topics

How a CPU Executes Code
Instructions, registers, clock cycles, pipelines and multiple cores, and what compiled code turns into.
The Memory Hierarchy
Registers, caches, RAM, disk and network, why each step is slower by orders of magnitude, and why locality matters.
Storage and Durability
How SSDs and filesystems store data, and what it takes for a write to survive a power loss.
Processes and Virtual Memory
How the operating system isolates programs, gives each its own address space and schedules them onto cores.
System Calls and Files
The boundary between a program and the kernel, covering file descriptors, sockets, permissions, signals and exit codes.
GPUs and Accelerators
Why massively parallel hardware runs graphics and machine learning, including the models that write your code.
Runtime Environments
Virtual machines, containers and serverless functions, what each one isolates and limits (memory, CPU time, disk, request length), and why code that runs locally dies there.

You understand it when you can

  • State the rough latency of a CPU cache hit, a memory read, an SSD read, a round trip inside a data center and a round trip across a continent.
  • Explain what happens between typing a command in a shell and the resulting process exiting.
  • Name the tool you would use to find which file or port a failing program is opening, and what its output shows.

Drill

An agent wrote a nightly job that reads a 40 GB log file into memory in one call, writes a summary, and exits with status 0 even when processing throws an error. Find the two defects that only appear on production-sized input or on failure, and describe what the scheduler and the next job in the pipeline will see.

Start here

Watch

How CPU Memory & Caches Work - Computerphile

Matt Godbolt, 2025. 35-minute explainer.

The creator of Compiler Explorer explains cache levels, cache lines and why memory access patterns change performance by orders of magnitude.

Watch

Read

Operating Systems: Three Easy Pieces

Remzi H. Arpaci-Dusseau and Andrea C. Arpaci-Dusseau, 2023, version 1.10. Free to read online.

Free, readable chapters on processes, virtual memory, scheduling, file systems and crash consistency, organized around virtualization, concurrency and persistence.

Computer Systems: A Programmer's Perspective

Randal E. Bryant and David R. O'Hallaron, 2015, 3rd edition.

Explains the machine from a programmer's side: machine code, the memory hierarchy and locality, linking, processes, signals and system-level I/O.

How Linux Works: What Every Superuser Should Know

Brian Ward, 2021, 3rd edition.

A practical tour of processes, file descriptors, devices, filesystems and inspection tools such as lsof and strace for finding which file or port a program is touching.

Primary sources