Chapter 4 - Memory Part 3
Chapter 4 - Memory Part 3
Once the cache has been filled, when a new block is brought into the
cache, one of the existing blocks must be replaced.
For direct mapping, there is only one possible line for any particular
block, and no choice is possible.
Random Replacement
pick a line at random from among the candidate lines.
random replacement provides only slightly inferior performance to
an algorithm based on usage.
Write Policy
When a block that is resident in the cache is to be replaced, there
are two cases to consider. If the old block in the cache has not been
altered, then it may be over written with a new block without first
writing out the old block. If at least one write operation has been
performed on a word in that line of the cache, then main memory
must be updated by writing the line of cache out to the block of
memory before bringing in the new block.
Write Policy
Problems
First, more than one device may have access to main memory. For
example, an I/O module may be able to read-write directly to
memory. If a word has been altered only in the cache, then the
corresponding memory word is invalid.
Further, if the I/O device has altered main memory, then the cache
word is invalid.
The problem with write back is that portions of main memory are
invalid, and hence accesses by I/O modules can be allowed only
through the cache. This makes for complex circuitry and a
potential bottleneck.
Number of Caches
When caches were originally introduced, the typical system had
a single cache. More recently, the use of multiple caches has
become the norm.
Multilevel Caches
the on-chip cache (cache on the same chip as the processor)
reduces the processor’s external bus activity and therefore
speeds up execution times and increases overall system
performance. When the requested instruction or data is
found in the on-chip cache, the bus access is eliminated.
Multilevel Caches