In embedded processors (like microcontrollers, DPSs, etc...) we usually have a hardware watchdog timer. Think of this as a countdown timer which triggers something (usually reset) upon reaching zero and you always need to avoid it reaching zero by writing a register from the main program. If we set this to say 10 seconds, it will cunt like 9, 8, 7 .....3, 2, 1, 0. Upon reaching zero usually we reset the chip.
I'll give you an example for the usual case.
- We setup the Watchdog timer to be say 10 seconds.
- From our main routine, we write a defined value to a special register or memory location related to the watchdog timer repeatedly (say in 5 seconds intervals). This value and the register is defined in the datasheet of the chip. As soon as we write to this register, the Watchdog timer will get refreshed and start counting from beginning.
- Say our program got stuck somewhere due to an error and we were unable to write to this register within 10 seconds. Then the Watchdog timer will reach 0 (timeout situation) and then the chip will get reset. (That means everything will start from the beginning).
This is just an example. Watchdog is an important unit which will give you lots of benefits if used carefully.