阅读:3081回复:5
有别的方法替代KeStallExecutionProcessor吗?
我在一个driver,我们的芯片硬件设计有点问题,一个command下去,不知道什么时候做完,所以总是要delay一小段时间,我用KeStallExecutionProcessor来delay小于50个microsecond,但是读写数据的时候,CPU占用率很高,90%啊,哥们,有没有好的方法替代KeStallExecutionProcessor的。
谢谢了。 |
|
|
沙发#
发布于:2005-02-02 14:10
void
SysDelay( ULONG Timeout ) /*++ SysDelay: performs a required delay. The usage of KeStallExecutionProcessor is very nasty, but it happends only if SysDelay is called in the context of our DPC routine (which is only called if a card change was detected). For 'normal' IO we have Irql < DISPATCH_LEVEL, so if the reader is polled while waiting for response we will not block the entire system Arguments: Timeout delay in milli seconds Return Value: void --*/ { LARGE_INTEGER SysTimeout; if( KeGetCurrentIrql() >= DISPATCH_LEVEL ) { ULONG Cnt = 20 * Timeout; while( Cnt-- ) { // KeStallExecutionProcessor: counted in us KeStallExecutionProcessor( 50 ); } } else { SysTimeout.QuadPart = (LONGLONG)-10 * 1000 * Timeout; // KeDelayExecutionThread: counted in 100 ns KeDelayExecutionThread( KernelMode, FALSE, &SysTimeout ); } return; } |
|
板凳#
发布于:2005-02-02 14:32
nop
nop nop nop 。。。 nop 你看看一个nop消耗多少时间,然后 算出需要几个nop |
|
|
地板#
发布于:2005-02-02 16:03
nop 这个方法可取,Linux中就是这样做的,用循环做NOP操作 |
|
|
地下室#
发布于:2005-02-02 17:48
楼上的和我想到一起了 :D
|
|
|
5楼#
发布于:2005-02-03 11:36
可以用空循环,
While() { } |
|