MESI protocol

From Wikipedia, the free encyclopedia

The MESI protocol (known also as Illinois protocol) is a widely used cache coherency and memory coherence protocol, which was later introduced by Intel in the Pentium processor to "support the more efficient write-back cache in addition to the write-through cache previously used by the Intel 486 processor" [1].

Contents

[edit] States

Every cache line is marked with one of the four following states (coded in two additional bits):

  • M - Modified: The cache line is present only in the current cache, and is dirty; it has been modified from the value in main memory. The cache is required to write the data back to main memory at some time in the future, before permitting any other read of the (no longer valid) main memory state.
  • E - Exclusive: The cache line is present only in the current cache, but is clean; it matches main memory.
  • S - Shared: Indicates that this cache line may be stored in other caches of the machine.
  • I - Invalid: Indicates that this cache line is invalid.

[edit] Operation

A cache may satisfy a read from any state except Invalid. An Invalid line must be fetched (to the Shared or Exclusive states) to satisfy a read.

A write may only be performed if the cache line is in the Modified or Exclusive state. If it is in the Shared state, all other cached copies must be invalidated first. This is typically done by a broadcast operation known as Read For Ownership (RFO).

A cache may discard a non-Modified line at any time, changing to the Invalid state. A Modified line must be written back first.

A cache that holds a line in the Modified state must snoop (intercept) all attempted reads (from all of the other CPUs in the system) of the corresponding main memory location and insert the data that it holds. This is typically done by forcing the read to back off (i.e. to abort the memory bus transaction), then writing the data to main memory and changing the cache line to the Shared state.

A cache that holds a line in the Shared state must also snoop all invalidate broadcasts from other CPUs, and discard the line (by moving it into Invalid state) on a match.

A cache that holds a line in the Exclusive state must also snoop all read transactions from all other CPUs, and move the line to Shared state on a match.

The Modified and Exclusive states are always precise: i.e. they match the true cacheline ownership situation in the system. The Shared state may be imprecise: if another CPU discards a Shared line, and this CPU becomes the sole owner of that cacheline, the line will not be promoted to Exclusive state (because broadcasting all cacheline replacements from all CPUs is not practical over a broadcast snoop bus).

In that sense the Exclusive state is an opportunistic optimization: If the CPU wants to modify a cache line that is in state S, a bus transaction is necessary to invalidate all other cached copies. State E enables modifying a cache line with no bus transaction.

[edit] Read For Ownership

A Read For Ownership (RFO) is an operation in cache coherency protocols. The operation is issued by a processor trying to write into a cache line that is not exclusive or not modified to itself, i.e., that is in the shared (S) or invalid (I) states of the MESI protocol. The operation causes all other processors to set the state of such line to I.

[edit] See also

[edit] References

  1. ^ IA-32 Intel Architecture Software Developers Manual

[edit] External links