Search⌘ K
AI Features

Levels of Computer Memory

Explore the levels of computer memory from CPU registers to disk drives, and how data flows between them. Understand access speed, capacity, access time, and costs of each memory level. Discover why memory hierarchy and caching are vital for efficient program execution and how they affect CPU performance.

Why the OS loads instructions into the RAM

In theory, the CPU can read program instructions directly from the disk drive. However, this never actually happens. Instead, the OS loads the instruction into RAM first. Then, the processor executes them. Why does this happen?

A modern computer has four levels in the memory hierarchy. Each level matches the red rectangle, as shown in the figure on the right. Each rectangle matches a separate device. The only exception is the CPU chip, which contains both registers and a memory cache. Those are separate modules of the chip.

The arrows in the figure represent data flows. Data transfer occurs only between adjacent memory levels. The processor works with data from its registers only. If the CPU needs something from the disk drive, it’s loaded in the following way:

  1. Disk drive to RAM
  2. RAM to the processor cache
  3. Processor cache to processor registers
Memory hierarchy

When the CPU writes data back to the disk, it does so in reverse order of the steps above.

The memory levels differ from each other by the following parameters:

  1. Access speed ...