From: Koen Martens <Koen.Martens@tomtom.com>
To: linux-kernel@vger.kernel.org
Subject: sys_nanosleep round-off error
Date: Fri, 21 Oct 2005 11:30:47 +0200 [thread overview]
Message-ID: <4358B547.7070900@tomtom.com> (raw)
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 | koen.martens@tomtom.com | +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.
reply other threads:[~2005-10-21 9:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4358B547.7070900@tomtom.com \
--to=koen.martens@tomtom.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.