From: "Alexandre P. Nunes" <alex@PolesApart.wox.org>
To: linux-kernel@vger.kernel.org
Subject: Re: some questions using rdtsc in user space
Date: Fri, 02 Aug 2002 16:05:59 -0300 [thread overview]
Message-ID: <3D4AD817.3080200@PolesApart.wox.org> (raw)
In-Reply-To: 3D4ACF11.FD7BB5B5@nortelnetworks.com
Chris Friesen wrote:
>[snip]
>
>>If using rdtsc is a good way, someone knows how do I do some sort of
>>loop, converting the rdtsc difference (is it in cpu clocks, right?) to
>>nano/microseconds, and if there could be bad behaviour from this (I
>>believe there could be some SMP issues, but for now this is irrelavant
>>for us).
>>
>>
>
>You'd be more portable looping on gettimeofday(), which returns back seconds and
>microseconds. The disadvantage is that if you change the system time while your
>program is running you can get screwed.
>
I guess ntpd would be the evil on this issue, because at least in some
machines I have here, it makes minor (sometimes not "that" minor)
corrections every half hour or so...
>
>If you want to loop on rdtsc (which as you say is often clockspeed, but that is
>not necessarily exactly what is advertised), then the first thing you need to do
>is to figure out how fast you're going. What I usually do is grab a timestamp,
>sleep for 10 seconds using select(), and grab another timestamp. Figure out the
>difference in timestamps, divide by 10, and you get ticks/sec. If it's close to
>your advertised clock rate, then round it up to the clock rate for ease of
>calculation. As an example, my 550MHz P3 gives 548629000 ticks/sec using this
>method, so for your purposes I'd round it up to 550000000.
>
>Once you have this information, just divide by 5 million to get the number of
>ticks in 200ns.
>
>
>
Ok, that's exactly where I was trying to get to, I'll do some
experiments, thank you!
Alexandre
next prev parent reply other threads:[~2002-08-02 19:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-02 17:08 some questions using rdtsc in user space Alexandre P. Nunes
[not found] ` <3D4ACF11.FD7BB5B5@nortelnetworks.com>
2002-08-02 19:05 ` Alexandre P. Nunes [this message]
2002-08-03 4:31 ` Ben Greear
[not found] <Pine.LNX.4.33.0208021430590.2710-100000@coffee.psychology.mcmaster.ca>
2002-08-02 19:29 ` Alexandre P. Nunes
2002-08-02 20:58 ` george anzinger
[not found] <006901c23a81$08f52170$0100a8c0@brianwinxp>
2002-08-03 18:18 ` Alexandre Pereira Nunes
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=3D4AD817.3080200@PolesApart.wox.org \
--to=alex@polesapart.wox.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox