MSI vs MESI vs MOESI: Key Differences Explained

MSI, MESI and MOESI are protocols that attach a state to each line held in each cache of a multicore system so that data at the same address never becomes inconsistent. MSI is the basic form with only three states: Modified, Shared and Invalid. MESI adds Exclusive (held only by this cache, with the same contents as memory), which saves bus traffic when writing data that no other core holds. MOESI further adds the Owned state, which allows modified data to be shared with other caches without writing it back to memory.

AspectMSIMESIMOESI
Number of statesThree (M, S, I)Four (M, E, S, I)Five (M, O, E, S, I)
Modified (M)Held only by this cache; contents differ from memorySameSame
Shared (S)Other caches may also hold it. Contents match memorySameOther caches may also hold it. Contents may differ from memory (when a line in O state exists)
Exclusive (E)NoneHeld only by this cache; contents match memoryPresent (same as MESI)
Owned (O)NoneNoneContents differ from memory, but other caches share it in S. Responsible for writing back to memory
When reading data no other core holdsEnters S stateEnters E stateEnters E state
When then writing to that dataTo change from S to M, issues a request on the bus or similar to invalidate other copiesChanges from E to M without any communicationChanges from E to M without any communication
When another core reads an M lineWrites back to memory; both become SWrites back to memory; both become S (the data may also be passed directly from the cache)Passes the data without writing back; this cache becomes O and the other becomes S
Write-back to memoryOccurs each time a modified line is read by another coreOccurs each time a modified line is read by another coreCan be deferred until the O line is evicted
State bits and complexity2 bits. Simplest2 bits. Moderate3 bits. Most complex

Figures are typical orders of magnitude and vary by process generation and product.

When to use which

MSI
As the basic form for learning how coherence works. When you want to keep state transitions as simple as possible.
MESI
When there are many reads and writes to data used by only one core. Thanks to the E state, read-then-write operations avoid communication. It forms the basis of the protocols in many multicore CPUs.
MOESI
When modified data is frequently passed between cores. When you want to reduce write-backs to memory and save memory bandwidth.

FAQ

What is the benefit of MESI's E state?

Reading data that no other core holds puts the line in E state, and a later write can change it to M without notifying other cores. In MSI, the same case enters S state, so an invalidation request must be issued for each write. It reduces bus traffic for read-then-write operations on data used by only one thread.

What is the benefit of MOESI's O state?

When another core reads modified data (M state), MESI writes it back to memory before sharing it, but MOESI passes the data between caches without writing back, and the original cache keeps responsibility for the write-back in O state. This reduces writes to memory.

How do the E and M states differ?

In both, this cache is the only one holding the line. In E state the contents match memory, so no write-back is needed on eviction. In M state the line has been modified and differs from memory, so it must be written back on eviction.

Are these protocols used with snooping or with directory-based coherence?

Either. MSI, MESI and MOESI define how line states are assigned, which is a separate matter from how other caches are notified (snooping, which monitors a shared bus or similar, or a directory scheme, which records the owners of each line).

Check your understanding

Which correctly lists the four states of the MESI cache coherence protocol?

  1. AMemory, Execute, Store, Index
  2. BModified, Exclusive, Shared, Invalid
  3. CMiss, Evict, Swap, Idle
Show answer and explanation

Answer: B. Modified, Exclusive, Shared, Invalid

In MESI, each cache line is in one of four states: Modified (changed and held only by this core), Exclusive (unchanged and held only by this core), Shared (several cores hold the same contents) or Invalid. The state changes whenever the core reads or writes, or learns of other cores' reads and writes, which prevents copies of the same address from disagreeing.

In the MESI protocol, what does it mean when a cache line is in the Modified (M) state?

  1. AOnly this core holds the line, and its contents differ from main memory (it must be written back)
  2. BSeveral cores hold the same contents, which also match main memory
  3. CThe line's contents are unusable and must be fetched again to read
Show answer and explanation

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 or supplied directly. 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.

In the MESI protocol, what happens when a core writes to a line it holds in the Exclusive (E) state?

  1. AIt sends invalidation requests to all other cores before writing
  2. BIt cannot write, so it writes to main memory and reads the line back
  3. CNo other core needs to be notified, and the line simply becomes M
Show answer and explanation

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.

  1. In an invalidation-based coherence protocol, what happens when a core writes to a line in the Shared (S) state?
  2. In MESI, when core 1 tries to read a line that core 0 holds in the Modified (M) state, what generally happens?
  3. Which describes the snooping approach to cache coherence?

Practice Multicore & Synchronization questions

Key terms explained

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.
Cache coherency
In a multicore CPU, the mechanism that keeps copies of the same address in different cores' caches consistent, for example by invalidating other copies when one core writes.
Bus snooping
A coherence approach in which each cache watches other cores' reads and writes on a shared bus or similar and updates its own line states. It suits small core counts.
Cache line
The unit in which data moves between a cache and the level below, also called a cache block. Many CPUs use 64 bytes, and the low address bits give the position (offset) within the line.
Directory-based coherence
A coherence approach that records in a table which cores hold each line and notifies only those cores. Used in systems with many cores.

Related comparisons