Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2005

Tip: Looking for answers? Try searching our database.

Performance counters and LARGE_INTEGER values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob Altman - 20 Mar 2005 17:51 GMT
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!
Jochen Kalmbach - 20 Mar 2005 18:09 GMT
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.

Signature

Greetings
 Jochen

  My blog about Win32 and .NET
  http://blog.kalmbachnet.de/

Tim Robinson - 21 Mar 2005 01:23 GMT
>> QueryPerformanceCounter returns a LARGE_INTEGER, which the
>> documentation states is equivalent to a signed 64-bit integer.  My
[quoted text clipped - 5 lines]
> 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.

Signature

Tim Robinson
MVP, Windows SDK

Jochen Kalmbach - 21 Mar 2005 07:35 GMT
Hi Tim Robinson,

>>> QueryPerformanceCounter returns a LARGE_INTEGER, which the
>>> documentation states is equivalent to a signed 64-bit integer.  My
[quoted text clipped - 11 lines]
> 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!

Signature

Greetings
 Jochen

  My blog about Win32 and .NET
  http://blog.kalmbachnet.de/

Tim Robinson - 21 Mar 2005 21:12 GMT
[...]
>> To be exact, QPC/QPF use different counters under different
>> circumstances. On my system, the clock used for these functions is
[quoted text clipped - 4 lines]
> 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

Signature

Tim Robinson
MVP, Windows SDK

- 22 Mar 2005 03:45 GMT
But the TSC can be user-set to any value, at
any time.  Not that you'd want to, but anyone
(typically) could.

Signature

40th Floor - Software  @  http://40th.com/
iPlay : the ultimate audio player for PPCs
mp3,mp4,m4a,aac,ogg,flac,wav,play & record
parametric eq, xfeed, reverb: all on a ppc

Jochen Kalmbach - 22 Mar 2005 07:28 GMT
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>

Signature

Greetings
 Jochen

  My blog about Win32 and .NET
  http://blog.kalmbachnet.de/

- 22 Mar 2005 10:00 GMT
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.

Signature

40th Floor - Software  @  http://40th.com/
iPlay : the ultimate audio player for PPCs
mp3,mp4,m4a,aac,ogg,flac,wav,play & record
parametric eq, xfeed, reverb: all on a ppc


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.