sama5d3_xplained, usleep(), timers...

Moderator: nferre

Posts: 11
Joined: Sat May 24, 2014 5:33 am

sama5d3_xplained, usleep(), timers...

Sat Jun 28, 2014 9:43 pm

I was attempting to use the usleep() function recently on my sama5d3_xplained board, and noticed that the time interval is really off. ( Looks like it is 1sec instead of 1usec).

Then I tried to use the ITIMER_REAL ( with SIGALARM handler...).
And again, the time internals were really off. 

I wonder if somebody experienced the similar behaviour... ( may be some settings are wrong...).
Also, can somebody navigate to the code where the linux kernel timer is set, and which physical timer is used ? 

Location: India
Posts: 3
Joined: Tue Jun 10, 2014 3:27 pm

Re: sama5d3_xplained, usleep(), timers...

Wed Jul 02, 2014 8:14 am


Quoting usleep man page
The usleep() function suspends execution of the calling thread for (at least) usec microseconds. The sleep may be lengthened slightly by any system activity or by the time spent processing the call or by the granularity of system timers.
so may be your kernel timer resolution is very low, because of the tick rate definition. The Tick rate and associated concepts are well explained in the book Linux Kernel Development by Robert Love. You can read the associated section here

If the problem is Tick rate you can try high resolution timer facility in linux kernel, try recompiling with high resolution timer support. Details here

I got the same issue in another platform some time back [ep9302a, arm9], which doesnt have proper high resolution timer support, anyway SamA5D3x has got high resolution timer support.
Posts: 11
Joined: Sat May 24, 2014 5:33 am

Re: sama5d3_xplained, usleep(), timers...

Fri Jul 04, 2014 7:03 am

Thanks a lot! 
Re-building the kernel with HIGH resolution timers enabled helped. 

I wonder what 'side effects' enabling High Resolution Timers may have, and why they were not enabled by default... But it is next step to look at... 

Thanks once again, 


Return to “SAMA5-based”

Who is online

Users browsing this forum: No registered users and 3 guests