There is a description in the book "Windows Internals", which shows how determine the clock cycles per quantum - It can be derived from the current timer resolution:
include \masm32\include\masm32rt.inc
include \masm32\include\advapi32.inc
includelib \masm32\lib\advapi32.lib
NTQUERYTIMERRESOLUTION typedef proto MinimumResolution:PULONG,MaximumResolution:PULONG,ActualResolution:PULONG
PNTQUERYTIMERRESOLUTION typedef ptr NTQUERYTIMERRESOLUTION
UULONG union
qw QWORD ?
ul ULONG ?
UULONG ends
.const
c0 REAL8 1.0E6
c1 REAL8 100.0E-9
c3 REAL8 0.33333333333333333
.data?
NtQueryTimerResolution PNTQUERYTIMERRESOLUTION ?
.code
main proc uses esi
LOCAL hKey:HKEY
LOCAL ulMHz:UULONG,_size:DWORD
LOCAL ulMinimumResolution:UULONG,ulMaximumResolution:UULONG,ulActualResolution:UULONG
LOCAL MinimumResolution:REAL8,MaximumResolution:REAL8,ActualResolution:REAL8,MHz:REAL8
LOCAL r8:REAL8
.repeat
; get undocumented function NtQueryTimerResolution :-|
.if !rvx(NtQueryTimerResolution = GetProcAddress,rv(GetModuleHandle,"Ntdll.dll"),"NtQueryTimerResolution")
print "error: can't locate NtQueryTimerResolution",13,10
.break
.endif
mov _size,4
.if rvx(esi = RegOpenKeyEx,HKEY_LOCAL_MACHINE,"HARDWARE\DESCRIPTION\System\CentralProcessor\0",0,KEY_READ,&hKey) != ERROR_SUCCESS || \
rvx(RegQueryValueEx,hKey,"~MHz",0,0,&ulMHz, &_size) != ERROR_SUCCESS
print "error: can't read CPU frequency from registry",13,10
.break
.endif
mov ulMHz.ul[4],0
fild ulMHz.qw
fmul c0
fstp MHz
fnc crt_printf,"CPU frequency: %u [MHz]\n",ulMHz.ul
fn NtQueryTimerResolution,&ulMinimumResolution,&ulMaximumResolution,&ulActualResolution
FOR var,<MinimumResolution,MaximumResolution,ActualResolution>
mov ul&var&.ul[4],0
fild ul&var&.qw
fmul c1
fst var ; -> seconds
fmul MHz
fmul c3 ; var*(1/3) -> Windows Internal: "each quantum unit is one-third of a clock interval"
fstp r8 ; -> clocks per quantum
fnc crt_printf,"Timer: &var : %.6G [s] -\r clocks/quantum: %G\n",var,r8
ENDM
.until 1
inkey
exit
main endp
end mainThey also mention that there is a variable that can be read out in kernel mode: KiCyclesPerClockQuantum.
for my i7QM:
CPU frequency: 2294 [MHz]
Timer: MinimumResolution : 0.0156001 [s] -> clocks/quantum: 1.19289E+007
Timer: MaximumResolution : 0.0005 [s] -> clocks/quantum: 382333
Timer: ActualResolution : 0.001 [s] -> clocks/quantum: 764667
Press any key to continue ...AFAICS this result only applies when the CPU is not throttled.