public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: George Anzinger <george@mvista.com>
To: john stultz <johnstul@us.ibm.com>
Cc: markh@compro.net, linux-kernel@vger.kernel.org
Subject: Re: HZ question
Date: Tue, 13 Sep 2005 21:15:06 -0700	[thread overview]
Message-ID: <4327A3CA.5000700@mvista.com> (raw)
In-Reply-To: <1126632856.3455.45.camel@cog.beaverton.ibm.com>

john stultz wrote:
> On Tue, 2005-09-13 at 11:05 -0400, Mark Hounschell wrote:
> 
>>Tim Schmielau wrote:
>>
>>>On Tue, 13 Sep 2005, Mark Hounschell wrote:
>>>
>>>
>>>>Most if not all userland delay calls rely on HZ value in some way or
>>>>another. The minimum reliable delay you can get is one (kernel)HZ. A
>>>>program that needs an acurrate delay for a time shorter that one
>>>>(kernel)HZ may have an alternative if it knows that HZ is greater the
>>>>the requested delay.
>>>
>>>Just assume that kernel HZ are USER_HZ and see anything else as an
>>>additional bonus that you cannot rely on.
>>>
>>>What does 'acurrate delay' mean, anyways?
>>>
>>>Tim
>>>
>>
>>But they are not the same. Why can I get USER_HZ but not HZ?
> 
> 
> Because USER_HZ is there only because HZ changes on various systems and
> we don't want to break userland apps that assume its value.
> 
> 
> 
>>On a 100HZ kernel ANY requested delay via udelay or 
>>pthread_cond_timedwait of less than 10000usecs is unreliable and the the 
>>actual results are totally unacceptable.
>>
>>On a 1000HZ kernel the number is 1000 usecs.
>>
>>I'm not asking the kernel running at 1000hz to actually give me 500 usec 
>>delay if I ask. I do expect it to be at least 500 usec and within +- a 
>>single HZ however. Oviously a 1000HZ machine is going to give me better 
>>resulution in any requested delay. Why is it unreasonable for userland 
>>to know the probable resolution of userland delay requests.
> 
> 
> But you don't really want to know HZ, you want to know timer resolution.
> That's a reasonable request and I believe the posix-timers
> clock_getres() interface might provide what you need. Although I'd defer
> to George (CC'ed) since he's more of an expert on those interfaces.

Exactly.  clock_getres() on CLOCK_REALTIME will get the resolution of 
timers (itimers or posix timers on CLOCK_REALTIME.  You can also get the 
res using the old itimer interface by programing a repeating time of 1 
usec and then reading back the timer (get_timer ?).  Set a longish 
initial time so you can delete the timer prior to its expiring and look 
at the repeat time returned.  Do be aware that this will be rounded up, 
however, and will likely show, e.g. 1000 usec for 999849 ns (as returned 
by clock_getres()).  Either of these interfaces is in the 2.6 kernel 
these days.
> 
> You might also want to check out his HRT patches.

Thanks for the plug :)
-- 
George Anzinger   george@mvista.com
HRT (High-res-timers):  http://sourceforge.net/projects/high-res-timers/

  parent reply	other threads:[~2005-09-14  4:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-13 12:48 HZ question Mark Hounschell
2005-09-13 13:46 ` linux-os (Dick Johnson)
2005-09-13 14:00   ` Mark Hounschell
2005-09-13 14:20     ` Tim Schmielau
2005-09-13 15:05       ` Mark Hounschell
2005-09-13 16:01         ` Tim Schmielau
2005-09-13 16:41           ` Mark Hounschell
2005-09-13 16:47           ` Mark Hounschell
2005-09-13 18:38             ` Stefan Smietanowski
2005-09-13 19:17               ` Mark Hounschell
2005-09-13 23:19                 ` Daniel Barkalow
2005-09-13 17:34         ` john stultz
2005-09-13 19:15           ` Mark Hounschell
2005-09-14  4:15           ` George Anzinger [this message]
2005-09-13 20:13   ` jdow
2005-09-13 20:38     ` linux-os (Dick Johnson)
2005-09-15  1:29       ` Lee Revell
2005-09-13 14:07 ` Tim Schmielau
2005-09-14  4:00 ` Coywolf Qi Hunt
2005-09-15  1:20   ` Lee Revell
2005-09-15 16:16     ` Joe Bob Spamtest
2005-09-15 20:19       ` Valdis.Kletnieks
2005-09-15 20:34         ` Jesper Juhl

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=4327A3CA.5000700@mvista.com \
    --to=george@mvista.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markh@compro.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox