Description:
- Problem: processors cache shared data but each core has their own cache, then they might have (incoherent) values for the same memory location
Snooping:
- Every cache that has a copy of the data from a block of the memory also has a copy of the sharing status of the block but no centralized status is kept
- Cache controller snoop on the shared bus to determine whether or not they have a copy of a block that is requested on the bus
- But Snooping doesn’t scale
Cache coherence protocols based on snooping:
-
Write Invalidate Protocol:
- With write-thru cache:
- ex
Step | Event | bus | x in core 0 | x in core 1 | x in mem |
---|---|---|---|---|---|
0 | 0 | ||||
1 | Core 0 reads x | cache miss | 0 | 0 | |
2 | Core 1 reads x | cache miss | 0 | 0 | 0 |
3 | Core 0 write 1 to x | invalidate x | 1 | x | 0 (doesnt change yet) |
4 | Core 1 reads x | cache miss | 1 | 1 | 1 (change here) |
- Modified Shared Invalid Protocol:
- States and Transitions: The MSI protocol defines three states for cache blocks: Modified, Shared, and Invalid.
- The Modified state indicates that a cache block has been modified and differs from the main memory.
- The Shared state indicates that the cache block is valid and has multiple copies across different caches.
- The Invalid state denotes that the cache block is invalid or not present in the cache.
- Handling Modified and Shared Data: In the MSI protocol, when a cache block is in the Modified state, any write operation triggers an invalidation of other copies in different caches.
- The Modified state allows the cache to retain ownership of the block, ensuring exclusive modification rights.
- When a cache block is in the Shared state, read operations can be performed, but write operations require transitioning to the Modified state.
- States and Transitions: The MSI protocol defines three states for cache blocks: Modified, Shared, and Invalid.
- Modied Owner Shared Invalid Protocol
- Introduction to Owned State: The MOSI protocol extends the MSI protocol by introducing an additional Owned state. The Owned state indicates that a cache holds the exclusive ownership of a block, allowing both read and write operations without invalidating other copies.
- Improved Handling of Ownership: The Owned state in the MOSI protocol provides an advantage over the MSI protocol. When a cache wants to modify a block in the Owned state, it can directly update the block without invalidating other copies. This reduces bus traffic and improves performance compared to the MSI protocol.
- Modified Exclusive Shared Invalid Protocol
- Widely Used Cache Coherence Protocol: The MESI protocol is one of the most commonly used cache coherence protocols. It extends the MSI protocol by introducing the Exclusive state, which allows a cache to hold a copy of a block exclusively, indicating that no other cache has a copy.
- Advantages of Exclusive and Modified States: The Exclusive state in the MESI protocol enables faster read operations by allowing caches to read the block without checking for other copies. When a cache wants to modify a block in the Exclusive state, it can transition to the Modified state directly without invalidating other copies. This reduces the need for unnecessary bus transactions, enhancing performance.
- Modified Owner Exclusive Shared Invalid Protocol, …
Directory-based protocols
- Caches & memory record blocks’ sharing status in directory
- directory protocols are slower