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 Paths
  • Concept Map
  • How to Read the Diagrams
  • Part 0: What Is a Protocol?10
  • Part 1: Timing and Clocking11
  • Part 2: Encoding and Framing12
  • Part 3: Handshakes13
  • Part 4: Flow Control17
  • Part 5: Transactions19
  • Part 6: Concurrency and Performance17
  • Part 7: Ordering13
    • Why Ordering Matters
    • Ordering Scopes
    • The Point of Serialisation
    • Early and Final Acknowledgement
    • Fences and Barriers
    • Ordering Tables
    • Relaxed and ID-Based Ordering
    • Same-Address Hazards
    • Interrupt and Data Ordering
    • Memory Consistency Models
    • Ordering Across Bridges
    • Protocols Compared: Ordering
    • Drills: Ordering
  • Part 8: Sharing and Arbitration12
  • Part 9: Deadlock and Liveness13
  • Part 10: Reliability and Recovery20
  • Part 11: Bring-Up and Link Management10
  • Part 12: Power8
  • Part 13: Shared State and Coherence9
  • Part 14: Security and Isolation7
  • Part 15: Specifying and Verifying11
  • Part 16: Protocols Dissected17
  • Part 17: Capstones5
  • Part 18: Interview Preparation6
Loading lesson

‹Part 7: Ordering
  1. Topics
  2. First Principles of Hardware Protocols
  3. Part 7: Ordering
  4. Interrupt and Data Ordering

Part 7 · Ordering · Senior (S)

Interrupt and Data Ordering

An interrupt is the flag of the most common producer/consumer pair: DMA data, then "done". Why a message-signalled interrupt is ordered behind the data it announces, why a wired interrupt is not, and what drivers do about it.

On this page

    Note

    Level: Senior (S) · Answers: In what order do results become visible?

    Before this: Ordering Tables, Interrupts and Notification

    A storage device finishes reading a block, writes it into memory by DMA, and signals completion. With one kind of interrupt, the driver always finds the block complete. With another, it occasionally finds part of the old contents, and the bug disappears whenever someone adds a debug print to the handler. The device is the same; only the interrupt mechanism differs.

    Why does the kind of interrupt decide whether the data is there when the handler runs?

    The obvious answer, and why it breaks

    The obvious assumption is that a device signals completion only after it has finished writing, so the data must be in memory. But "finished writing" from the device's side means the writes have left the device, not that they have arrived. They may still be queued in a switch or a write buffer. Whether the interrupt can overtake them depends entirely on whether it travels on the same ordered path.

    The idea: the interrupt is the flag

    DMA data followed by an interrupt is data-then-flag (lesson 7.1), with the interrupt as the flag. It is safe only if the interrupt cannot become visible before the data.

    Mechanism

    Path

    Ordered behind the data?

    Message-signalled interrupt

    A posted memory write on the same path as the DMA writes

    Yes: a posted write may not pass earlier posted writes from the same device (lesson 7.6)

    Wired interrupt

    A separate wire to the interrupt controller

    No: it is not on the data path at all

    Emulated wired interrupt (message)

    A message on the link, but not required to follow the ordering of memory writes

    Not guaranteed

    The MSI is a write in the same ordered stream as the data, so it lands after it; a wired interrupt takes a separate path.

    What drivers do with wired interrupts

    • Read a device register first. In the handler, read a status register from the device before touching the data. The read is non-posted and may not pass the device's earlier posted writes on the same path, so by the time its completion returns, the DMA data has landed (lesson 5.7). It costs a round trip per interrupt.

    • Check a sequence number in the data. The device writes an incrementing number or valid bit as the last part of each completion entry; the driver checks it and retries if it is stale.

    The opening's "disappearing" bug fits exactly: a debug print delayed the handler long enough for the buffered writes to land.

    How real systems chose

    System

    Interrupt ordering

    PCI Express

    An MSI or MSI-X is a posted memory write and may not pass posted writes sent earlier by the same function, so DMA data reaches memory first. Legacy INTx messages carry no such ordering; drivers using them read a device register to flush earlier writes.

    On-chip devices with wired interrupts

    The interrupt wire and the data path are separate; drivers read back a device register, or the interconnect provides a barrier, before using DMA data.

    What breaks

    The opening device (illustrative) used a legacy wired interrupt behind a PCIe switch. Under load, DMA writes queued in the switch while the interrupt went straight through. The fix was to switch the device to MSI-X, which also gave each queue its own vector; on systems that could not use MSI-X, the driver read the device's status register at the start of the handler.

    Why this matters

    Senior lens. Treat every interrupt as the flag of a producer/consumer pair and ask what orders it behind its data. For message-signalled interrupts, check every bridge on the path preserves posted-write order (and does not mark the MSI relaxed). For wired interrupts, insist on a read-back or an equivalent barrier in the handler, and test with heavy traffic between device and memory, the condition that exposes the race.

    Interview

    Asked: "Why are MSIs safer than wired interrupts for DMA completion?"

    Weak answer: MSIs are faster.

    Strong answer: Because an MSI is a posted memory write that travels on the same path as the device's DMA writes, and the ordering rules forbid a posted write from passing earlier posted writes from the same device. So when the MSI lands and the handler runs, the data has already landed. A wired interrupt takes a separate path and can arrive while the DMA writes are still queued in a switch or buffer, so the driver must read a device register first to flush them, which costs a round trip per interrupt.

    Follow-ups: (1) How does a register read flush earlier posted writes? (2) What could break MSI ordering on the way?

    Check yourself Why does reading a device register in the handler make wired interrupts safe?

    The read may not pass the device's earlier posted writes on that path; its completion cannot return until those DMA writes have landed.

    Check yourself A bridge on the path marks MSIs as relaxed-ordering writes. What breaks?

    The MSI may pass the DMA writes before it, so the handler can run before the data has landed.

    Key takeaways

    • DMA data followed by an interrupt is data-then-flag, with the interrupt as the flag.

    • An MSI is a posted write in the same ordered stream, so it lands after the data; a wired interrupt can overtake it.

    • With wired interrupts, read a device register (or check a sequence number) before using the data.

    Keep going

    Next: Lesson 7.10, Memory Consistency Models. Sequential consistency, TSO and weak models on one page, with litmus tests.

    Related topics

    • Part 7 overview: Ordering

    Previous

    112 / 234

    Next: Memory Consistency Models

    Up next

    Up nextMemory Consistency Models

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Why Ordering Matters
    • Ordering Scopes
    • The Point of Serialisation