Previous | Next --- Slide 9 of 64
Back to Lecture Thumbnails
Iamme

I'm still a bit confused as to why we need the modified-but-stale bit, the in-L1 bit, AND the M (modified) state.

It seems that we have the following cases for a line in L1: 1. Not in L1 ==> not modified since the last time it was flushed from L1 (when there would have been a write to memory if it was modified at the time) 2. In L1 and not modified 3. In L1 and modified ==> the version in L2 should be stale

Since we only have 3 cases, why do we need 3 bits? Specifically, it seems like in-L1 and modified both being true implies modified-but-stale, and this is the only time modified-but-stale occurs. What am I missing?

taoy1

@lamme I have the same question with you. If line is in L1 and both L1 and L2 is in Modified state, then we need to require data from L1, otherwise don't. So why do we need modified-but-stale bit?

MangoSister

This is silly but what will happen if there's a L1 write miss but L2 write hit? How is coherence maintained in all possible situations (write-through/write-back, write-allocation/no-write-allocate)?

Iamme

You mean a miss in L1 and hit in L2 when trying to write? I believe the line is moved to the L1 cache before the write, since caches are assumed to be LRU, and this line is now the most recently used.

kevinle1

@taoy1 I think the difference is that on a write-miss, line X will be put in modified state into both L1 and L2. However, subsequent writes will be a hit in L1, and thus the changes won't propagate to L2. If we are in the first case, we would just pull the data from L2, but in the second case, we can't, so we need that bit to tell us to go look in L1.