Module 9: Addendum to Module 6: Shared Memory Multiprocessors
  Lecture 17: Multiprocessor Organizations and Cache Coherence
 


Cache Coherence

  • Nothing unique to multiprocessors
    • Even uniprocessor computers need to worry about cache coherence
    • For sequential programs we expect a memory location to return the latest value written
    • For concurrent programs running on multiple threads or processes on a single processor we expect the same model to hold because all threads see the same cache hierarchy (same as shared L1 cache)
    • For multiprocessors there remains a danger of using a stale value: hardware must ensure that cached values are coherent across the system and they satisfy programmers' intuitive memory model

Cache Coherence: Example

    • Assume a write-through cache
      • P0: reads x from memory, puts it in its cache, and gets the value 5
      • P1: reads x from memory, puts it in its cache, and gets the value 5
      • P1: writes x=7, updates its cached value and memory value
      • P0: reads x from its cache and gets the value 5
      • P2: reads x from memory, puts it in its cache, and gets the value 7 (now the system is completely incoherent)
      • P2: writes x=10, updates its cached value and memory value