A watchdog timer is really a hardware-assisted, time-based assertion in the code. As such, it is just a part of the larger software development strate gy known as Design by Contract (DbC).
The value of identifying the watchdog timer as an *assertion* is that it in forms you what to expect from it. For example, you can't expect an assertio n to "avoid" or "fix" a problem (like in the OP "avoid a task not executed" ). This is because assertions neither handle nor prevent errors, in the sam e way as fuses in electrical circuits don't prevent accidents or abuse. In fact, a fuse is an intentionally introduced weak spot in the circuit that i s designed to fail sooner than anything else, so actually the whole circuit with a fuse is less robust than without it.
Now, regarding using watchdog timers in the context of an RTOS: you should service the watchdog from the context of the task. A common mistake is to s ervice a watchdog from a periodic timer service. RTOS timers typically run in the ISR context, so they might be running and being serviced, while the task is starving. Another mistake along these lines is to service a watchdo g from various RTOS callbacks, also known as "hooks", which might also run in a different context than your task.
Once you use a watchdog timer, you need to carefully design (and test!) the behavior of the system when the watchdog expires. Here again, identifying the watchdog as an assertion helps, because you can use your general strate gy of handling failed assertions. I've written more about this in the blog: ["A nail for a fuse"]
formatting link
-for-a-fuse/).
I am always amazed by embedded designs, where developers go to great length s to apply memory protection (MPU or MMU) or watchdogs, while at the same t ime they don't sprinkle their code with basic code assertions that perform rudimentary sanity checks.
Even more bizarre to me is when developers use assertions, but *disable* th em in the production release (while keeping the MPU and the watchdogs.) I'm sure the readers of this forum never do such an illogical thing, and alway s ship the products with carefully designed assertions, right?