最近在做wince的驅動中,想在一個IST線程中處理兩個硬件中斷,自己想偷懶,不想用兩個線程來做,故就用WaitForMultipleObjects函數去等待那兩個中斷線程,一直不能成功。用GetLastError(),獲取msg全是87,說是傳參數有問題,但是我兩個事件的創建都是成功的啊,沒有相應的error的log信息。鬱悶了一個下午,後來在查了幫助ms的幫助文檔,終於找到原因了,我不能那樣幹。
自己記性不好,故記錄在這裏,以防自己忘記。同時希望,能對和我犯同樣錯誤的看客有所幫助。呵呵
本文鏈接地址:http://blog.csdn.net/bbw2008/archive/2011/05/04/6393329.aspx
與中斷關聯過的EVENT,在IST線程中,只能使用
DWORD WaitForSingleObject(
HANDLE hHandle,
DWORD dwMilliseconds
);
不能使用
DWORD WaitForMultipleObjects( DWORD nCount, CONST HANDLE* lpHandles, BOOL fWaitAll, DWORD dwMilliseconds );
詳細wince的InterruptInitialize函數的幫助文檔,
ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.WindowsCE.v60.en/CE_OS_IntExplorer/html/4ae3a36b-759a-4103-8251-ecac4c440103.htm
This function must be called before using the hEvent parameter, which provides a link between the idInt parameter and the SYSINTR value returned by an ISR.
The hEvent parameter can be used only in a WaitForSingleObject call to wait for the event to be triggered by the kernel.
A WaitForMultipleObjects call with hEvent fails.
If you use hEvent in a call to WaitForSingleObject before you call InterruptInitialize, InterruptInitialize fails.
InterruptInitialize is a kernel-mode-only function. For more information about kernel-mode-only functions, see Kernel Mode APIs.
InterruptInitialize is used with device drivers and user-mode drivers. For more information about user-mode drivers, see User Mode Driver Framework.