These are all good ideas, thank you! I am considering the posix timer approach.
I would like to ask, are there cases where the timer may not fire? Is it guaranteed to fire, for example, if the thread is in a dead lock, or if a higher priority thread has caused CPU starvation, or similar cases? Στις Δευ, 15 Μαρ 2021 στις 10:24 μ.μ., ο/η Sara da Cunha Monteiro de Souza < saramonteirosouz...@gmail.com> έγραψε: > Please, > take a look at the watcher/watched examples: > > https://github.com/apache/incubator-nuttx-apps/tree/master/examples#watcher-watcher--watched > . > The watcher uses a Hardware WDT to monitor the subscribed watched tasks. > In this case, the "watched" example have 4 subscribed tasks. > Note: these examples are going to be changed these days. I'll submit a PR > to fix a issue in the print task. > > Em seg., 15 de mar. de 2021 às 06:36, Pelle Windestam < > pelle.windes...@tagmaster.com> escreveu: > > > > > If you want to catch some task/thread in an infinite loop, the > hardware > > > > watchdog monitor in nuttx can do it for you. > > > > > > If the hardware watchdog is fed from multiple sources, all of them need > > to > > > fail. Not just one of them. > > > Do you have anything else in mind? > > > > > > > You don't need a special timer here, the posix timer can work very > > well: > > > > > > > > 1. Create a watchdog timer by timer_create > > > > 2. Feed the timer periodically through timer_settime > > > > 3. Register a timeout signal handler > > > > 4. Call exit/abort in signal handler > > > > > > This is a nice idea, thank you. > > > I didn't think of it before. > > > > We have a similar watchdog functionality built into a driver. Via an > > ioctl()-call it is possible to register new individual "watchdogs" that > are > > fed via another ioctl()-call. This way each thread that we want to > monitor > > will register its own watchdog via the ioctl() interface, and the driver > > will keep track of which thread failed to feed feed it. > > > > //Pelle > > >