cachingmultiprocessingcpu-architecturecpu-cachemesi

Which MESI protocol states are relevant if cache with write-through policy is used?


I came across following question, while reading the slides of a lecture about cache coherency protocols: Which MESI states are relevant, if cache with write-through policy is used?

The answer was also given: I (Invalid) and S (Shared Unmodified).

I understand that the state M (Modified Exclusive) is not relevant, since cache with write-through policy propagates the changes to main memory anyway.

The state E (Exclusive Unmodified) is not relevant, since it's only issued when exclusive read misses with replacement occur (and is kept with further read hits).

Can someone explain the given answer?


Solution

  • As you mentioned, M state is pretty obviously useless since you never keep modified data in your cache.

    As for Exclusive state: keep in mind that in some sense it's "stronger" than shared state, since in WB caches, it guarantees that a write to that line doesn't need to obtain ownership and invalidate other copies first, and instead can write directly to that line without having to go out of the local cache. In other words, the transition from E to M is simple, while S to M is more complicated and requires invalidating all other copied first.

    On the other hand, in a WT cache you already have the guarantee that no one else is holding a modifies version of the line, and more importantly - you don't have the benefit of doing the simple transition in your local cache (since you have to write the data outside anyway), so there's really no need for an exclusive state - you gain no benefit from having it. In fact, you may actually lose from it, because having an E state forces you to send snoops on any other core reading the same line (E -> S transition),

    Of course, when writing something outside, you'll still need to invalidate all other copies, but you don't need the distinction between E and S to tell you if they exist, usually there's a snoop filter or some other list to tell you which cores to snoop.