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
    • Caches and Shared Data
      • Caches, Lines and Write-Back
      • Two Cores Disagree
      • What Coherence Promises
      • The Course Model in Action
    • Permissions and Values
  • States and Protocols12
  • 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

‹Caches and Shared Data
  1. Topics
  2. Cache Coherency
  3. Why Coherence Exists
  4. Caches and Shared Data
  5. The Course Model in Action

Part 1 · Why Coherence Exists · All levels

The Course Model in Action

Follow a cold shared read and a conflicting write request, including the acknowledgement that makes the handoff safe.

On this page

    When exactly may the second core write?

    C0 has read X. C1 now wants to store 1. Is sending an invalidation enough? No: the old reader must lose permission before the new writer receives it. Prerequisite: S is read-only, I has no usable value, and write permission excludes other usable copies. This example selects MSI, so the first cold read grants S rather than MESI's optional E.

    Reset the course machine: memory holds X = 0 and neither cache has a copy. H serializes conflicting transactions for X. Transaction A completes before B starts; the local store follows B's Data delivery.

    C0 reads zero, C1 requests writing, H invalidates C0 and receives its acknowledgement before sending C1 zero with M permission.
    MSI: transaction A has two messages; B has four. Inv-Ack returns to H before Data grants C1 write permission.

    Step

    C0 state / value

    C1 state / value

    H directory

    Memory

    Newest data

    Initial

    I / -

    I / -

    U

    0

    Memory: 0

    1. GetS received

    IS^D / -

    I / -

    U, pend GetS C0

    0

    Memory: 0

    2. Data received

    S / 0

    I / -

    U, pend GetS C0

    0

    C0 and memory: 0

    (assumed) grant delivered

    S / 0

    I / -

    S{C0}

    0

    C0 and memory: 0

    3. GetM received

    S / 0

    IM^D / -

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

    0

    C0 and memory: 0

    4. Inv received

    I / -

    IM^D / -

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

    0

    Memory: 0

    5. Inv-Ack received

    I / -

    IM^D / -

    U, pend GetM C1, acks 1/1

    0

    Memory: 0

    6. Data received

    I / -

    M / 0

    U, pend GetM C1, acks 1/1

    0

    C1 and memory: 0

    (assumed) grant delivered

    I / -

    M / 0

    exclusive(C1)

    0

    C1 and memory: 0

    L. Local store

    I / -

    M / 1

    exclusive(C1)

    0

    C1: 1

    C1 is in IM^D ('was I, wants M, waiting for Data') from step 3 to step 6: it waits only for Data, because H collects the acknowledgement. While H awaits C0's acknowledgement its recorded sharer can conservatively outlive C0's actual copy (step 4). At step 5 H has no sharers left (U), but the pending GetM keeps it busy; it is not free for another request. H keeps that pending entry in the step-6 row and records exclusive(C1) only in the '(assumed) grant delivered' row: it starts no conflicting transaction for X until the step-6 grant has been delivered.

    The acknowledgement carries evidence

    Step 4 removes C0's permission. Step 5 tells H it has been removed. Only then may H send step 6. This causal wait establishes safety without relying on any message order. No core can write in the initial idle/read epoch; C1 cannot write during its pending request. M / 0 at step 6 is a conservative dirty-responsibility state even though the stored bits still match memory; L makes the difference visible.

    If C1 had already held a valid S copy, the upgrade would still wait for the required acknowledgement and end with permission-only Data, as in Epochs and Serialization. Real controllers track the same outstanding work in transient states: compare the descriptions in the gem5 MESI Two Level documentation.

    Common pitfall

    Sending Inv is not evidence that it has arrived. A grant before Inv delivery could expose C1 as a writer while C0 still has a usable copy. At the step-4 delivery boundary C0 is already I, but H has not yet received the required confirmation. H must wait for step 5, Inv-Ack received, before sending the write grant.

    Interview

    Draw the dependency, not just the arrows: C0 loses permission, H receives evidence, C1 receives write permission, then the local store changes the value. Explain why every table row preserves exclusive writing.

    Check yourself After step 5, may C1 store 1 because all acknowledgements have arrived at H?

    No. H has the evidence, but C1 is still in IM^D and has no usable value or write permission. C1 must receive Data with M permission at step 6 before the local store.

    Related topics

    • Course Model

    • Review: What Coherence Promises

    • Up: Caches and Shared Data

    Previous

    9 / 167

    Next: Permissions and Values

    Up next

    Up nextPermissions and Values

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Caches, Lines and Write-Back
    • Two Cores Disagree