Hi All,
We just had some weird stuff going on with nanosleep. When interrupted
by a signal, it should return the amount of sleeptime remaining.
However, when (for example) setting the time to sleep to 10
milliseconds, it would sometimes return a remaining sleep time of 15ms.
Now, we can see why this is happening, we suspect this line:
expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
Expire is the number of jiffies that is passed to schedule_timeout(),
and we see that if we do indeed have some time to sleep, 1 is added to
this number.
On the system where we saw this, a jiffie is 5 msec.
So when we enter nanosleep with 10msec to sleep, it converts that to 2
jiffies, and expire is 3. Then when the timeout is interrupted by a
signal before any timeout is actually done, we return with 3 and this is
converted back to 15msec...
So, the big question: why is the + (t.tv_sec || t.tv_nsec) there?? I
assume it has to do with round-off, eg. when you put 9msec in, you get 1
jiffie, but want to round-of upwards to 10msec=2jiffies.
Best,
Koen
--
Koen Martens | Developer | TomTom | [email protected] | +31 (0) 20 850 09 81
This e-mail message contains information which is confidential and may be privileged. It is intended for use by the addressee only. If you are not the intended addressee, we request that you notify the sender immediately and delete or destroy this e-mail message and any attachment(s), without copying, saving, forwarding, disclosing or using its contents in any other way. TomTom N.V., TomTom International BV or any other company belonging to the TomTom group of companies will not be liable for damage relating to the communication by e-mail of data, documents or any other information.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]