Section 19.4.8

Watchdog coverage and diagnostic independence

Definition

Watchdog §6.16 coverage is the set of failures that a watchdog timer detects. A watchdog timer, a hardware timer that resets the device unless software restarts the timer (feeds it) within a fixed timeout §9.34, therefore detects exactly the failures that stop every feed. Diagnostic independence is the property that no single fault can both make the supervised work fail and keep the watchdog from detecting that failure. Coverage depends on what the feeding code checks; independence depends on what the watchdog shares with the supervised work.

Where it fits

Main entry: Watchdog timer (§6.16).

The Watchdog timer entry explains the mechanism. A feed proves only that the feeding code ran, so coverage follows from the condition under which that code feeds.

Independence is the opposite requirement: the feed must depend on the work, but the watchdog’s counting and its reset must not. A watchdog clocked by the processor’s clock stops counting when that clock stops and then never resets the device, so many watchdogs run from a separate oscillator. Software that can disable the watchdog or lengthen its timeout can switch off the check with one stray write, so many microcontroller §6.1 watchdogs cannot be stopped or reconfigured once started, except by a reset.

Pacing, delaying work on purpose to hold a rate, makes the timeout hard to size. Let GG be the longest gap between feeds in correct operation and TT the timeout. A correct device escapes reset only if T>GT > G, with margin for clock tolerance, and a hang that starts just after a feed is detected only TT later. A monitor escapes this trade-off by counting a declared, bounded wait as progress until its stated end time and as a failure after it; TT then needs to cover only the monitor’s own loop.

Limits and common mistakes

A reset discards the contents of RAM and recurs if the fault survives the restart. A thread that checks in while computing wrong results is not detected. An attacker who can lengthen a wait that the watchdog counts as a hang can reset the device at will, a denial of service §1.28.

Questions answered

Why can timeout sizing conflict with pacing?

Timeout sizing conflicts with pacing because pacing makes correct work pause for long stretches, and a watchdog cannot tell a long correct pause from a hang. A watchdog timer resets the device unless software restarts it, called feeding it, before its timeout runs out. Pacing delays work on purpose to hold a rate, for example by making a worker wait for permission from a rate limiter §9.38, so each wait lengthens the gap between the worker’s feeds.

Suppose a worker may wait 100 ms for permission and then works for 10 ms, so correct gaps between feeds reach 100+10=110100 + 10 = 110 ms. A timeout of 80 ms resets a correct worker, because 110>80110 > 80. A timeout of 150 ms never does, but it detects a hang that starts just after a feed only 150 ms later instead of 80 ms. Feeding from an unrelated timer avoids false resets only by detecting nothing about the worker. The repair is a monitor thread that alone feeds the watchdog and counts each declared, bounded wait as progress until its end time, so the timeout has to cover only the monitor’s loop.

Related entries: Deadline versus timeout (§9.34), Duty-cycle bound versus per-request response-time bound (§19.4.6).