zangyurong
驱动牛犊
驱动牛犊
  • 注册日期2011-06-25
  • 最后登录2011-06-28
  • 粉丝0
  • 关注0
  • 积分4分
  • 威望31点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1695回复:2

为什么我程序停止在KeWaitForSingleObject处了

楼主#
更多 发布于:2011-06-25 16:06

KSEMAPHORE  gstartiosem;
KSEMAPHORE  gdothreadsem;
KSEMAPHORE  gcmdcpltsem;
PCOMMAND gpcmdinthrd = NULL;
VOID fThreadPrint(IN PVOID pContex)
{
 OsPrint(("in thread "));
 KeReleaseSemaphore(&gdothreadsem, 0, 1, 0);
 while(1)
 {
  OsPrint(("wait cmd in"));
  KeWaitForSingleObject(&gstartiosem, Executive, KernelMode, FALSE, NULL);
  ldm_queue_cmd(gpcmdinthrd);
  OsPrint(("cmd cmplt"));
  KeReleaseSemaphore(&gcmdcpltsem, 0, 1, 0);
 }
 //PsTerminateSystemThread(STATUS_SUCCESS);
}
void CreateThread()
{
 HANDLE hThread;
 KeInitializeSemaphore(&gdothreadsem, 1, 1);
 KeInitializeSemaphore(&gstartiosem, 1, 1);
 KeInitializeSemaphore(&gcmdcpltsem, 1 ,1);
 KeWaitForSingleObject(&gdothreadsem, Executive, KernelMode, FALSE, NULL);
 KeWaitForSingleObject(&gstartiosem, Executive, KernelMode, FALSE, NULL);
 KeWaitForSingleObject(&gcmdcpltsem, Executive, KernelMode, FALSE, NULL);
 OsPrint(("create thread"));
 PsCreateSystemThread(&hThread, 0, NULL, NULL, NULL, fThreadPrint, NULL);
 KeWaitForSingleObject(&gdothreadsem, Executive, KernelMode, FALSE, NULL);
 ZwClose(hThread);
 OsPrint(("exit main thread"));
}
然后我在一个函数里等待命令然后唤醒线程,这里是不断的会被调用的。
  gpcmdinthrd = pCmd;
  KeReleaseSemaphore(&gstartiosem, 0, 1, 0);
  OsPrint(("wait gcmdcpltsem"));
  KeWaitForSingleObject(&gcmdcpltsem, Executive, KernelMode, FALSE, NULL);
 OsPrint(("return in OsSendCommand"));
 
我在Windbg下调试打印时,发现这个线程只运行了一遍,第二遍时就卡在了 KeWaitForSingleObject(&gcmdcpltsem, Executive, KernelMode, FALSE, NULL);这里
拜托各位帮我看看怎么回事
急求解啊
zangyurong
驱动牛犊
驱动牛犊
  • 注册日期2011-06-25
  • 最后登录2011-06-28
  • 粉丝0
  • 关注0
  • 积分4分
  • 威望31点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2011-06-25 16:56
求回复,求帮助
zangyurong
驱动牛犊
驱动牛犊
  • 注册日期2011-06-25
  • 最后登录2011-06-28
  • 粉丝0
  • 关注0
  • 积分4分
  • 威望31点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2011-06-28 10:56
没劲
游客

返回顶部