Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Periodic thread with clock_nanosleep

$
0
0
Hi
I have a periodic task (with the highest priority) which I away every X nano-second.
I am using the function clock_nanosleep with REAL_TIME timer.
when I wake up, I versify that I was awake on time,
and check if the delta between the last time I get to sleep and the current time is X nano-second.
(I verify this with the function clock_gettime, and again with REAL_TIME timer).
sometimes when the thread wake up, the delta is not X nano second (it can be sometimes less or high above
X nanosecond)
I am connected to NTP.

1. why sometimes the thread wake up before or after X nano second (I see this through the delta)
2. if the reason is the NTP and REAL_TIME timer, why the thread wake up after it finish to sleep
and the delta is less than X nano second ?

Thanks

Viewing all articles
Browse latest Browse all 16232