View topic - Timer accuracy in task scheduling

Timer accuracy in task scheduling

For discussion of realtime and/or embedded programming.

Timer accuracy in task scheduling

Postby Ericxx » Thu Oct 18, 2012 4:45 pm


I am now currently using QNX 6.5.0 on omap3530 for robotics applications. I created a timer with an interval of 20ms to activate the main() program in a continuous method. The main() program will further creates other thread performing various tasks such as sensor data reading, control algorithms and servo driving, all in a 20ms interval fashion. A snippet of the main() is listed below.
Code: Select all
    m_chMain = ChannelCreate(0);

    sigevent event;
    event.sigev_notify = SIGEV_PULSE;
    event.sigev_coid = ConnectAttach(ND_LOCAL_NODE, 0, m_chMain, _NTO_SIDE_CHANNEL, 0);
    event.sigev_priority = getprio(0);
    event.sigev_code = PULSECODE_MAIN;

    itimerspec timer; timer_t idTimer;
    timer_create(CLOCK_REALTIME, &event, &idTimer);

    ...start other threads

The current problem is that in most of the time, the timer intervals between each activation of the main() program can be strictly close to 20ms, while there are still quite a lot of times that the intervals became like up to 26ms... For other threads created within the main(), the sum of each execution time is less than 20ms. So i am quite confused how the timer will notify the main() with such an incorrect time interval. Please kindly suggest. Thank you.

Senior Member
Posts: 158
Joined: Mon Jun 09, 2008 1:38 pm

Re: Timer accuracy in task scheduling

Postby mario » Thu Oct 18, 2012 7:29 pm

Read the section in the manual titled Tick Tock.
QNX Master
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Re: Timer accuracy in task scheduling

Postby denkelly » Thu Oct 18, 2012 11:51 pm

6 ms is too much latency. Have you raised the priority of these threads you expect to run regularly? What else is going on in the system?
Senior Member
Posts: 163
Joined: Sat Aug 02, 2008 3:27 pm

Return to Realtime and Embedded

Who is online

Users browsing this forum: No registered users and 3 guests