Re: Short sleep precision

From: Jan Engelhardt
Date: Sun Mar 20 2005 - 08:36:59 EST


>Running your program here I see even worse values than that on 2.6.11-mm4
>and it's also interresting to see that for a lot of continuous runs the
>values reported drop steadily and eventually settle around ~1100, but if I
>insert a sleep 1 between runs, then I see a steady ~1000 reported.
>This is all with HZ = 1000

That may be related to the new mix of USER_HZ. I can't really tell,
just observed that there is such.

>Linux nanosleep() used to have a busywait loop for sleeps less than two
>milliseconds. 2.4.x still does.

Yes, I know. Linus threw it out during 2.5 because it was deemed to buggy.
That did not affect me, because that busywaiting is only possible in
!SCHED_OTHER, which I cannot use, because tiny delays are needed in a
user-runnable userspace app, and I don't want it suid and stuff.

(I've developed an "overhead correction" for accurate(*) realtime replay of
logfiles. (*) with respect to the total runtime. Works well.)

>You can spin on the gettimeofday() result in userspace.

How can I use it? / What does it help me? I just have the gettimeofday() in
the example script to measure the total time of nanosleep(). Sometimes,
nanosleep completes in the same tick, sometimes (95%), another task is
scheduled before returning. I am calling nanosleep repetedly to find out the
_average_ time for a 0us-nanosleep(), usually 100/1000 us.



Jan Engelhardt
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/