What is MESI protocol?
A coherence protocol that tracks each cache line in one of four states: Modified, Exclusive, Shared or Invalid. On a write it invalidates other cores' copies.
Japanese name: MESIプロトコル
A coherence protocol that tracks each cache line in one of four states: Modified, Exclusive, Shared or Invalid. On a write it invalidates other cores' copies.
Japanese name: MESIプロトコル
Modified (M): this cache holds the only copy and has written it, so memory is stale and the data must be written back or supplied to others. Exclusive (E): the only copy, but identical to memory. Shared (S): an unmodified copy that other caches may also hold. Invalid (I): the line holds no usable data. The protocol guarantees a single-writer, multiple-reader rule for each line: at any time either one cache may write it (M or E) or any number may read it (S), never both.
On a read miss the cache requests the line; if no other cache has it, it is loaded in E, otherwise in S. If another cache holds it in M, that cache writes it back to memory (it may also supply the data directly) and drops to S. A write to an S line must first invalidate all other copies, an upgrade request, before moving to M. A write miss issues a read-for-ownership that fetches the line and invalidates other copies in one step. When another core's write request is observed, any local copy goes to I, and an M copy hands over its data first.
The simpler MSI protocol has no E state, so a core that reads private data and then writes it must send an extra invalidation on the bus even though no other cache holds a copy. E records that the line is clean and unshared, allowing the later write to move silently to M. Since much data is private to one core, this saves a large amount of coherence traffic. Variants add more states: MOESI adds Owned, letting a dirty line be shared without first updating memory, and MESIF adds Forward, naming the one sharer that answers requests.
Coherence works per cache line, typically 64 bytes, not per variable. If two cores repeatedly write different variables that happen to share a line, each write must invalidate the other core's copy, so the line bounces between M in one cache and I in the other even though the threads never touch the same data. This false sharing can make parallel code slower than sequential code. The fix is to separate frequently written per-thread data, such as counters, onto different lines by padding or alignment.
Answer: A. Only this core holds the line, and its contents differ from main memory (it must be written back)
The M state means this core has written the line and alone holds the latest value. Main memory is stale, so when the line is evicted or another core wants to read it, the latest value must be written back to main memory (it may also be supplied directly to the reading core). A line in M can be written again any number of times without notifying other cores, so repeated writes by the same core are fast.
Answer: C. No other core needs to be notified, and the line simply becomes M
The E state means only this core holds the line and its contents match main memory. Since there are known to be no other copies, the core can move to M on a write without sending invalidations. The benefit of having E is saving that communication in the common pattern of reading and then writing data used by a single core. Writing from S, by contrast, requires invalidating other copies.
MESI adds the Exclusive state for clean lines that no other cache holds. A core can then write such a line without broadcasting an invalidation, which MSI would require.
This cache has the only valid copy and has changed it, so main memory is out of date. The line must be written back on eviction or supplied to another core that requests it.
A slowdown that occurs when threads on different cores write separate variables located in the same cache line, forcing the coherence protocol to move the line back and forth between their caches.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.