Fundamentals
Computer system organization
CPU, memory hierarchy, buses, and how the OS maps onto them
Start here
Von Neumann stored-program machine (theory)
Most general-purpose computers today follow a stored-program idea: instructions and data live in the same addressable memory. The CPU fetches instructions, decodes them, executes them, and may read or write memory operands. I/O devices (disks, NICs, keyboards) appear as special regions of addresses or dedicated instructions; the OS configures how they interact with RAM through DMA, interrupts, and MMU rules.
The OS does not change physics, it schedules work around latency hierarchies: registers and L1 caches are nanoseconds; DRAM is tens of nanoseconds; SSDs are microseconds; wide-area networks are milliseconds. Policies (NUMA placement, block I/O schedulers, IRQ affinity) exist because these gaps span orders of magnitude.
By the end of this page you should be able to
- Name the main levels of the memory hierarchy and explain why each exists.
- Explain why DMA uses physical addresses and why an IOMMU matters for security.
- Relate interrupt storms and IRQ affinity to multi-core organization.
- Read a simple latency table and infer likely bottlenecks for CPU-bound vs I/O-bound workloads.
Subsystems the OS maps onto
CPU cores and caches
Main memory & NUMA
Buses and peripherals
Timers and preemption
Formal reading of “organization”
Computer organization (this topic) is about structure and timing of the machine. Computer architecture sometimes emphasizes ISA design; operating systems sit above both and assume them as constraints. When you tune a database, you are often really tuning how much L3 miss traffic and how many remote NUMA accesses you generate.
TL;DR
The OS assumes a von Neumann-style machine: CPUs execute instructions from memory, caches hide DRAM latency, I/O devices appear as memory-mapped or port-I/O, and the OS configures timers, interrupt controllers, and the MMU to regain control periodically and enforce isolation.
Computer organization is the substrate operating systems exploit. Understanding caches, buses, and interrupt delivery explains why certain OS structures exist (per-CPU runqueues, RCU, slab coloring) and why naive locking or memory allocation can destroy performance even when “algorithmically optimal.”
Latency ladder (orders of magnitude)
Latency orders of magnitude (rough, system-dependent)
| Layer | Typical latency |
|---|---|
| L1 cache hit | ~1 ns |
| Main memory (local NUMA node) | ~50–100 ns |
| SSD read (4 KiB) | ~10–100 μs |
| Cross-region network RTT | 10–150 ms |
Where latency hides
Where latency hides
| Layer | Typical culprit |
|---|---|
| CPU | Branch misses, pipeline hazards |
| Cache | Capacity/conflict misses, coherence traffic |
| DRAM | Row buffer misses, NUMA remote |
| I/O | Queue depth, rotational/FTL latency |
Why the OS cares
Bus widths, cache hierarchy, and NUMA topology are not trivia, they change lock contention, DMA coherency costs, and why a “fast” algorithm becomes slow under false sharing. The OS schedules around these physical facts with affinity, per-CPU runqueues, and NUMA-aware allocators.
Hardware story (timeline)
CPU executes streams of instructions
Pipeline stalls, branch prediction, and cache misses dominate latency more than raw GHz.
Memory hierarchy hides DRAM latency
L1/L2/L3 caches coherency protocols (MESI family) interact with kernel spinlocks and RCU.
Devices signal completion
MMIO registers, MSI-X interrupts, and DMA rings move data without byte-wise CPU copies.
Storage is block-oriented
OS stacks page cache atop block devices; alignment and queue depth matter for throughput.
Insights
Memory hierarchy is policy-driven
Interrupt controllers are programmable
Timers drive preemption
Firmware hands off a memory map
First-time debugging hint
Did you know?
- Cache coherence protocols (MESI and variants) matter when kernel spinlocks share cache lines across cores, false sharing can dominate scalability.
- DMA engines see **physical** addresses; IOMMUs translate so malicious devices cannot DMA arbitrary RAM.
- Modern servers are NUMA: the OS must allocate memory “near” the scheduling CPU or pay remote DRAM latency.
Common mistakes
Assuming uniform memory
Remote NUMA access can double latency; `numactl` and default `first_touch` policy matter for big data jobs.
Ignoring cache line contention
Two cores writing different variables sharing a 64B line ping-pong cache, use padding or per-CPU counters.
Terms
Follow-ups
- Why does false sharing hurt even when threads mutate different logical variables?
- How does a device interrupt differ from a syscall with respect to preemption?
- What breaks if DMA targets physical RAM a VM does not own?
Performance debugging
When CPU usage looks low but latency is high, suspect I/O wait, lock contention, or remote NUMA memory, not always “bad algorithms.”
Practice
Whiteboard exercise
Deep dive
Memory-mapped I/O vs port I/O
Why the OS cares about cache lines
NUMA topology (Linux)
lscpu | grep -i numanumactl --hardware
Self-check
1DMA primarily reduces…
2NUMA stands for…
3IOMMU protects against…