chapter 5
chapter 5
Miss
The figure
Hit below shows
these last two
operations
occurring in
parallel.
Caching in a Memory Hierarchy
Smaller, faster, more expensive
device at level k caches a
Level k: 48 9 14
10 3
subset of the blocks from level k+1
0 1 2 3
Request
Cache miss
12
4*
12 ◦ b is not at level k, so level k cache must
fetch it from level k+1. E.g., block
12
0 1 2 3 ◦ If level k cache is full, then some current
block must be replaced (evicted). Which
Level 44* 5 6 7
one is the “victim”?
k+1: 8 9 10 11 ◦ Placement policy: where can the new block go?
12 13 14 15 E.g., b mod 4
◦ Replacement policy: which block should be
evicted? E.g., LRU
Typical Cache Organization
miss
In this organization,
the cache connects
to the processor via
data, control, and
address lines.
hit
The data and
address lines also
attach to data and
address buffers,
which attach to a
system bus from
which the main
memory is reached.
ELEMENTS OF CACHE DESIGN
• Permits each main memory block to be loaded into any line of the cache
• The cache control logic interprets a memory address simply as a Tag and a Word field
• To determine whether a block is in the cache, the cache control logic must
simultaneously examine every line’s Tag for a match .
• any to any
Set Associative
Associative Mapping
A compromise that exhibits the
strengths of both the direct and
associative approaches while
Direct Mapping reducing their disadvantages
The most common replacement
algorithms are:
Least recently used (LRU)
• Most effective
• Replace that block in the set that has been in the cache longest with no
reference to it
• Because of its simplicity of implementation, LRU is the most popular
replacement algorithm
First-in-first-out (FIFO)
• Replace that block in the set that has been in the cache longest.
• Easily implemented as a round-robin or circular buffer technique
Least frequently used (LFU)
• Replace that block in the set that has experienced the fewest
references
• Could be implemented by associating a counter with each line.
ELEMENTS OF CACHE DESIGN
Write Policy