i_tingfeng
驱动牛犊
驱动牛犊
  • 注册日期2002-11-28
  • 最后登录2004-12-16
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1224回复:3

关于在驱动程序中使用定时器,能给例子吗?

楼主#
更多 发布于:2003-08-01 20:01
我想在驱动程序中使用定时器
以便于在超时的时候结束IO请求
各位大虾谁有例子,或能给点建议
请帮忙了
i_tingfeng@163.com
先谢过了
hong
驱动小牛
驱动小牛
  • 注册日期2001-09-19
  • 最后登录2005-12-16
  • 粉丝0
  • 关注0
  • 积分2分
  • 威望1点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于: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);

i_tingfeng
驱动牛犊
驱动牛犊
  • 注册日期2002-11-28
  • 最后登录2004-12-16
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2003-08-02 12:23
谢谢指教
我回去试
i_tingfeng
驱动牛犊
驱动牛犊
  • 注册日期2002-11-28
  • 最后登录2004-12-16
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地板#
发布于:2003-08-07 16:10
还是不好,奇怪了
游客

返回顶部