Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Course
  • Reading Path
  • Cache Coherency Glossary
  • The Shared Course Model
  • Cache Coherency Revision Sheet
  • Why Coherence Exists8
  • States and Protocols12
    • Single-Writer, Multiple-Reader Invariant
      • SWMR Precisely
      • The Data-Value Invariant
      • Invalidate Versus Update
      • What a Violation Looks Like
    • Line States and Transitions
    • Directory Versus Snoop Fundamentals
  • Transactions12
  • Races and Controller Design8
  • Progress and the Fabric16
  • Ordering and Synchronization12
  • Performance and Scalability12
  • Real Protocols12
  • SoC Integration12
  • Power, Clocking and Reliability12
  • Verification12
  • Debug and Bring-up12
  • Interview and Design Review17
  • Capstone: A Coherent Model Lab5
Loading lesson

‹Single-Writer, Multiple-Reader Invariant
  1. Topics
  2. Cache Coherency
  3. States and Protocols
  4. Single-Writer, Multiple-Reader Invariant
  5. What a Violation Looks Like

Part 2 · States and Protocols · All levels

What a Violation Looks Like

Find the first permission failure in a deliberately broken upgrade and distinguish it from the later wrong-value symptom.

On this page

    Where does a coherence bug begin: at the stale load, or earlier? Often the first failure is a grant that permits an unsafe access. The bad load only makes that failure visible. A useful debug explanation identifies both events and connects them with a state and value history, instead of starting and ending with 'the caches disagree'.

    Prerequisite: Invalidate Versus Update. This deliberately broken MSI example begins at the same settled shared snapshot: S / 0, S / 0, H = S{C0,C1}, memory = 0; all preceding transactions are complete.

    An intentionally broken early grant

    Inject one defect: H skips invalidating C1 and sends writable Data to C0. This is not a legal alternative transaction. The trace uses no concurrent requests, so a fabric race cannot explain the failure. Data at step 2 is permission-only; C0 already has 0.

    Broken sequence with GetM, premature writable Data while C1 remains shared, a local store of one at C0, and a later local read of zero at C1.
    Intentionally incorrect upgrade: the unsafe grant precedes the stale-read symptom. Memory stays 0.

    Step

    C0 state / value

    C1 state / value

    H directory

    Memory

    Newest data

    Initial

    S / 0

    S / 0

    S{C0,C1}

    0

    C0, C1, memory: 0

    1. GetM received

    SM^D / 0

    S / 0

    S{C0,C1}, pend GetM C0, acks 0/1

    0

    C0, C1, memory: 0

    2. BUG Data received

    M / 0

    S / 0

    S{C0,C1}, pend GetM C0, BUG: no Inv sent

    0

    All still 0, SWMR already fails

    (assumed) grant delivered

    M / 0

    S / 0

    exclusive(C0), wrong: C1 not revoked

    0

    All still 0, SWMR still fails

    L. C0 local store

    M / 1

    S / 0

    exclusive(C0), wrong

    0

    C0: 1, C1 and memory stale

    L. C1 local load returns 0

    M / 1

    S / 0

    exclusive(C0), wrong

    0

    C0: 1, returned 0 is wrong

    Step 2 is the first safety violation even though all bits still agree. C1 remains allowed to serve hits while C0 has permission to change X. At C0's store the values diverge. Stipulate that C0's store has completed at the coherence interface before C1's load is issued, with neither operation speculative or buffered outside this trace. With this ordering and no intervening store, returning 0 is the wrong-value symptom. No newest value is hidden in a Data payload here because the only Data is permission-only.

    Separate the evidence you need

    Observation

    Conclusion on the stated model

    Evidence to preserve

    M / 0 beside S / 0 at step 2

    Permission failure before values differ

    Writable grant and C1's still-usable S permission

    M / 1 beside I / - with memory = 0

    Can be legal write-back

    C0's permission and responsibility for value 1

    S / 1 beside S / 1 after final write value 2

    Value failure despite legal permissions

    Reference write history, not just current agreement

    An older result in an unqualified software log

    Insufficient evidence by itself

    Named memory model, synchronization and operation order

    The last three rows are independent diagnostic classifications, not extra transactions. Check permission history, then value history. The two-invariant approach follows the Primer, second edition, Chapter 2. Also record H's pending transaction and acknowledgements: a directory saying exclusive cannot override an actual reader that was never revoked.

    The repair is the acknowledgement boundary from the preceding lesson: revoke C1, collect its Inv-Ack at H, then send permission-only Data. Waiting an arbitrary number of cycles is not equivalent evidence when delivery is reliable but variably delayed. This example establishes a safety bug; it makes no bounded-latency or eventual-completion claim. Language data races and cross-location ordering need their own model before interpreting software outcomes.

    Common pitfall

    Blaming C1's load alone encourages a patch to the load path. The first illegal state is step 2. A value-only checker can miss it until a store changes the bits; a permission checker catches the unsafe grant immediately. Coherence safety failures are correctness failures, not an acceptable statistical rate.

    Interview

    Give the earliest failing row, the violated obligation, and the mechanism that repairs it. Here: row 2 violates SWMR, the missing revocation permits C1's stale hit, and H must collect the required acknowledgement before writable Data. Equal bits at the first failure are the useful detail.

    Check yourself If C0 never performs its store, is the early grant still a coherence bug?

    Yes. C0 = M / 0 and C1 = S / 0 grants mutually incompatible access even without a store. Permission safety is an invariant, so a trace need not reach a wrong-value load before it is rejected.

    Related topics

    • Course Model

    • SWMR Precisely

    • The Data-Value Invariant

    • Correct Upgrade and Acknowledgement Boundary

    Previous

    17 / 167

    Next: Line States and Transitions

    Up next

    Up nextLine States and Transitions

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • SWMR Precisely
    • The Data-Value Invariant