Chapter 5: Q17E (page 495)
Cache coherence concerns the views of multiple processors on a given cache block. The following data shows two processors and their read/write operations on two different words of a cache block X (initially X[0] = X[1] = 0). Assume the size of integers is 32 bits.
P1 | P2 |
5.17.1 List the possible values of the given cache block for a correct cache coherence protocol implementation. List at least one more possible value of the block if the protocol doesn’t ensure cache coherency.
5.17.2 For a snooping protocol, list a valid operation sequence on each processor/cache to finish the above read/write operations.
5.17.3 What are the best-case and worst-case numbers of cache misses
needed to execute the listed read/write instructions?
Memory consistency concerns the views of multiple data items. The following data shows two processors and their read/write operations on different cache blocks (A and B initially 0).
P1 | P2 |
5.17.4 List the possible values of C and D for an implementation that ensures both consistency assumptions on page 470.
5.17.5List at least one more possible pair of values for C and D if such assumptions are not maintained.
5.17.6 For various combinations of write policies and write allocation policies, which combinations make the protocol implementation simpler?
Short Answer
4.17.1.The possible values of the given cache block for a correct cache coherence protocol implementation
Order 1:
P1 | P2 |
| |
|
Order 2:
P1 | P2 |
X [1] = 3; | |
X [1] + = 2; |
Order 3:
P1 | P2 |
| X [0] = 5; |
X [0]++; | |
X [1] + = 2; | |
X [1] = 3; |
Order 4:
P1 | P2 |
X [0] ++; | |
X [0] = 5; | |
X [1] +=2; | |
X [1] =3; |
Order 5:
P1 | P2 |
X [0] = 5 | |
X [0] ++; | |
X [1] = 3 | |
X [1] += 2 |
Order 6:
P1 | P2 |
X [0] = 5 | |
X [1] += 2 | |
X [0] ++; | |
X [1] = 3 |
If coherency is not ensured, then P2’s operations take precedence over P1’s.
4.17.2For a snooping protocol, the list of valid operation sequences on each processor/cache to finish the above read/write operations is as follows:
P1 | P1 Cache status | P2 | P2 Cache status |
X [0] = 5 | Invalidate X on other caches, Read X and Write X block | ||
X [1] += 2; | read and write X block | ||
X [0] ++; | Read X value | X block is shared | |
Send invalidate message | X block is invalided | ||
Write X block | |||
X [1] = 3; | Write X block |
4.17.3 Best case: Orderings 1 and 6
Worst Case: Orderings 2 and 3
4.17.4The possible values of the given cache block for a correct cache coherence protocol implementation with C and D.
Order 1:
P1 | P2 |
A = 1 | |
B = 2 | |
A+ =2; | |
B++; | |
C = B | |
D = A |
Order 2:
P1 | P2 |
A = 1 | |
B = 2 | |
A+ =2; | |
C = B | |
B ++; | |
D = A |
Order 3:
P1 | P2 |
A = 1 | |
B = 2 | |
C = B | |
A+ =2; | |
B ++; | |
D = A |
Order 4:
P1 | P2 |
A = 1 | |
C = B | |
B = 2 | |
A+ =2; | |
B ++; | |
D = A |
Order 5:
P1 | P2 |
C = B | |
A = 1 | |
B = 2 | |
A+ =2; | |
B++; | |
D = A |
Order 6:
P1 | P2 |
A = 1 | |
B = 2 | |
A+ =2; | |
C = B | |
D = A | |
B ++; |
Order 7:
P1 | P2 |
A = 1 | |
B = 2 | |
C = B | |
A+ =2; | |
D = A | |
B ++; |
Order 8:
P1 | P2 |
A = 1 | |
C = B | |
B = 2 | |
A+ =2; | |
D = A | |
B ++; |
Order 9:
P1 | P2 |
C = B | |
A = 1 | |
B = 2 | |
A+ =2; | |
D = A | |
B ++; |
Order 10:
P1 | P2 |
A = 1 | |
B = 2 | |
C = B | |
D = A | |
A+ =2; | |
B ++; |
Order 11:
P1 | P2 |
A = 1 | |
C = B | |
B = 2 | |
D = A | |
A+ =2; | |
B ++; |
Order 12:
P1 | P2 |
C = B | |
A = 1 | |
B = 2 | |
D = A | |
A+ =2; | |
B ++; |
Order 13:
P1 | P2 |
A = 1 | |
C = B | |
D = A | |
B = 2 | |
A+ =2; | |
B ++; |
Order 14:
P1 | P2 |
C = B | |
A = 1 | |
D = A | |
B = 2 | |
A+ =2; | |
B ++; |
Order 15:
P1 | P2 |
C = B | |
D = A | |
A = 1 | |
B = 2 | |
A+ =2; | |
B ++; |
5.17.5 Result: (2,0) for B=0, not preceding by A=1
5.17.6 Write Back is simpler.