linac
驱动牛犊
驱动牛犊
  • 注册日期2005-04-25
  • 最后登录2005-11-20
  • 粉丝0
  • 关注0
  • 积分16分
  • 威望3点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1480回复:6

windows 内核定时粒度是多少?

楼主#
更多 发布于:2005-05-11 06:52
定时器用100纳秒,但实际粒度应该大于此数。

最新喜欢:

TOMG2004TOMG20...
linac
驱动牛犊
驱动牛犊
  • 注册日期2005-04-25
  • 最后登录2005-11-20
  • 粉丝0
  • 关注0
  • 积分16分
  • 威望3点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2005-05-14 23:31
驱动不能调用multimedia库。
老大,1ms定时如何办法?
linac
驱动牛犊
驱动牛犊
  • 注册日期2005-04-25
  • 最后登录2005-11-20
  • 粉丝0
  • 关注0
  • 积分16分
  • 威望3点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2005-05-13 14:19
打破砂锅问到底。

xp ddk中说KTIMER的定时精度是10 ms。也可以通过SetTimerResolution改成1ms?
另KeQuerySystemTime得到的时间会否被用户改变?即我需要一个从驱动加载开始一个线性的相对时间坐标,用什么api?
bmyyyud
驱动老牛
驱动老牛
  • 注册日期2002-02-22
  • 最后登录2010-01-21
  • 粉丝0
  • 关注0
  • 积分1000分
  • 威望130点
  • 贡献值0点
  • 好评度106点
  • 原创分0分
  • 专家分0分
地板#
发布于:2005-05-11 15:33
可以取8254的状态看看
9x 2k xp 每种操作系统都不同
 

是8253吧,太老了 :D
滚滚长江东逝水 浪花淘尽英雄 是非成败转头空 青山依旧在 几度夕阳红 白发渔樵江渚上 惯看秋月春风 一壶浊酒喜相逢 古今多少事 尽付笑谈中
boly81
驱动小牛
驱动小牛
  • 注册日期2004-06-25
  • 最后登录2012-06-08
  • 粉丝0
  • 关注0
  • 积分490分
  • 威望73点
  • 贡献值0点
  • 好评度49点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2005-05-11 13:47
可以取8254的状态看看
9x 2k xp 每种操作系统都不同
linac
驱动牛犊
驱动牛犊
  • 注册日期2005-04-25
  • 最后登录2005-11-20
  • 粉丝0
  • 关注0
  • 积分16分
  • 威望3点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2005-05-11 11:17
精采,放分。
bmyyyud
驱动老牛
驱动老牛
  • 注册日期2002-02-22
  • 最后登录2010-01-21
  • 粉丝0
  • 关注0
  • 积分1000分
  • 威望130点
  • 贡献值0点
  • 好评度106点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2005-05-11 10:48
定时器用100纳秒,但实际粒度应该大于此数。

这个问题大师已回答的非常完美
引用











 



  



Copyright ? 1997 Mark Russinovich
Last Updated: Last updated July 9, 1997
Note: The information presented here is the result of my own study. No source code was used.

Introduction
High resolution timers are desirable in a wide variety of different applications. For example, the most common use of such timers in Windows is by multimedia applications that are producing sound or audio that require precise control. MIDI is a perfect example because MIDI sequencers must maintain the pace of MIDI events with 1 millisecond accuracy. This article describes how high resolution timers are implemented in NT and documents NtSetTimerResolution and NtQueryTimerResolution, the NT kernel functions that manipulate and return information about the system clock. Unfortunately, NtSetTimerResolution and NtQueryTimerResolution are not exported by the NT kernel, so they are not available to kernel-mode device drivers.
The Timer API
Windows NT bases all of its timer support off of one system clock interrupt, which by default runs at a 10 millisecond granularity. This is therefore the resolution of standard Windows timers. When a multimedia application uses the timeBeginPeriod mutlimedia API, which is exported by the Windows NT dynamic link library WINMM.DLL, the call is redirected into the Windows NT kernel-mode function NtSetTimerResolution, which is exported by the native Windows NT library NTDLL.DLL.

NtSetTimerResolution and NtQueryTimerResolution are defined as follows. All times are specifified in hundreds of nanoseconds.

NTSTATUS NtSetTimerResolution (

    IN ULONG RequestedResolution,
    IN BOOLEAN Set,
    OUT PULONG ActualResolution


);

Parameters

RequestedResolution

The desired timer resolution. Must be within the legal range of system timer values supported by NT. On standard x86 systems this is 1-10 milliseconds. Values that are within the acceptable range are rounded to the next highest millisecond boundary by the standard x86 HAL. This parameter is ignored if the Set parameter is FALSE.

Set

This is TRUE if a new timer resolution is being requested, and FALSE if the application is indicating it no longer needs a previously implemented resolution.

ActualResolution

The timer resolution in effect after the call is returned in this parameter.

Comments

NtSetTimerResolution returns STATUS_SUCCESS if the resolution requested is within the valid range of timer values. If Set is FALSE, the caller must have made a previous call to NtSetTimerResolution or STATUS_TIMER_RESOLUTION_NOT_SET is returned.

NTSTATUS NtQueryTimerResolution (

    OUT PULONG MinimumResolution,
    OUT PULONG Maximum Resolution,
    OUT PULONG ActualResolution


);

Parameters

MinimumResolution

The minimum timer resolution. On standard x86 systems this is 0x2625A, which is about 10 milliseconds

MaximumResolution

The maximum timer resolution. On standard x86 systems this is 0x2710, which is about 1 millisecond.

ActualResolution

This is the current resolution of the system clock.
Implementation Details
NtSetTimerResolution can be called to set timer resolutions by more than on application. To support a subsequent process setting a timer resolution without violating the resolution assumptions of a previous caller, NtSetTimerResolution never lowers the timer\'s resolution, only raises it. For example, if a process sets the resolution to 5 milliseconds, subequent calls to set the resolution to between 5 and 10 millseconds will return a status code indicating success, but the timer will be left at 5 milliseconds.

NtSetTimerResolution also keeps track of whether a process has set the timer resolution in its process control block, so that when a call is made with Set equal to FALSE it can verify that the caller has previously requested a new resolution. Every time a new resolution is set a global counter is incremented, and every time it is reset the counter is decremented. When the counter becomes 0 on a reset call the timer is changed back to its default rate, otherwise no action is taken. Again, this preserves the timer resolution assumptions of all the applications that have requested high resolution timers by guaranteeing that the resolution will be at least as good as what they specified.

You can use the ClockRes applet from Sysinternals to view the current clock resolution on your system.



Back to Top


附件名称/大小 下载次数 最后更新
2005-05-11_CLOCKRES.ZIP (20KB)  20
滚滚长江东逝水 浪花淘尽英雄 是非成败转头空 青山依旧在 几度夕阳红 白发渔樵江渚上 惯看秋月春风 一壶浊酒喜相逢 古今多少事 尽付笑谈中
游客

返回顶部