Cache Coherence Protocols — MESI and MOESI — Cache coherence protocols ensure that multiple processors observing the same memory location always see a consistent value, with MESI and MOESI being the most widely deployed snooping-based protocols in modern multiprocessor systems.
MESI Protocol States — The four-state MESI protocol defines cache line behavior:
- Modified (M) — the cache line has been written and differs from main memory, only this cache holds a valid copy, and a writeback is required before any other cache can access it
- Exclusive (E) — the cache line matches main memory and exists in only this cache, allowing a silent transition to Modified on a write without bus traffic
- Shared (S) — the cache line matches main memory and may exist in multiple caches simultaneously, requiring a bus transaction to transition to Modified
- Invalid (I) — the cache line contains no valid data and must be fetched from memory or another cache before use
MOESI Protocol Extension — The five-state MOESI protocol adds the Owned state for optimization:
- Owned (O) — the cache line has been modified and other caches hold Shared copies, but this cache is responsible for supplying the data on requests instead of main memory
- Dirty Sharing Optimization — the Owned state eliminates the need to write back modified data to main memory before sharing, reducing memory bus traffic significantly
- Cache-to-Cache Transfers — when a cache in Owned state receives a read request, it supplies the data directly, avoiding the latency of main memory access
- AMD Adoption — AMD processors extensively use MOESI to reduce memory bandwidth consumption in multi-socket configurations
Snooping vs Directory Protocols — Two fundamental approaches to maintaining coherence:
- Bus Snooping — all caches monitor a shared bus for transactions affecting their cached addresses, providing low-latency coherence for small-scale systems
- Directory-Based Coherence — a centralized or distributed directory tracks which caches hold copies of each line, scaling to large systems by avoiding broadcast traffic
- Snoop Filtering — modern systems add snoop filters to reduce unnecessary coherence traffic, combining snooping simplicity with improved scalability
- Hierarchical Protocols — large systems may use snooping within a socket and directory-based coherence between sockets to balance latency and scalability
State Transition Mechanics — Protocol correctness depends on precise state machine behavior:
- Read Miss Handling — a read miss triggers a bus read transaction, transitioning the requesting cache to Shared or Exclusive depending on whether other caches hold copies
- Write Miss Handling — a write miss generates a read-with-intent-to-modify transaction, invalidating all other copies and transitioning to Modified
- Upgrade Transactions — a write to a Shared line requires an upgrade transaction that invalidates other copies without re-fetching the data
- Intervention — caches in Modified or Owned states must respond to snoop requests by supplying data, potentially transitioning to Shared or Invalid
MESI and MOESI protocols form the backbone of hardware cache coherence in virtually all modern multiprocessor systems, with their state transition efficiency directly impacting multi-threaded application performance.
Explore 500+ Semiconductor & AI Topics
From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.