← All concepts
TechnologyComputer systems

CPU & memory hierarchy

How a CPU runs instructions and the memory hierarchy from registers to disk.

Inside the CPU

  • The control unit fetches and decodes instructions; the ALU does arithmetic and logic; registers hold the values being worked on right now.
  • The fetch–decode–execute cycle repeats for every instruction, paced by the clock (measured in Hz).

Memory hierarchy

Faster memory is smaller and costlier, so machines layer it (fastest first):

  1. Registers (inside the CPU)
  2. Cache — L1, L2, L3
  3. Main memory (RAM)
  4. SSD / hard disk

Ideas that speed things up

  • Cache keeps recently-used data close to the CPU, exploiting *locality of reference*.
  • Pipelining overlaps the stages of consecutive instructions like an assembly line.
  • Interrupts let a device signal the CPU when it's ready, instead of the CPU wastefully polling.