[lkml]   [2002]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: some questions using rdtsc in user space
    Chris Friesen wrote:

    >>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!


    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:27    [W:0.023 / U:37.212 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site