6.1.6 · D3Parallelism & Multicore

Worked examples — Cache coherence at scale (directory-based)

2,846 words13 min readBack to topic

This page is the drill floor. The parent note told you how directory protocols work; here we run the machine through every kind of situation it can meet — every starting state, every degenerate corner, a real word problem, and an exam trap — and check the arithmetic on each one.

Before we touch an example, one promise: we will use no symbol you haven't met. Let us re-earn the three things that appear over and over.


The scenario matrix

Every case a directory protocol can face is a combination of (starting state) × (operation), plus the degenerate and real-world corners. Here is the full grid; each cell names the example that covers it.

# Starting state Operation Degenerate / twist Covered by
1 Uncached Read first-ever touch (base case) Ex 1
2 Shared Read add a sharer, no data movement Ex 2
3 Modified (other owner) Read owner must write back Ex 3
4 Shared (many sharers) Write invalidate all + ack-count Ex 4
5 Modified (other owner) Write invalidate-forward, ownership transfer Ex 5
6 Shared, you already hold it Write (upgrade) zero data transfer, self not invalidated Ex 6
7 any storage cost limiting cases (, huge ) Ex 7
8 any NUMA home routing by address bits (word problem) Ex 8
9 Shared Write exam twist: race — two writers at once Ex 9

Nine cells, nine examples. Read the "Forecast:" line and guess before unfolding the steps.


The worked examples


Recall Quick self-test

Ex 3: on a read to a Modified block, who supplies data — memory or the owner? ::: The owner (memory is stale until the write-back). Ex 4: HD holds Shared with 3 sharers; a write arrives — how many Inv-Ack must it collect? ::: All 3, before granting the write. Ex 6: a current sharer upgrades to write — how many bytes of data move to it? ::: Zero; it already holds a valid copy, so only an ack (no payload). Ex 7: full-map directory storage grows like or ? ::: Linear in (the bit-vector), never . Ex 8: consecutive 256B blocks under interleaving land on the same or different sockets? ::: Different sockets, by design, to spread load. Ex 9: what stops two simultaneous writers from both owning the block? ::: The home directory serializes requests for one address — one arbiter, one order.

See also: Cache coherence protocols (MESI, MOESI) · NUMA architectures · Interconnect topologies · Memory consistency models · Cache line false sharing · back to the parent topic.