All of lore.kernel.org
 help / color / mirror / Atom feed
From: george anzinger <george@mvista.com>
To: Marcus Ramos <marcus@ansp.br>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: What is the precision of usleep ?
Date: Sun, 22 Apr 2001 03:47:40 -0700	[thread overview]
Message-ID: <3AE2B6CC.1D1F8A10@mvista.com> (raw)
In-Reply-To: <3AE07A5A.C5BBE59C@ansp.br>

Marcus Ramos wrote:
> 
> Hello,
> 
> I am using usleep in an application under RH7 kernel 2.4.2. However,
> when I bring its argument down to 20 miliseconds (20.000 microseconds)
> or less, this seems to be ignored by the function (or the machine's hw
> timer), which behaves as if 20 ms where its lowest acceptable value. How
> can I measure the precision of usleep in my box ? I am currently using
> an Dell GX110 PIII 866 MHz.
> 
> Thanks in advance.
> Marcus.

Well, first, your issue is resolution, not precision.  Current
resolution on most all timers is 1/HZ.  So this should get a min.
nanosleep of 10 ms.

So, could someone explain this line from sys_nanosleep() (
kernel/timer.c):

	expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);

It seems to me this should just be:

	expire = timespec_to_jiffies(&t)

timespec_to_jiffies(&t) seems to do all the needed resolution round up
and such.  Since || is logical, this seems to always add 1, except if
the requested value is 0.  The net result is you always get 1 extra
jiffie (unless you ask for zero, in which case you get a timer that will
expire next tick (thru the wonders of add_timer).

George

  reply	other threads:[~2001-04-22 10:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-20 18:05 What is the precision of usleep ? Marcus Ramos
2001-04-22 10:47 ` george anzinger [this message]
2001-04-23 16:20   ` george anzinger

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=3AE2B6CC.1D1F8A10@mvista.com \
    --to=george@mvista.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcus@ansp.br \
    /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.