Tech Support > Microsoft Windows > Drivers > Is there a kernel api or assembly instruction by which I can get the processor clock ticks from within kernel code?
Is there a kernel api or assembly instruction by which I can get the processor clock ticks from within kernel code?
Posted by Praveen Kumar Amritaluru on January 3rd, 2008


Hi,

Is there a kernel api or assembly instruction in Windows by which I can get
the number of processor clock ticks from within kernel code?
I want to measure the number of processor cycles that are elapsed between
two particular points within my code.
OS ticks is not granular enough to be useful for this purpose.

Its fine even if its an assembly instruction which I can execute from
within my kernel driver.
I am looking to use it both on systems with AMD/Intel Procs.

I have done such measurements on a different OS. So trying to figure out
similar solution on Windows Vista.

Thanks,
-Praveen


Posted by Don Burn on January 3rd, 2008


Yes you can do this KeQueryPerformanceCounter or KeQueryTickCount. Note:
that you can have problems with the fact that if your code runs on more that
one processor there may be some errors in the calculation. Of course a
reschedule in the code will have huge impacts anyway.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply


"Praveen Kumar Amritaluru" <apraveen.kumar@gmail.com> wrote in message
news:%23HZ54ZhTIHA.3400@TK2MSFTNGP03.phx.gbl...


Posted by Alexander Grigoriev on January 4th, 2008


Use _rdtsc() intrinsic function.

"Praveen Kumar Amritaluru" <apraveen.kumar@gmail.com> wrote in message
news:%23HZ54ZhTIHA.3400@TK2MSFTNGP03.phx.gbl...


Posted by Stephan Wolf [MVP] on January 4th, 2008


Don's note can be important on some multi-processor systems because
the timestamp can be different on each processor (which is AFAIK a
hardware bug).

Thus, you should IMHO use KeGetCurrentProcessorNumber() in combination
with KeQueryPerformanceCounter().

Stephan
---
On Jan 3, 3:48*pm, "Don Burn" <b...@stopspam.windrvr.com> wrote:


Similar Posts