Skip to content

MSI Protocol

Each cache line is in exactly one of three states:

StateMeaningCan read?Can write?Memory up-to-date?
M (Modified)This cache has the only valid copy; it’s been writtenYesYesNo (cache has newer data)
S (Shared)Clean copy; other caches may also have copiesYesNo (must upgrade first)Yes
I (Invalid)Not in cache or staleNoNo
Current StateActionNext State
MRead hitM
SRead hitS
I (miss)Issue BusRd; if another cache has M, it flushes → both go SS
Current StateActionNext State
MWrite hitM
SIssue BusUpgr → invalidate other sharersM
I (miss)Issue BusRdX → get line, invalidate othersM
Observed SignalMy StateActionMy New State
BusRdMFlush data to bus + memoryS
BusRdSNo actionS
BusRdX / BusUpgrMFlush data to bus + memoryI
BusRdX / BusUpgrSI

At any time, for any cache line, exactly one of these is true:

  • One cache holds the line in M, and all others are I
  • Multiple caches hold the line in S (and memory is up-to-date)
  • All caches are I (nobody has the line)

This invariant is what guarantees coherence: there’s never a situation where two caches have conflicting data.

Pick a read/write and a core, click Apply. The widget shows the resulting state vector and the bus traffic. The bottom invariant box confirms MSI’s key safety property after every step.

Worked Example: Three Cores, One Cache Line

Section titled “Worked Example: Three Cores, One Cache Line”

Trace the state and bus traffic for a sequence on line A, starting with everyone in I. Each row is one operation; we track who has the line in what state.

#OperationBusCore 0Core 1Core 2
0initialIII
1Core 0 reads ABusRdS (memory supplies)II
2Core 1 reads ABusRdSSI
3Core 2 reads ABusRdSSS
4Core 0 writes ABusUpgr → InvMII
5Core 1 reads ABusRd → flush by Core 0S (flushed, mem now fresh)SI
6Core 2 writes ABusRdX → InvIIM

Five bus transactions for six accesses — and that single write at step 4 by itself broadcast invalidations to both other caches even though they were only reading. Now imagine 32 cores were all sharing the line in S: that one write costs 31 invalidation messages.

This is the classic argument for read-mostly data being a coherence bargain and shared-mutable data being a coherence disaster. MESI’s E state will save one BusUpgr on step 4 only if Core 0 was the sole reader to begin with — which it isn’t here (three sharers).

MSI has an inefficiency: when a cache reads a line that nobody else has, it goes to S even though it’s the only copy. If it later writes to that line, it must first issue a BusUpgr (unnecessary bus traffic). The MESI protocol fixes this with an Exclusive state.