阅读:1757回复:11
再问驱动程序中如何计时
我用KeQueryInterruptTime函数,似乎windows nt4不支持。
然后改用KeQueryTickCount,KeQuerySystemTime,KeQueryTimeIncrement等,都不起作用。 我想测试整个DMA传输的耗时,我在启动Dma之前调用一次,在结束Dma之后再调用一次,发现两次调用的计时是相同的,为什么啊?难道进入驱动程序中,时钟的计数器就暂停了吗? |
|
最新喜欢:wolfwa... |
沙发#
发布于:2003-07-21 15:50
用户被禁言,该主题自动屏蔽! |
|
板凳#
发布于:2003-07-21 15:59
你是说那个函数好使啊?
老大是怎么使的? 到我这怎么就不好使了呢? |
|
地板#
发布于:2003-07-22 16:48
是否进入中断处理程序之后,系统时钟计数就会停止?
就好像进入softice之后,机器的时钟就会停止一样。 我这两天的实验观察给我这种感觉。 请教各位大虾! |
|
地下室#
发布于:2003-07-24 03:51
KeQuerySystemTime()
is Ok. this is my code: void DoDma() { // prepare for dma ... KeQuerySystemTime(&(pdx->startTime)); //start dma ... } BOOLEAN OnInterrupt(...) { // check is my interrrupt? ... //if this is my interrupt KeQuerySystemTime(&(pdx->endTime)); .... //print out dma time, here the time uint is 100ns KdPrint((\"DMAUsedTime=%x\\n\", pdx->endTime.QuadPart - pdx->startTime.QuadPart)); ... } |
|
5楼#
发布于:2003-07-24 08:52
我也是这么做的呀,为什么两次取得的计数值是相等的,结果一减耗时为零,faint了。
|
|
6楼#
发布于:2003-07-24 09:42
是否进入中断处理程序之后,系统时钟计数就会停止? 进入Softice机器时钟会停止。 记得上学时有一次跟踪一个程序,调完以后看计算机的时钟 才晚上九点多,出去一看已经全都熄灯了。 |
|
|
7楼#
发布于:2005-03-03 14:00
KeQuerySystemTime() 我现在也需要做计时处理. 打印数据时用的是DebugPrint 请问上面的程序里的pdx是怎么定义的呢? 还有QuadPart是什么意思呢? 我需要测的时间间隔是10-100us之间,如果测出的时间单位是100ns是再好不过了! 我用下面的程序测出的结果是起点和终点一样大,没法得出时间差. LARGE_INTEGER startTime, endTime //测量起点 KeQuerySystemTime(&startTime); DebugPrint(\"DispatchRead() : startTime = %L \", startTime) ; //测量终点 KeQuerySystemTime(&endTime); DebugPrint(\"DispatchRead() : endTime = %L \", endTime) ; 我在DDK帮助上看到这样的关于KeQuerySystemTime的说明: System time is typically updated approximately every ten milliseconds. 是不是说小于10ms的时间段就没法用KeQuerySystemTime来测了呢? 还请大虾指教. |
|
8楼#
发布于:2005-03-03 15:34
I guess the finest system timer resolution is 100 nanosecond.
|
|
9楼#
发布于:2005-03-12 11:07
引自www.sysinternals.com的文章
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. 标题不知为什么粘不上 写上Inside Windows Nt High resolution timers |
|
|
10楼#
发布于:2005-03-12 11:28
老大。能不能先贴下解决放方案,再贴介绍啊?
英文看的好累啊! |
|
11楼#
发布于:2005-03-12 11:35
老大。能不能先贴下解决放方案,再贴介绍啊? 其实就是调用未输出的NtSetTimerResolution 或者用一个用户模式下的应用程序调用timeBeginPeriod mutlimedia API,先设置一下,就可以了 |
|
|