less_retarded_wiki/watchdog.md
Miloslav Ciz 2f23834d88 Update
2022-08-12 22:38:13 +02:00

1.3 KiB

Watchdog

Watchdog is a special timer that serves as a safety mechanism for detecting malfunction of computer programs at run time by requiring programs to periodically reset the timer.

Basically watchdog keeps counting up and a correctly behaving program is supposed to periodically reset this count ("feed the dog") -- if the reset doesn't happen for a longer period, the watchdog counts up to a high value and alerts that something's wrong ("the dog starts barking"), e.g. with an interrupt or a signal. This can mean for example that the program has become stuck in an infinite loop or that its instructions were corrupted and the program control jumped to some unintended area of RAM and is doing crazy shit. This is usually handled by resetting the system so as to prevent possible damage by the program gone insane, also logs can be made etc. Watchdogs are very often used in embedded systems. Operating systems may also use them to detect nonresponsive processes.

Watchdog is similar to the dead man's switch used e.g. in trains where the operator is required to periodically push a button otherwise the train will automatically activate brakes as the operator is probably sleeping or dead.

See Also