Skip navigation.
Home
The QNX Community Portal

View topic - Timer Question

Timer Question

For discussion of realtime and/or embedded programming.

Timer Question

Postby darnandy » Wed Jul 29, 2009 2:50 pm

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"?
darnandy
New Member
 
Posts: 6
Joined: Tue May 12, 2009 2:06 pm

RE: Timer Question

Postby mario » Wed Jul 29, 2009 4:21 pm

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.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

RE: Timer Question

Postby darnandy » Wed Jul 29, 2009 4:34 pm

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!
darnandy
New Member
 
Posts: 6
Joined: Tue May 12, 2009 2:06 pm


Return to Realtime and Embedded

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron