Skip to guide

Part 4 · Cache coherence

MSI, MESI, MOESI, and ownership

Track readers, writers, dirty ownership, invalidation, intervention, false sharing, and write-policy consequences across private caches.

Compare architectural tradeoffs with explicit performance models and trace the mechanisms that recover correctness when speculation fails.

Updated July 20261 connected chaptersInteractive labs + worked examples

Multicore · private caches

A private cache is fast only if every core agrees which copy is valid.

Coherence tracks ownership and visibility for each cache line. Snooping controllers observe transactions, invalidate stale copies, and move the newest data without asking software to repair the view.

Multicore topologyPrivate speed, shared ownership.

Core A’s write upgrades X from S to M, invalidates Core B’s copy, and makes the private owner responsible for the newest value.

  1. 1

    Core A reads X and caches a clean copy.

  2. 2

    Core B reads X and also caches a clean copy.

  3. 3

    Core A writes X, making its local value newer.

  4. !

    Without coherence, Core B could keep and read stale X.

MESI transition explorer

Keep one address coherent across two private caches.

Address X
Core A
Core B
Private L1 · Core AINo valid copy
Snoop fabricIdle
Private L1 · Core BINo valid copy

Neither private cache holds X. Memory owns the current copy.

MModified only valid copy, dirty
EExclusive only valid copy, clean
SShared clean copy may exist elsewhere
IInvalid data cannot be used

Protocol invariants

States are an encoding of who may read, who may write, and who owns the newest data.

Single writerAt most one cache may hold write permission.

M or E excludes every peer’s valid writable copy. A Shared writer must invalidate peers first.

Multiple readersSeveral clean Shared copies may coexist.

Every observer must see a value consistent with the ordered coherence transaction for that line.

Data valueThe newest value lives in memory or one identifiable owner.

MESI M and MOESI M/O mark memory stale; intervention or writeback supplies the current data.

ProtocolStatesKey additionPrivate clean writeRead of dirty peerTradeoff
MSIM · S · IBasic invalidation coherenceNeeds an ownership transaction because there is no Exclusive stateModified owner must supply or flush the newest dataSimple, but generates extra traffic for private data
MESIM · E · S · IExclusive marks one clean private copySilent E → M transitionModified owner relinquishes dirty ownership; implementations may forward while updating coherence stateCommon balance of private-write efficiency and complexity
MOESIM · O · E · S · IOwned permits dirty shared dataSilent E → M transitionOwner can forward dirty data directly while memory remains staleLess writeback pressure, more controller and verification complexity
MSI

S + local write: request ownership, invalidate sharers, then enter M.

MESI

E + local write: enter M silently. E + remote read: both copies become S.

MOESI

M + remote read: supplier may enter O while the requester enters S and memory remains stale.

Write-through

Update lower memory on every write.

Memory stays current, but peer caches can still contain stale copies. The coherence protocol must invalidate or update them. Traffic is high unless a write buffer absorbs latency.

Write-back

Keep the newest data in the owning cache.

Writes avoid immediate lower-level traffic, but the protocol must identify the dirty owner and make it supply or write back data when another requester arrives.

Core A has E; Core B now reads the same line. What happens?

Core B issues a read transaction. Core A snoops it and downgrades from Exclusive to Shared because it is no longer the only holder. Core B receives a clean Shared copy, so the final state is S/S. Since the original E line matched memory, no dirty-data recovery is required.

How do write-through and write-back differ under coherence?

Write-through immediately updates the next memory level, while write-back lets an M or O cache remain the newest owner. Both still need a protocol for other cached copies. Write-through simplifies finding a current lower-level copy at the cost of traffic; write-back reduces traffic at the cost of ownership, intervention, and eviction logic.

Continue the system

Connect the adjacent layer.