Performance counters and LARGE_INTEGER values

  • Thread starter Thread starter Bob Altman
  • Start date Start date
B

Bob Altman

Hi all,

QueryPerformanceCounter returns a LARGE_INTEGER, which the documentation
states is equivalent to a signed 64-bit integer. My question is, can
QueryPerformanceCounter return negative values, or is its output restricted
to positive values? TIA!
 
Hi Bob Altman,
QueryPerformanceCounter returns a LARGE_INTEGER, which the
documentation states is equivalent to a signed 64-bit integer. My
question is, can QueryPerformanceCounter return negative values, or is
its output restricted to positive values? TIA!

QueryperformanceCounter internaly sometimes uses the RDTSC instruction. And
this value is an unsigned 64-bit value. Therefor if you interpret this
value as signed, it might become negative...


BUT: On current processor speeds (3GHz) it will take about 95 years of a
continuous running CPU to reach the "negative" value.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
Jochen Kalmbach said:
QueryperformanceCounter internaly sometimes uses the RDTSC instruction.
And
this value is an unsigned 64-bit value. Therefor if you interpret this
value as signed, it might become negative...


To be exact, QPC/QPF use different counters under different circumstances.
On my system, the clock used for these functions is much slower than the CPU
clock; I believe it's using some clock on the motherboard. If you think
about the multi-CPU case, RDTSC stops making sense.
 
Hi Tim Robinson,
To be exact, QPC/QPF use different counters under different
circumstances. On my system, the clock used for these functions is
much slower than the CPU clock; I believe it's using some clock on the
motherboard. If you think about the multi-CPU case, RDTSC stops making
sense.

I just wanted to show that in the fastes possible implementation (RDTSC),
it will take 95 years to become negative!

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
[...]
I just wanted to show that in the fastes possible implementation (RDTSC),
it will take 95 years to become negative!

A fair point :).

/me goes and tests Jochen's theory
 
But the TSC can be user-set to any value, at
any time. Not that you'd want to, but anyone
(typically) could.
 
Hi ,
But the TSC can be user-set to any value, at
any time. Not that you'd want to, but anyone
(typically) could.

Not 100% true...

<quote>
When the WRMSR instruction is used to write to the time-stamp
counter, only the low order 32-bits of the time-stamp counter can be
written to, and the highorder 32 bits cleared to all 0s.
</quote>

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
JK- [Mon, 21 Mar 2005 22:28:33 -0800]:
Not 100% true...

Right you are ... not the full 64 bits since the P6,
apparently all 64 in the P5. Do you have a P5 to
try? I've got some...on the wall. Smart move in
any case.
 
Back
Top