Introduction
Every modern CPU is far faster than the main memory (RAM) that feeds it data and instructions. If the processor had to wait for RAM on every access, it would sit idle most of the time. Cache memory is a small, extremely fast memory placed between the CPU and main memory that keeps recently and frequently used data close to the processor. The whole idea works because real programs obey the principle of locality of reference — they tend to reuse the same data and nearby data over and over.
For BCS, Bank IT, and IT-officer exams this topic is a repeat favourite. Questions test the memory hierarchy, the meaning of hit/miss/hit ratio, effective access time (EAT) calculations, temporal vs spatial locality, cache mapping techniques (direct, associative, set-associative), and write policies. Master the definitions AND be able to compute EAT and hit ratios — that is where marks are won.
Learning Objectives
- Explain why the memory hierarchy exists and where cache sits in it.
- Define cache memory, cache line/block, hit, miss, hit ratio and miss ratio.
- State and distinguish temporal locality and spatial locality with examples.
- Compute effective (average) memory access time and hit/miss ratios.
- Compare the three cache mapping techniques: direct, fully associative, set-associative.
- Explain replacement policies (LRU, FIFO, Random) and write policies (write-through, write-back).
- Distinguish the levels L1, L2, L3 and avoid common exam traps.