On Thu, 26 Oct 2023 16:08:02 +0200
Morten Brørup <m...@smartsharesystems.com> wrote:

> > > In our recent tests, nanosleep() itself took around 50 us. So you need to 
> > >  
> > sleep longer than that for your thread not to be runnable when the 
> > nanosleep()
> > wakes up again, because 50 us has already passed in "nanosleep overhead".  
> > > 10 milliseconds provides plenty of margin, and corresponds to 10 jiffies 
> > > on  
> > a 1000 Hz kernel. (I don't know if it makes any difference for the kernel
> > scheduler if the timer crosses a jiffy border or not.)
> > 
> > 10 ms looks like an eternity.  
> 
> Agree. It is only for functional testing, not for production!

To be safe the sleep has to be longer than the system clock tick.
Most systems are built today with HZ=250 but really should be using HZ=1000
on modern CPU's.

Reply via email to