liveBook · Manning

Cache coherence protocol

As explained in Latency

A cache coherence protocol is a set of rules that coordinates caches so copies of shared data are updated or invalidated consistently.

A cache coherence protocol coordinates per-core caches so copies of shared data remain consistent. When one core writes cached data, other caches update or invalidate their copies instead of returning stale values. section 6.4

Coherence lets programs read and write memory as though no cache intervened, but coordination adds latency and makes updates more expensive. Distributed caches may instead tolerate stale reads. section 6.4

Two cores cache the same value

Two CPU cores read the same memory region and cache it locally. If one core writes the value, a coherence protocol ensures the other cache updates or invalidates its copy, preventing an incoherent view. section 6.4

MESI models each cache line, such as a 64-byte block, with states including:

  • Modified (M): one cache holds a valid, modified copy and may change it further. section 6.4
  • Exclusive (E): one cache holds an unmodified copy matching main memory. section 6.4

How Latency covers it

How deep it goes
Defines stale-cache failures, explains update or invalidation, and introduces MESI states without detailing complete transitions.
Examples
Uses two cores caching one memory region and a 64-byte cache line to illustrate writes, stale copies, and MESI states.
What it assumes
Assumes familiarity with CPU caches and memory while establishing shared cached data through a two-core scenario.
What you can do after
Evaluate/understand how multicore caches prevent stale reads and why coherence coordination adds latency.
How it connects
Connects cache coherence with CPU caches, cache lines, multicore systems, main memory, MESI, and distributed caches.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Latency. The section links point to the parts of the book it draws on.