| CACHE
Overview
The purpose of cache is to speed
up memory accesses by storing
recently used chunks of memory.
Now, main memory (RAM) is nice
and cheap. Not as cheap as disk
memory, but cheap nevertheless.
The disadvantage of this sort
of memory is that it is a bit
slow. An access from main memory
into a register may take 20-50
clock cycles. However, there are
other sorts of memory that are
very fast, that can be accessed
within a single clock cycle. This
fast memory is what we call cache.
However, this fast memory is
prohibitively expensive, so we
can't compose our main memory
entirely of it. However, we can
have a small amount, say 8K to
128K on average, in which we store
some of our data. But what data
do we choose? The way it happens,
we choose data that has been most
recently used. This is a policy
that takes advantage of something
called spatial and temporal locality.
Spatial and temporal locality
of memory accesses refers to the
idea that if you access a certain
chunk of memory, in the near future
you're likely to access that memory,
or memory near it, again. For
example, you execute consecutive
instructions in memory, so the
next dozen of so instructions
that you access are probably contained
in a given contiguous block of
data, so the next instruction
would be accessed close by. Similarly,
if you're accessing elements of
an array, they will be located
consecutively, so it makes sense
to store a block of data that
has recently been used. Separate
variables called in a function
are usually close by as well.
That is what cache does.
When we want to access memory
at a certain address, we look
in the cache to see if it is there.
If it is there, we get it from
cache instead of going all the
way to memory; that situation
is called a "cache hit."
If the data is not in cache, then
we bring the data from memory
to cache, which takes longer since
the data must be brought in from
the smaller memory; that situation
is called a "cache miss,"
and that delay that we endure
because that memory must be brought
from main memory is called a "miss
penalty."
Direct
Mappe Catche |
N-Way Set Associative Cache
|
Cache Design and Other Details |
Interrupts
and DMA |
|

|