Timer Question

I have a routine that wants to “wake up” on an aperiodic basis and do some work (in the “main” thread). The periodicity will change depending upon where we are in the flight plan. Pouring over the docs, it seems as if the anwser is a one-shot, relative timer adjusted at each invocation using a signal as the notification event (?). Can I create and start the timer within the routine itself or must this be done in “main”?

No it can be done in the routine itself. you can confirm yourself by using checking in the documentation if the function you want to use is signal safe, there is a table on the bottom of the page.

You also might want to consider using a pulse instead of signal, which can be nasty to deal with or perhaps a thread.

If the period doesn’t change every time I would keep it a periodic timer and then change the the period when you need to. Periodic timer are more stable, because there is a side effect to change the period. If you create a one-time timer of say 2ms, you may get the notification 3-4 ms latter instead of 2.

Great. I’ll go with the periodic as the timing will not change every time and poke into using a pulse. Thanks for the advice!