Cache coherency
|
Cache coherency (alternatively cache coherence or cache consistency) refers to the integrity of data stored in local caches of a shared resource. Cache coherence is a special case of memory coherence.
Cache_Coherency_Generic.png
When clients in a system, particularly CPUs in a multiprocessing system, maintain caches of a common memory resource, problems arise. Referring to the figure, if the top client has a copy of a memory block from a previous read and the bottom client changes that memory block, the top client could be left with an invalid cache of memory without it knowing any better. Cache coherency is intended to manage such conflicts and maintain consistency between cache and memory.
Cache Coherency Mechanisms
Directory based cache coherency mechanisms maintain a central directory of cached blocks.
Snoop/Snarf. Snooping is the process where the individual caches monitor address lines for accesses to memory that they have cached. When a write operation is observed to a location that a cache has a copy of, the cache controller invalidates its own copy of the snooped memory location. Snarfing is where a cache controller watches both address and data in an attempt to update its own copy of a memory location when a second master modifies a location in main memory.
Distributed shared memory systems mimic these mechanisms in an attempt to maintain consistency between blocks of memory in loosely coupled systems.
Coherency Models
Various models and protocols have been devised for maintaining cache coherency, such as the MESI protocol, MSI protocol, MOSI protocol and the MOESI protocol. Choice of consistency model is crucial to designing a cache coherent system. Most of the cache protocols in multiprocessors are designed to support sequential consistency. Coherency models differ in performance and scalability so must be evaluated for each system design.