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
  • Part 8: Sharing and Arbitration12
  • Part 9: Deadlock and Liveness13
    • Deadlock, Livelock and Starvation
    • Deadlock Conditions and Graphs
    • Channel Dependencies
    • Message-Dependent Deadlock
    • The Consumption Assumption
    • Routing Deadlock
    • Pre-allocation or Retry
    • Retry Livelock
    • Timeouts and Watchdogs
    • Hang Debug
    • Proving Deadlock Freedom
    • Protocols Compared: Deadlock and Liveness
    • Drills: Deadlock and Liveness
  • 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 9: Deadlock and Liveness
  1. Topics
  2. First Principles of Hardware Protocols
  3. Part 9: Deadlock and Liveness
  4. Timeouts and Watchdogs

Part 9 · Deadlock and Liveness · Working (W)

Timeouts and Watchdogs

Timeouts detect requests that will never complete; watchdogs detect systems that have stopped. How to choose a timeout value, what a timeout should do when it fires, and why recovering cleanly is harder than detecting.

On this page

    Note

    Level: Working (W) · Answers: Why can it hang?

    Before this: Deadlock, Livelock and Starvation, The Request/Response Model

    A processor reads a register in a device that has crashed. With no timeout, the read waits for ever, the core waits behind it, and the operating system freezes with nothing in its logs. With a timeout, the read completes with an error after a few milliseconds, the driver logs "device not responding", resets the device, and the system carries on. The device failed the same way in both cases; only one system survived it.

    How do you detect a request or a system that will never make progress, and what should happen next?

    The obvious answer, and why it breaks

    The obvious answer is to design so that hangs cannot happen: deadlock-free fabrics, compliant endpoints, every request answered. That is necessary, but devices crash, links fail, power domains switch off, and bugs escape verification. Something must turn "waiting for ever" into an error that software can handle. And the tool for that, a timeout, has two hard parts: choosing the value, and leaving the system in a clean state afterwards.

    The idea: timeouts and watchdogs

    Mechanism

    Watches

    Fires when

    Typical action

    Request (completion) timeout

    One outstanding request

    Its response has not arrived within a limit

    Complete the request with an error; free its tag and buffers; log it

    Watchdog

    A whole agent or system

    It has not shown progress (a "kick") within a limit

    Interrupt, then reset the agent or the system

    Progress monitor

    A channel or queue

    No handshake for N cycles while something is waiting

    Raise an error with a snapshot of state for debug (lesson 9.10)

    Choosing the value

    • Longer than the slowest legitimate response, including the worst case: power-state wake-ups, retries, congestion, device firmware that is slow on purpose. A timeout that fires on a healthy but slow device causes the failure it was meant to catch.

    • Shorter than what the system can tolerate: the requester and everything waiting behind it are stuck until it fires.

    • Different per class of target: on-chip registers answer in nanoseconds; a device behind a link that may retrain or wake from a low-power state may legitimately take milliseconds.

    Diagram
    Illustrative device behind a link:
      normal read latency                           ~1 us
      link retraining after an error (worst case)   ~10 ms
      device wake from a deep power state            ~20 ms
    Timeout must exceed the worst legitimate case:  > 30 ms; choose ~50 ms
    An on-chip peripheral answering in < 1 us could use ~1 ms

    When it fires

    Flowchart. If a response is overdue: complete the request with an error, free its tag, buffers and credits, and log which request and target and how long. If a late response then arrives, drop it because its tag is no longer valid. Software then decides whether to retry, reset the target, or report.
    A timeout must turn the hang into an error, release everything the request held, record enough to debug, and safely discard a response that arrives too late.

    The late-response step is where recovery usually breaks: if the tag was freed and reused, a stale response can be matched to a new request and deliver wrong data silently (lesson 6.4). Designs mark timed-out tags as quarantined until the target is reset, or include a sequence number that late responses fail to match.

    How real protocols chose

    Protocol

    Timeouts

    PCI Express

    Completion timeouts are programmable in ranges from 50 µs to 64 s (the Device Control 2 register); functions must support 50 µs to 50 ms, and a timeout can be disabled. A timed-out request completes with an error and is reported through error logging.

    Interconnects and SoCs

    Many provide per-target timeout monitors that answer a stuck request with an error response, so one dead peripheral cannot hang a core.

    Processors and systems

    Hardware watchdog timers that reset the system if software stops kicking them.

    What breaks

    A design (illustrative) set a 1 ms completion timeout for a device that, in a deep power state, took 5 ms to wake. Every first access after idle timed out, the driver reset the device, and the device went back to sleep: a loop that looked like a hardware failure. The timeout was below the slowest legitimate response. Raising it to 50 ms, and keeping a shorter one for other targets, fixed it.

    Why this matters

    Senior lens. Every requester that can wait on something outside its control needs a timeout, chosen from the target's worst legitimate latency, and a recovery path that frees everything the request held and safely discards late responses. Test the recovery path deliberately, with a target that never answers and one that answers just after the timeout; those are the paths that have never run when the field failure happens.

    Interview

    Asked: "How long should a completion timeout be?"

    Weak answer: As short as possible.

    Strong answer: Longer than the slowest legitimate response from that target, including worst cases like link retraining or waking from a low-power state, and short enough that the requester and everything behind it aren't stuck longer than the system tolerates. That usually means different values per target class: microseconds to a millisecond on chip, tens of milliseconds for a device behind a link. Then the recovery matters as much as the value: complete with an error, free the tag and buffers, log it, and make sure a late response is discarded, not matched to a reused tag.

    Follow-ups: (1) What goes wrong if the timeout is too short? (2) How do you handle a response that arrives after the timeout?

    Check yourself A target normally answers in 2 µs but may take 15 ms after a link error. A 5 ms timeout: what happens?

    After every link error, requests time out even though the target is healthy; the system treats a slow recovery as a failure. The timeout should exceed 15 ms.

    Check yourself Why must a timed-out request's tag not be reused immediately?

    A late response for the old request could arrive and be matched to the new one, delivering wrong data with no error.

    Key takeaways

    • Timeouts turn requests that will never complete into errors; watchdogs reset systems that have stopped.

    • Choose a timeout above the target's worst legitimate latency and below what the system can tolerate.

    • On firing: error status, free everything, log, and discard late responses safely.

    Keep going

    Next: Lesson 9.10, Hang Debug. Building the wait-for graph from a waveform, with a design that hangs.

    Related topics

    • Part 9 overview: Deadlock and Liveness

    Previous

    137 / 234

    Next: Hang Debug

    Up next

    Up nextHang Debug

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Deadlock, Livelock and Starvation
    • Deadlock Conditions and Graphs
    • Channel Dependencies