Home Knowledge Base Cache Coherence Protocols

Cache Coherence Protocols are the hardware mechanisms that maintain a consistent view of shared memory across multiple processor cores' private caches — ensuring that when one core modifies a cached copy of a memory location, all other cores' copies are invalidated or updated, providing the illusion of a single unified memory despite the physically distributed cache hierarchy that is essential for multicore processor performance.

The Coherence Problem

Each core has its own L1/L2 cache for fast access. When Core 0 writes to address X (cached locally), Core 1's copy of X in its cache becomes stale. Without coherence, Core 1 reads the old value — a silent data corruption bug. The coherence protocol ensures that every read returns the most recently written value, regardless of which core performed the write.

MESI Protocol

The most widely-used snooping protocol. Each cache line is in one of four states:

MOESI Extension: Adds Owned (O) state — this cache has a dirty copy but others may have Shared copies. The owner supplies data on snooped reads without writing back to memory first. Used by AMD processors to reduce memory traffic.

Coherence Mechanisms

False Sharing

Two variables on the same cache line (typically 64 bytes) accessed by different cores. Even though they are logically independent, the coherence protocol bounces the cache line back and forth between cores on every write — the line is shared but each core's write invalidates the other's copy. Performance impact: 10-100x slowdown on tight loops. Fix: pad variables to cache-line boundaries (alignas(64)).

Performance Impact

Cache Coherence Protocols are the invisible contract that makes shared-memory multicore processors work — the hardware mechanism that hides the complexity of distributed caches behind the programmer-friendly abstraction of a single, consistent memory space.

cache coherence protocolmesi moesi protocolsnooping directory coherencefalse sharing cachecache invalidation

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.