Cache Coherence Protocols must enforece two rules:
- Write propagation: Writes eventually become visible to all processors. 写操作最终所有处理器均可见。
- Write serialization: Writes to the same location are serialized (all processors see them in the same order). 写操作的顺序应当保持一致。
How to ensure write propagation?
- Write-invalidate protocols: Invalidate all other cached copied before performing the write. 执行写操作前,使其他所有的缓存备份失效。
- Write-update protocols: Update all other cached copies after performing the write. 执行写操作之后,更新其他所有缓存备份。
How to ensure write serialization?
- Snooping-based protocols: All caches observe each other's actions through a shared bus. 所有缓存通过共享总线观测其他缓存的行为。
- Directory-based protocols: A coherence directory tracks contents of private caches and serializes requests. 一致性目录跟踪专用缓存的内容并对请求序列化。