All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dag Nygren <dag@newtech.fi>
To: Nish Aravamudan <nish.aravamudan@gmail.com>
Cc: Dag Nygren <dag@newtech.fi>,
	linux-kernel@vger.kernel.org, dag@newtech.fi
Subject: Re: nanosleep with small value
Date: Thu, 17 Nov 2005 20:47:28 +0200	[thread overview]
Message-ID: <20051117184728.2863.qmail@dag.newtech.fi> (raw)
In-Reply-To: Message from Nish Aravamudan <nish.aravamudan@gmail.com>  of "Thu, 17 Nov 2005 09:12:58 PST." <29495f1d0511170912x2cceac78w766f0c800ee3f718@mail.gmail.com>

> On 11/17/05, Dag Nygren <dag@newtech.fi> wrote:

> 
> Which kernel, what value of HZ?

Sorry, the kernel is 2.6.13 and HZ is 250.

> In either case, it's absurd to assume
> that the kernel is going to provide you 1 microsecond resolution in
> 2.6 mainline, as the best HZ value is 1000 (1 millisecond). And we
> don't busy-wait ever in nanosleep().

Not?
The man page for nanosleep saya that times under 2 us are implemented
by a busywait and  this is why I expected it to work.

> So the fastest your loop can run
> is 1000 * 1 ms = 1 second. That's assuming the only time-consuming
> thing is sleeping (minimal overhead). But, in sys_nanosleep(), we
> convert nanoseconds to jiffies and add 1 if you requested any sleep
> time. So,
> 
> HZ = 100
>      1000 * (10 + 1 ms) = 11 s
> HZ = 250
>      1000 * (4 + 1 ms) = 5 s
> HZ = 1000
>      1000 * (1 + 1 ms) = 2 s (which is what Dick Johnson reported).
> 
> Note, that with HZ=250, there might be some extra rounding occurring
> timespec_to_jiffies() that I've forgotten.
> 
> So 8 s may not be terribly unreasonable. I don't know, though, what's
> add the 3 seconds if you're using 250.

OK, in that case the manpage should be changed. And an alternative
has to be worked out by me ;-).

Thankyou
Dag


  reply	other threads:[~2005-11-17 18:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-17 16:30 nanosleep with small value Dag Nygren
2005-11-17 16:55 ` linux-os (Dick Johnson)
2005-11-17 17:32   ` Eric Piel
2005-11-17 17:12 ` Nish Aravamudan
2005-11-17 18:47   ` Dag Nygren [this message]
     [not found] <29495f1d0511171051q6088099drfe094817a01668e4@mail.gmail.com>
2005-11-17 19:11 ` Dag Nygren
2005-11-17 19:15   ` Randy.Dunlap
2005-11-17 19:17   ` Nish Aravamudan
2005-11-17 19:47   ` Frank Sorenson
2005-11-21  7:12     ` Dag Nygren
  -- strict thread matches above, loose matches on Subject: below --
2005-11-17 20:25 Dag Nygren

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=20051117184728.2863.qmail@dag.newtech.fi \
    --to=dag@newtech.fi \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nish.aravamudan@gmail.com \
    /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.