1. Gyanastra
  2. Computer Organisation and Architecture
  3. Memory Hierarchy and Locality
  4. Cache as High-Speed Memory Between Registers and Main Memory
Free lesson, no account needed 5 min read 8 practice questions after it
Asked in past papers2 times
  • UGC NET20112007

Computer Organisation and Architecture · Memory Hierarchy and Locality

Cache as High-Speed Memory Between Registers and Main Memory

Overview

Cache is a high-speed memory placed between the CPU registers and main memory.
It exists to resolve the trade-off between registers, which are very fast but too small and costly to hold an entire program, and main memory, which is large enough to hold the program but slow.
By keeping the frequently used portion of a program in cache, the CPU fetches instructions quickly and executes faster.

Key concepts

  • Cache: a high-speed memory placed between the CPU registers and the main memory. It is not as costly as registers (cheaper per bit than registers) and faster than main memory (lower access time than main memory).
  • Position in the cost/speed trade-off: cache sits in the gap between registers and main memory — cost-wise cheaper than registers, speed-wise better than main memory.
  • Why registers alone are not enough: registers are very fast but their size is too small. They cannot hold the entire program; they can hold only a few instructions because they are costly.
    This creates a trade-off: memory must be large enough to hold the program but fast enough for the CPU.
  • Invention of cache: to resolve this trade-off, designers invented cache — a high-speed memory that is not as costly as registers but faster compared to main memory.
  • How cache speeds up execution: if a program (or at least a part of it) whose process is present in main memory has at least a part of it also present in cache, the CPU gets the instructions fast and executes them faster.
    The frequently used portion of the program is kept in the faster cache, so the CPU does not have to wait for the slower main memory every time.
  • Multiple levels of memory: because of this arrangement, the system no longer uses just one level of memory; it has various levels of memories (registers, cache, main memory, secondary memory), forming a memory hierarchy.
Memory diagram: Cache as High-Speed Memory Between Registers and Main Memory
Figure. Cache as High-Speed Memory Between Registers and Main Memory

How it works

  1. Registers are very fast but too small and costly to hold the entire program — they hold only a few instructions.
  2. This creates a trade-off: memory must be large enough to hold the program but fast enough for the CPU.
  3. To resolve the trade-off, cache is placed between the registers and main memory: cheaper than registers, faster than main memory.
  4. At least a part of the process residing in main memory is also kept in cache; the frequently used portion of the program stays in the faster cache.
  5. The CPU fetches instructions from cache quickly and executes them faster, without waiting for the slower main memory every time.
  6. The result is multiple levels of memory — registers, cache, main memory, secondary memory — forming a memory hierarchy.

Comparison

MemoryCostSpeedSize / holding capacity
RegistersHigh (costly)FastestVery small — only a few instructions
CacheCheaper than registersFaster than main memory, slower than registersLarger than registers (implied by hierarchy)
Main memoryCheaper than cache (implied by hierarchy)Slower than cacheHolds the process / program

Revision summary

  • Cache is not as costly as registers but faster than main memory — both halves of this statement matter.
  • Registers are too small to hold an entire program; they hold only a few instructions because they are costly.
  • The benefit of cache requires that at least a part of the process residing in main memory is also present in cache.
  • The frequently used portion of the program is kept in the faster cache, so the CPU does not wait for slower main memory every time.
  • The system uses multiple levels of memory (a memory hierarchy: registers, cache, main memory, secondary memory), not a single level.

Previous-year exam insights

  • Cache is a small, fast, volatile SRAM (static RAM) placed between the CPU and main memory; it holds copies of recently/frequently used main-memory blocks and is transparent to the programmer.
    Asked inUGC NET 2007
  • A buffer/block cache (disk cache) is a separate cache in main memory or in the disk controller that holds recently read disk blocks, so repeated reads of the same disk block are served without a disk access; it improves disk performance, not main-memory capacity or speed.
    Asked inUGC NET 2011
  • Average memory access time with a cache = hit time + miss rate × miss penalty, where miss penalty is the extra time to fetch the block from the next level;
    hit ratio h and miss ratio (1 − h) give AMAT = h × Tc + (1 − h) × Tm.
  • Cache performance depends on temporal locality (a location referenced once is likely to be referenced again soon) and spatial locality (nearby locations are likely to be referenced soon); blocks are fetched in multi-word units to exploit spatial locality.
  • The memory hierarchy from fastest/smallest/costliest per bit to slowest/largest/cheapest per bit is: registers, cache (L1, L2, L3), main memory, secondary/auxiliary storage; as we go down, access time and capacity increase while cost per bit decreases.
  • Cache is not non-volatile: like main memory it is volatile (loses contents on power-off), and it is not a register — registers are part of the CPU datapath, cache is separate high-speed RAM.
    Asked inUGC NET 2007
Pages 1–2 of 2