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,

The signal will be delivered to some thread in the task group, so in that sense it will "fire".  However, it may be the case that the the dead locked thread cannot respond to the signal.  There are many possible scenarios.

If you setup a signal handler to run and the task is deadlocked waiting on a semaphore that receives the signal, the semaphore wait will return EINTR and the signal handler will run.  But, I can imagine other cases where the task might not respond to the signal.

In a multi-threaded task group, it may may not be the waiting thread that receives the signal, however.  Multi-threaded signal delivery is complex and non-obvious.

or if a higher priority thread has caused CPU starvation, or similar cases?

Certainly the signal handling will typically pend and be delayed.  POSIX requires that signal events be queued only at least one deep; NuttX queues signal action events but not other signal events (as I recall).  The behavior will depend on the sigprocmask and might not pend at all!

Signal handling is complex and this was written from my recollection which may be flawed.

Reply via email to