如何获得当前的Windows系统范围内的计时器分辨率 [英] How to get the current Windows system-wide timer resolution
问题描述
我知道,默认值是15.6 每个时钟毫秒,但有些失败者可能会改变它,然后来回换一次又一次,我需要轮询当前值是什么进行有效QueryPerformanceCounter的同步。 p>
那么,有没有一个API的方式,以得到定时器分辨率?
我在C ++ BTW。
的Windows计时器的分辨率是由隐藏的API调用提供的:
NTSTATUS NtQueryTimerResolution(OUT PULONG MinimumResolution,
OUT PULONG MaximumResolution,
OUT PULONG ActualResolution);
NtQueryTimerResolution是由本地的Windows NT库ntdll.dll输出。
通用硬件平台156,250报告或为100144的 ActualResolution 的;旧平台可能会报告甚至更大的数字;较新的系统中,当HPET(高precision事件定时器)或恒定/ TSC不变的支持格外,可能为ActualResolution返回156001。
拨打 timeBeginPeriod(N)
反映在的 ActualResolution 的
I know that the default is 15.6 ms per tick, but some loser may change it and then change back and forth again and again, and I need to poll what the current value is to perform valid QueryPerformanceCounter synchronization.
So is there an API way to get the timer resolution?
I'm on C++ BTW.
Windows timer resolution is provided by the hidden API call:
NTSTATUS NtQueryTimerResolution(OUT PULONG MinimumResolution,
OUT PULONG MaximumResolution,
OUT PULONG ActualResolution);
NtQueryTimerResolution is exported by the native Windows NT library NTDLL.DLL.
Common hardware platforms report 156,250 or 100,144 for ActualResolution; older platforms may report even larger numbers; newer systems, particulary when HPET (High Precision Event Timer) or constant/invariant TSC are supported, may return 156,001 for ActualResolution.
Calls to timeBeginPeriod(n)
are reflected in ActualResolution.
More details in this answer.
这篇关于如何获得当前的Windows系统范围内的计时器分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!