阅读:1237回复:3
关于在驱动程序中使用定时器,能给例子吗?
我想在驱动程序中使用定时器
以便于在超时的时候结束IO请求 各位大虾谁有例子,或能给点建议 请帮忙了 i_tingfeng@163.com 先谢过了 |
|
沙发#
发布于:2003-08-02 02:56
you can follow these steps:
// 1. inside device extension KDPC watchDogDpc; //define timer DPC KTIMER watchDogTimer; //define a kernel timer obj // 2. inside start devie rountine or other place before you use this timer KeInitializeTimerEx(&pdx->watchDogTimer,NotificationTimer); KeInitializeDpc(&pdx->watchDogDpc,WatchDogPro,pdx); // 3. the place you start the timer KeSetTimer(&pdx->watchDogTimer, duetime, &pdx->watchDogDpc); // 4. your service when time out happens VOID WatchDogPro(PKDPC dpc, PVOID pContext, PVOID p1, PVOID p2) { PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION)pContext; KdPrint((\"WatchDogPro(): time out happen..\\n\")); //your service following here } // 5. before time out happen, if your expecting event happens, cancel the timer // so that the time out service routine will not run KeCancelTimer(&pdx->watchDogTimer); |
|
板凳#
发布于:2003-08-02 12:23
谢谢指教
我回去试 |
|
地板#
发布于:2003-08-07 16:10
还是不好,奇怪了
|
|