On Thu, 17 Nov 2005, Dag Nygren wrote::
No, it means he is at 250 HZ.
real 0m8.000s
user 0m0.000s
sys 0m0.000s
On an unprivilged account, I get this with
version 2.6.13.4
Script started on Thu 17 Nov 2005 11:44:47 AM EST
LINUX> time ./xxx
sched_setscheduler returned: -1
Operation not permitted
real 0m2.000s
user 0m0.000s
sys 0m0.001s
LINUX> uname -r
2.6.13.4
LINUX> exit
Script done on Thu 17 Nov 2005 11:45:07 AM EST
From the root account where the scheduler could be set:
Script started on Thu 17 Nov 2005 11:45:29 AM EST
[root@chaos root]# time /tmp/xxx
real 0m2.001s
user 0m0.000s
sys 0m0.001s
[root@chaos root]# exit
Script done on Thu 17 Nov 2005 11:45:53 AM EST
... essentially the same thing. And 2 seconds, not 8.
The HZ value for my kernel is 1000. It you are at 100 HZ,
that might explain it.
In general small nanosleep() returns between 1/HZ and 2/HZ. In this code, the sleep is (indirectly) synchronised on a tick so it's always 2/HZ, the worse!
Note that nanosleep() doesn't claim to be able to sleep
less than the resolution of some kernel timer. It just takes
parameters in seconds and nanoseconds.