Cache Memory

General Concept

cache-memory-simple.003

cache-memory-simple.004

cache-memory-simple.005

cache-memory-simple.006

CPU Core Caching

cache-memory-simple.008

cache-memory-simple.009

cache-memory-simple.010

cache-memory-simple.011

cache-memory-simple.012

cache-memory-simple.013

Cache Lines

cache-memory-simple.015

cache-memory-simple.016

Cache Memory

Associative Memory

cache-memory-simple.019

cache-memory-simple.020

cache-memory-simple.021

cache-memory-simple.022

Direct-Mapped Memory

cache-memory-simple.024

cache-memory-simple.025

cache-memory-simple.026

cache-memory-simple.027

Set Associative Memory

cache-memory-simple.029

cache-memory-simple.030

cache-memory-simple.031

Cache Read/Write Policies

cache-memory-simple.033

cache-memory-simple.034

cache-memory-simple.035

cache-memory-simple.036

cache coherency

MESI protocol: (Modified, Exclusive, Shared, Invalid)

  • Invalid lines are cache lines that are either not present in the cache, or whose contents are known to be stale. For the purposes of caching, these are ignored. Once a cache line is invalidated, it’s as if it wasn’t in the cache in the first place.
  • Shared lines are clean copies of the contents of main memory. Cache lines in the shared state can be used to serve reads but they can’t be written to. Multiple caches are allowed to have a copy of the same memory location in “shared” state at the same time, hence the name.
  • Exclusive lines are also clean copies of the contents of main memory, just like the S state. The difference is that when one core holds a line in E state, no other core may hold it at the same time, hence “exclusive”. That is, the same line must be in the I state in the caches of all other cores.
  • Modified lines are dirty; they have been locally modified. If a line is in the M state, it must be in the I state for all other cores, same as E. In addition, modified cache lines need to be written back to memory when they get evicted or invalidated – same as the regular dirty state in a write-back cache.

Principle Of Locality

cache-memory-simple.038

cache-memory-simple.039

cache-memory-simple.040

cache-memory-simple.041

cache-memory-simple.042

cache-memory-simple.043

Summary

cache-memory-simple.045