Memory Hierarchy

We classify memory types according to their closure to the CPU:

  1. Registers are located directly inside the CPU and used to store intermediate data. Registers are accessed in a single CPU clock cycle (= a couple nanoseconds,) making them the closest and quickest memory available to the processor.
  2. Cache memory is located very close to the CPU, often integrated onto the CPU chip. It is designed to store frequently accessed data and instructions, significantly reducing the time the CPU spends fetching data from slower memory layers. Cache memory is slightly slower than registers and is accessed in several nanoseconds.
  3. Main memory is separate from the CPU but connected to it via the system bus. While slower than cache, with access times in tens of nanoseconds, it provides the large capacity needed to store an operating system and application data.
  4. Secondary memory, like HDDs and SSDs, is located much farther from the CPU and is accessed via storage interfaces like SATA. It is used for non-volatile storage, retaining data even when the system is powered off. Its access times ranges from microseconds to milliseconds, making it about 1000 times slower than main memory.
  5. External or disconnected storage devices are typically used for archiving and long-term data storage. These devices are the farthest from the CPU, often requiring manual installation. As the slowest memory type, it is used for infrequent data access or backups. Examples include optical disks (CD/DVDs), tape drives, and external USB drives.