inaccuracy issue of clock_nanosleep() with Debian

I use BeagleboneBlack with Debian, kernel v3.15, and I want to implement an accurate timer on my BBB.
I use clock_nanosleep() to wait for 1 second. However, it always turns to be 1 second and 100~120 microsecond delay. (I measured clock_nanosleep() between clock_gettime() and with oscilloscope.)

I also run linuxPTP (a software that adjusts system clock, CLOCK_REALTIME, to synchronize linux system with PTP.) to synchronize my BBB.

I have no idea how to improve it, should I change linux to real-time linux? (Xenomai or RobertCNelson’s patch for linux)
or is there another way (such as software, codes, etc) to get more accuracy timer? (under 1us delay.)

Thanks!

Try the “cycle counter” in the pru.

look in the pru section of the forum

Hello, John,
Excuse me, may I ask that PRU can be used beyond linux system clock?
Because I need to synchronize my BBB with ourter PTP(precision time protocol) message , if PRU using its clock, then the BBB will become asynchronized device…

Thanks.

John Stampfl於 2014年7月17日星期四UTC+8下午11時02分32秒寫道:

You also might find accessing the timers from PRU is more accurate

Hello, John,
Excuse me, may I ask that PRU can be used beyond linux system clock?
Because I need to synchronize my BBB with ourter PTP(precision time protocol) message , if PRU using its clock, then the BBB will become asynchronized device…

You might find this helpful:

http://processors.wiki.ti.com/index.php/TI81XX_PSP_Ethernet_Switch_User_Guide#IEEE_1588.2F802.1AS_PTP_Support

Regards,
John