Cache Memory
Cache Memory
ACCESSING 22,26,22,26,16,3,16,18,16
Key points of Direct Mapping
❖ In Direct mapping, assign each memory block to a specific line in the
cache.
❖ If a line is previously taken up by a memory block when a new block
needs to be loaded, the old block is trashed.
❖ An address space is split into two parts index field and a tag field. The
cache is used to store the tag field whereas the rest is stored in the
main memory.
❖ Direct mapping`s performance is directly proportional to the Hit ratio.
Handling Writes
1. Write-through - The simplest way to keep the main memory and the
cache consistent is always to write the data into both the memory and the
cache.
2. Write Back- when a write occurs, the new value is written only to the
block in the cache. The modified block is written to the lower level of the
hierarchy when it is replaced. Write-back schemes can improve
performance.
L2: This cache is known as Level 2 cache or L2 cache. This level 2 cache may be
inside the CPU or outside the CPU. All the cores of a CPU can have their own
separate level 2 cache, or they can share one L2 cache among themselves.
L3: It is known as Level 3 cache or L3 cache. This cache is not present in all the
processors; some high-end processors may have this type of cache.
How does cache memory work with CPU?
When CPU needs the data, first of all, it looks inside the L1 cache. If it does not find
anything in L1, it looks inside the L2 cache. If again, it does not find the data in L2
cache, it looks into the L3 cache. If data is found in the cache memory, then it is
known as a cache hit. On the contrary, if data is not found inside the cache, it is
called a cache miss.
If data is not available in any of the cache memories, it looks inside the Random
Access Memory (RAM). If RAM also does not have the data, then it will get that data
from the Hard Disk Drive.