今天在WINCE5.0+S3C2440系统调试检测出租车是否载客的驱动的时候遇到这样的问题:
发现在开机启动加载驱动过程中调用PostMessage函数时会导致调用的线程崩溃,比如如果下面的线程在创建时调用了:
PostMessage(HWND_BROADCAST, MSG_TAXI_BUSY, 0, 1);//taxi idle
就会弹出下面的信息:
AKY=00000005 PC=8c2d54fc(NK.EXE+0x000d54fc) RA=8c2c0b38(NK.EXE+0x000c0b38) BVA=00000001 FSR=00000001
如果在系统加载完成后再调用PostMessage函数就不会有这个问题,至于原因目前还不知道,如果知道的朋友,麻烦告知,谢谢。
下面是改为中断检查的线程Taxi_MonitorThread的实现:
DWORD
Taxi_MonitorThread(PVOID pArg)
{
Taxi_EnableInterrupt();
gTaxiStatuIntrEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!(InterruptInitialize(SYSINTR_TAXI, gTaxiStatuIntrEvent, 0, 0)))
{
RETAILMSG(1, (TEXT("::: SYSINTR_POWER Init Fail/r/n")));
}
while(1)
{
WaitForSingleObject(gTaxiStatuIntrEvent, INFINITE);
if(v_pIOPregs->rGPFDAT&(0x1<<7))
{
RETAILMSG(1, (TEXT("taxi idle!/r/n")));
PostMessage(HWND_BROADCAST, MSG_TAXI_BUSY, 0, 1);//taxi idle
}
else
{
RETAILMSG(1, (TEXT("taxi busy!/r/n")));
PostMessage(HWND_BROADCAST, MSG_TAXI_BUSY, 1, 1);//taxi busy
}
InterruptDone(SYSINTR_POWER);
}
}
解决此问题的帖子http://topic.csdn.net/u/20110325/14/9c29b991-64e1-42a0-b4b3-bafe1241765c.html