Types of Caches
One-Level Cache(L1): A single cache, which works as described above, if it is using the MRU algorithm.
Two-level Cache(L2): In addition to a L1 cache, there’s a second, usually much larger, level of cache. It is located between the L1 cache and main memory.
In general, all data in the L1 cache is also in the L2 cache. This is called the multi-level inclusion property. However, because L2 cache is much larger, there will be data in the L2 cache that is not in L1.
The two-level cache works as follows:
If there’s a L1 cache hit, both caches have the data. Even though the access and hit only count for the L1 cache, that data is moved to the top of both caches.
If there’s a L1 cache miss but a L2 cache hit, the data is not in L1 cache but is in L2. The access counts against both caches, but only the L2 receives a hit. The data is added to the top of the L1 cache and is moved to the top of the L2 cache.
If there’s a L1 and L2 cache miss, the data is in neither cache. This counts as an access against both caches, but neither gets a hit. The data is retrieved from main memory and added to the top of both caches.