26/10/2023 18:28, Stephen Hemminger:
> 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.

If it has to be more than 1 ms,
we should mention it is a slow call
which may be skipped if the thread is already blocking on something else.



Reply via email to