Thanks, Bill:
I agree with you, but it seems it is not the case in my
function. Here is my code snipet. Please let me know if
you find anything weird. The error does not happy all the
time, but it does happen frequently. I saw this error
when I run the following function repeatedly in a loop
especially on Windows 2000.
Thanks,
zhong
// Omit the error check of course.
int DD_StartDma( ... )
{
DWORD StatusCode;
IOCTLDATA IoBuffer;
OVERLAPPED OverLapped, *pOverLapped;
HANDLE hEvent;
RETURN_CODE code = ApiSuccess;
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
OverLapped.hEvent = hEvent;
OverLapped.Offset = 0;
OverLapped.OffsetHigh = 0;
memset(&(IoBuffer.u.DmaData.u.TxParams), 0, sizeof
(DMA_TRANSFER_ELEMENT));
// Initialize IoBuffer for transaction
IoBuffer.u.DmaData.u.TxParams.LocalToPciDma =
bLocal2Pci;
IoBuffer.u.DmaData.u.TxParams.TransferCount =
size;
IoBuffer.u.DmaData.u.TxParams.u.UserVa =
(UINT32)pUserVa; // Virtual address of buffer
IoBuffer.u.DmaData.u.TxParams.Offset =
nOffset;
IoBuffer.u.DmaData.u.TxParams.LocalAddr =
LocalAddress; // Local bus address
IoBuffer.u.DmaData.channel
= (DMA_CHANNEL)uChan;
IoBuffer.ReturnCode
= ApiSuccess;
// Macro for DeviceIoControl() call
IoMessage(
m_hDevice,
MDL_DMA_TRANSFER,
&(IoBuffer),
sizeof(IOCTLDATA),
&OverLapped
);
StatusCode = WaitForSingleObject(hEvent,
MAX_DMA_TIMEOUT );
switch (StatusCode)
{
case WAIT_OBJECT_0:
TRACE("Exit ... DD_StartDma succeeds ...\n");
code = ApiSuccess;
break;
case WAIT_TIMEOUT:
TRACE("Exit ... DD_StartDma timeout ...\n");
code = ApiPciTimeout;
break;
case WAIT_FAILED:
TRACE("Exit ... DD_StartDma failed ...\n");
code = ApiFailed;
break;
default:
TRACE("Exit ... DD_StartDma failed ...\n");
code = ApiFailed;
break;
}
CloseHandle(hEvent);
}
return code;
-----Original Message-----
Pardon me for jumping into this conversation.
First, while it is always a possibility that there is a problem with
WaitForSingleObject() it is in my view an
extraordinarily remote one because