Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - QNX timer query: Page 1 of 5 (5 Items)
   
QNX timer query  
Hello,

I want to use QNX timer to get clock resolution in terms of millisecond.  I am successful in getting resolution in terms
 of integer values such as 32ms, 16ms, and even 1ms.

But when I set the timer interval to 5.3ms, the timer times out in non-uniform intervals (5ms, 5ms, 6ms, 5ms....).  What
 might be the cause for this behavior?
 
I set the timer parameters as shown below:

struct itimerspec       itime;
struct _pulse   		pl;
int                     rcvid;
float                 ms_interval = 5.3;

itime.it_value.tv_sec = 0;
itime.it_value.tv_nsec = ms_interval * 1000000;
itime.it_interval.tv_sec = 0;
itime.it_interval.tv_nsec = ms_interval * 1000000;
timer_settime(timer_id, 0, &itime, NULL);

while(1)
{
	rcvid = MsgReceive(chid, &pl, sizeof(pl), NULL);
	if (rcvid == 0)
	{ /* we got a pulse */
		if (pl.code == TIMER_START_PULSE)
		{
			printf("we got a pulse from our timer\n");
		}
	}
}

I measure the timer interval uses kernel traces captured using tracelogger.

Thank you in advance.

Best Regards,
Divya