Re: QueryPerformanceFrequency



While rdtsc is one possible implementation, on some CPUs/systems the QPC needs to be implemented in a more complex manner (multiple CPUs, CPUs with adaptive frequency, like seen first in notebooks and now in most systems...)

I would definitely not recommend using rdtsc directly - it was quite a common practice in game programming to do this a few years back, and games which did it are experiencing serious compatibility issues recently.

Even on CPU with no rdtsc instruction was introduced, the QPC was implemented on most systems, usualy using some motherboard high frequency counter (like 4 MHz).


Ondrej
Alex Blekhman napsal(a):
"David Webber" wrote:
The topic "About timers" in the documentation says:

"If a high-resolution performance counter exists on the system, you can use the QueryPerformanceFrequency function to express the frequency, in counts per second"

The "if" is a bit worrying: am I likely to encounter systems on which there isn't one?

A high-resolution performance counter is an euphemism for RDTSC CPU instruction. It was introduced with Intel's Pentium processors.

Alex


.



Relevant Pages

  • Re: High resolution timer.
    ... It should run on Windows and Linux so there is no Win32 API. ... The first thing to use is RDTSC. ... What about multiple CPUs. ...
    (comp.lang.asm.x86)
  • Re: [PATCH] [5/20] x86: Introduce nsec_barrier()
    ... to avoid races with timer interrupts on other CPUs. ... Except for x86 it is a nop right now. ... On CPUs without SSE there is generally no RDTSC ... That's most likely wrong unless you added two barriers -- the barriers ...
    (Linux-Kernel)
  • Re: [PATCH] [5/20] x86: Introduce nsec_barrier()
    ... to avoid races with timer interrupts on other CPUs. ... only tested x86, but it's a very simple change. ... On CPUs without SSE there is generally no RDTSC ...
    (Linux-Kernel)
  • Re: gettimeofday resolution seriously degraded in test9
    ... > modifies the gettimeofdayand the POSIX clock routines to ... > use rdtsc when available, a lot of problems will go away. ... sure most other modern cpus do too. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)