MOESI protocol
Encyclopedia
In computing, MOESI is a full cache coherency
protocol that encompasses all of the possible states commonly used in other protocols. In addition to the four common MESI protocol
states, there is a fifth "Owned" state representing data that is both modified and shared. This avoids the need to write modified data back to main memory before sharing it. While the data must still be written back eventually, the write-back may be deferred.
As discussed in AMD64 Architecture Programmer's Manual Vol 2 'System Programming', each cache line is in one of five states:
Modified: A cache line in the modified state holds the most recent, correct copy of the data. The copy in main memory is stale (incorrect), and no other processor holds a copy. The cached data may be modified at will. The cache line may be changed to the Exclusive state by writing the modifications back to main memory. Modified cache lines must respond to a snoop request with data.
Owned: A cache line in the owned state holds the most recent, correct copy of the data. The owned state is similar to the shared state in that other processors can hold a copy of the most recent, correct data. The copy in main memory can be stale (incorrect). Only one processor can hold the data in the owned state—all other processors must hold the data in the shared state. The cache line may be changed to the Modified state after invalidating all shared copies, or changed to the Shared state by writing the modifications back to main memory. Owned cache lines must respond to a snoop request with data.
Exclusive: A cache line in the exclusive state holds the most recent, correct copy of the data. The copy in main memory is also the most recent, correct copy of the data. No other processor holds a copy of the data. The cache line may be changed to the Modified state at any time in order to modify the data. It may also be discarded (changed to the Invalid state) at any time. Exclusive cache lines may respond to a snoop request with data.
Shared: A cache line in the shared state holds the most recent, correct copy of the data. Other processors in the system may hold copies of the data in the shared state, as well. The shared cache line may be dirty with respect to memory (if a copy of the cache line exists in the owned state) or it may be clean (if no copy of the cache line exists in the owned state). The cache line may not be written, but may be changed to the Exclusive state after invalidating all shared copies. It may also be discarded (changed to the Invalid state) at any time. Shared cache lines may not respond to a snoop request with data.
Invalid: A cache line in the invalid state does not hold a valid copy of the data. Valid copies of the data might be either in main memory or another processor cache.
For any given pair of caches, the permitted states of a given cache line are as follows:
(The order in which the states are normally listed serves only to make the acronym "MOESI" pronounceable.)
This protocol, a more elaborate version of the simpler MESI protocol
, avoids the need to write a dirty cache line back to main memory when another processor tries to read it. Instead, the Owned state allows a processor to supply the modified data directly to the other processor. This is beneficial when the communication latency and bandwidth between two CPUs is significantly better than to main memory. An example would be multi-core CPUs with per-core L2 caches.
While MOESI can quickly share dirty cache lines from cache, it cannot quickly share clean lines from cache. If a cache line is clean with respect to memory and in the shared state, then any snoop request to that cache line will be filled from memory, rather than a cache.
If a processor wishes to write to an Owned cache line, it must notify the other processors that are sharing that cache line. Depending on the implementation it may simply tell them to invalidate their copies (moving its own copy to the Modified state), or it may tell them to update their copies with the new contents (leaving its own copy in the Owned state).
Cache coherency
In computing, cache coherence refers to the consistency of data stored in local caches of a shared resource.When clients in a system maintain caches of a common memory resource, problems may arise with inconsistent data. This is particularly true of CPUs in a multiprocessing system...
protocol that encompasses all of the possible states commonly used in other protocols. In addition to the four common MESI protocol
MESI protocol
The MESI protocol is a widely used cache coherency and memory coherence protocol. It is the most common protocol which supports write-back cache...
states, there is a fifth "Owned" state representing data that is both modified and shared. This avoids the need to write modified data back to main memory before sharing it. While the data must still be written back eventually, the write-back may be deferred.
As discussed in AMD64 Architecture Programmer's Manual Vol 2 'System Programming', each cache line is in one of five states:
Modified: A cache line in the modified state holds the most recent, correct copy of the data. The copy in main memory is stale (incorrect), and no other processor holds a copy. The cached data may be modified at will. The cache line may be changed to the Exclusive state by writing the modifications back to main memory. Modified cache lines must respond to a snoop request with data.
Owned: A cache line in the owned state holds the most recent, correct copy of the data. The owned state is similar to the shared state in that other processors can hold a copy of the most recent, correct data. The copy in main memory can be stale (incorrect). Only one processor can hold the data in the owned state—all other processors must hold the data in the shared state. The cache line may be changed to the Modified state after invalidating all shared copies, or changed to the Shared state by writing the modifications back to main memory. Owned cache lines must respond to a snoop request with data.
Exclusive: A cache line in the exclusive state holds the most recent, correct copy of the data. The copy in main memory is also the most recent, correct copy of the data. No other processor holds a copy of the data. The cache line may be changed to the Modified state at any time in order to modify the data. It may also be discarded (changed to the Invalid state) at any time. Exclusive cache lines may respond to a snoop request with data.
Shared: A cache line in the shared state holds the most recent, correct copy of the data. Other processors in the system may hold copies of the data in the shared state, as well. The shared cache line may be dirty with respect to memory (if a copy of the cache line exists in the owned state) or it may be clean (if no copy of the cache line exists in the owned state). The cache line may not be written, but may be changed to the Exclusive state after invalidating all shared copies. It may also be discarded (changed to the Invalid state) at any time. Shared cache lines may not respond to a snoop request with data.
Invalid: A cache line in the invalid state does not hold a valid copy of the data. Valid copies of the data might be either in main memory or another processor cache.
For any given pair of caches, the permitted states of a given cache line are as follows:
M | O | E | S | I | |
---|---|---|---|---|---|
M | |||||
O | |||||
E | |||||
S | |||||
I |
(The order in which the states are normally listed serves only to make the acronym "MOESI" pronounceable.)
This protocol, a more elaborate version of the simpler MESI protocol
MESI protocol
The MESI protocol is a widely used cache coherency and memory coherence protocol. It is the most common protocol which supports write-back cache...
, avoids the need to write a dirty cache line back to main memory when another processor tries to read it. Instead, the Owned state allows a processor to supply the modified data directly to the other processor. This is beneficial when the communication latency and bandwidth between two CPUs is significantly better than to main memory. An example would be multi-core CPUs with per-core L2 caches.
While MOESI can quickly share dirty cache lines from cache, it cannot quickly share clean lines from cache. If a cache line is clean with respect to memory and in the shared state, then any snoop request to that cache line will be filled from memory, rather than a cache.
If a processor wishes to write to an Owned cache line, it must notify the other processors that are sharing that cache line. Depending on the implementation it may simply tell them to invalidate their copies (moving its own copy to the Modified state), or it may tell them to update their copies with the new contents (leaving its own copy in the Owned state).