Professional Documents
Culture Documents
Snooping Protocols Examples
Snooping Protocols Examples
Example 1: Consider a bus-based shared memory system consisting of three processors. The shared
memory is divided into three blocks x, y, z. Each processor has a cache that can fit only two blocks at
any given time. Each block can be in one of two states: valid (V) or invalid (I). Assume that caches are
initially flushed (empty) and that the contents of the memory are as follows:
Memory block X y Z
Contents 10 100 1000
Example 2: Consider a bus-based shared memory system consisting of three processors. The shared
memory is divided into three blocks x, y, z. Each processor has a cache that can fit only one block at
any given time. Assume that caches are initially flushed (empty) and that the contents of the memory
are as follows:
Memory block x y z
Contents 10 30 80
Consider, the following sequence of memory access events given in order:
1) P1: Read(x), 2) P1: x = x + 25, 3) P2: Read(x), 4) P3: Read(x), 5) P1: Read(z),
6) P3: x =15, 7) P1: z = z +10, 8) P2: Read(x).
Show the contents of the caches and memory and the state of cache blocks after each of the above
operations in the write-back and write-invalidate protocol.
Solution:
let V=valid , I=invalid, RO=read Only, RW=Read-Write states, then the contents of the caches and
memory and the state of cache blocks after each of the above operations using the write-back and
write-invalidate protocol is shown in table given below:
Example 3: Consider a bus-based shared memory system consisting of three processors. The shared
memory is divided into three blocks x, y, z. Each processor has a cache that can fit only two blocks at
any given time. Assume that caches are initially flushed (empty) and that the contents of the memory
are as follows:
Memory block X Y z
Contents 10 20 30
Consider the following sequence of memory access events given in order:
1) P1: Read(x, y), 2) P2: Read(x, z), 3) P3: Read(y, z), 4) P1: x = x + 10, 5) P1: Read(z), 6) P2:
Read(x), 7) P3: x = 15, 8) P3: Read(y), 9) P3: y = y+x, 10) P1: z = z + 10.
Show the contents of the caches and memory and the state of cache blocks after each of the
above operations using the write once protocol.
Solution:
let V=valid , I=invalid, RES=Reserved, D=Dirty states, then the contents of the caches and memory
and the state of cache blocks after each of the above operations using the write once protocol is shown
in table given below:
Instruction Action XYZ P1 P2 P3
1) P1: Read(x, y) Read miss 10,20,30 10V, 20V -- --
2) P2: Read(x, z) Read miss 10,20,30 10V, 20V 10V, 30V --
3) P3: Read(y, z) Read miss 10,20,30 10V, 20V 10V, 30V 20V, 30V
4) P1: x = x + 10 Write hit 20,20,30 20 RES, 20V 10I, 30V 20V, 30V
5) P1: Read(z) Read miss 20,20,30 20 RES, 30V 10I, 30V 20V, 30V
6) P2: Read(x) Read miss 20,20,30 20V, 30V 20V, 30V 20V, 30V
7) P3: x = 15 Write miss 20,20,30 20I, 30V 20I, 30V 15D, 30V
8) P3: Read(y) Read miss 20,20,30 20I, 30V 20I, 30V 15D, 20V
9) P3: y = y + x Write hit 20,35,30 20I, 30V 20I,30V 15D, 35 RES
10) P1: z=z +10 Write hit 20,35,30 20I, 40D 20I, 30I 15D, 35 RES
H.w.1: Consider a bus-based shared memory system consisting of three processors. The shared
memory is divided into three blocks x, y, z. Each processor has a cache that can fit only two
blocks at any given time. Assume that caches are initially flushed (empty) and that the contents
of the memory are as follows:
Memory block X Y Z
Contents 10 20 30
Consider the following sequence of memory access events given in order:
1) P1: Read(x, y), 2) P2: Read(x, z), 3) P3: Read(y, z), 4) P1: x = x + 10, 5) P1: Read(z),
6) P3:z=z+5, 7) P2: Read(x), 8) P3: x = 15, 9) P2: Read(z), 10) P1: x = x+y, 11) P1: z = z +
10, 12) z is replaced in P1 cache.
Show the contents of the caches and memory and the state of cache blocks after each of
the above operations using the write-invalidate and write-back protocol.
H.w.2: Consider a bus-based shared memory system consisting of three processors.The shared
memory is divided into four blocks x, y, z, w. Each processor has a cache that can fit only one block at
any given time. Each block can be in one of two states: valid (V) or invalid (I). Assume that caches are
initially flushed (empty) and that the contents of the memory are as follows:
Memory block x y z w
Contents 10 30 80 20
Consider, the following sequence of memory access events given in order:
1)P1: Read(x), 2)P2: Read(x), 3)P3: Read(x), 4)P1: x=x+25, 5)P1: Read(z), 6)P2: Read(x),
7)P3:x=15, 8)P1:z=z+1
Show the contents of the caches and memory and the state of cache blocks after each of the above
operations in the following cases: (1) write-through and write-invalidate and (2) write-back and
write-invalidate.
H.W.3: Consider a bus-based shared memory system consisting of three processors. The shared
memory is divided into three blocks x, y, z. Each processor has a cache that can fit only two blocks at
any given time. Each block can be in one of two states: valid (V) or invalid (I). Assume that caches are
initially flushed (empty) and that the contents of the memory are as follows:
Memory block x y z
Contents 10 20 30
Consider the following sequence of memory access events given in order:
1) P1: Read(x, y), 2) P2: Read(x, z), 3) P3: Read(y, z), 4) P1: x = x + 10, 5) P1: Read(z), 6) P2:
Read(x), 7) P3: x = 25, 8) P1: z = z + 10, 9) P2: x = 5, 10) P2: z = z + 10
Show the contents of the caches and memory and the state of cache blocks after each of the
above operations using the write once protocol.
Chained Directories Chained directories emulate full-map by distributing the directory among
the caches. They are designed to solve the directory size problem without restricting the number
of shared block copies. Chained directories keep track of shared copies of a particular block by
maintaining a chain of directory pointers.
Figure -3 shows that the directory entry associated with X has a pointer to Cache C2,
which in turn has a pointer to Cache C0. That is, block X exists in the two Caches C0 and
Cache C2. The pointer from Cache C0 is pointing to terminator (CT), indicating the end of the
list.