KeWaitForSingleObject doesn't return even though 0 timeout specified

Hi,
I want to check the state of an event object from a routine running at
DISPATCH_LEVEL, so I call KeWaitForSingleObject with a timeout of 0.
Unfortunately, KeWaitForSingleObject doesn’t return immediately as expected.
Here’s a snippet of my code. Do you see anything obviously wrong with it?
I see the first debug statement, but neither of the others.

DumpDebug ( DBG_TRACE, ( DRIVERNAME " - checking started event.\n" ));

if ( KeWaitForSingleObject ( &evStarted, Executive, KernelMode, FALSE,
0 ) == STATUS_SUCCESS )
{
DumpDebug ( DBG_TRACE, ( DRIVERNAME " - already started.\n\n" ));
return;
}

DumpDebug ( DBG_TRACE, ( DRIVERNAME " - starting.\n" ));

Linda

The last parameter is a pointer to a large integer. You’ve specified a
NULL timeout (ie. No timeout) rather than a zero timeout there.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Linda Marcellus
Sent: Friday, July 18, 2003 4:52 PM
To: Windows System Software Developers Interest List
Subject: [ntdev] KeWaitForSingleObject doesn’t return even though 0
timeout specified

Hi,
I want to check the state of an event object from a routine running at
DISPATCH_LEVEL, so I call KeWaitForSingleObject with a timeout of 0.
Unfortunately, KeWaitForSingleObject doesn’t return immediately as
expected.
Here’s a snippet of my code. Do you see anything obviously wrong with
it?
I see the first debug statement, but neither of the others.

DumpDebug ( DBG_TRACE, ( DRIVERNAME " - checking started event.\n"
));

if ( KeWaitForSingleObject ( &evStarted, Executive, KernelMode,
FALSE, 0 ) == STATUS_SUCCESS )
{
DumpDebug ( DBG_TRACE, ( DRIVERNAME " - already started.\n\n"
));
return;
}

DumpDebug ( DBG_TRACE, ( DRIVERNAME " - starting.\n" ));

Linda


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Use the following:

LARGE_INTEGER LiZero;
LiZero.QuadPart = 0;
KeWaitForSingleObject (&evStarted, Executive, KernelMode, FALSE, &LiZero);

Max

“Linda Marcellus” wrote in message
news:LYRIS-11365-120733-2003.07.18-19.51.39–maxim#xxxxx@lists.osr.c
om…
> Hi,
> I want to check the state of an event object from a routine running at
> DISPATCH_LEVEL, so I call KeWaitForSingleObject with a timeout of 0.

Thank you Max and Peter. What a novice mistake. It would have taken me a
while to see that.
Linda

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
>
> Use the following:
>
> LARGE_INTEGER LiZero;
> LiZero.QuadPart = 0;
> KeWaitForSingleObject (&evStarted, Executive, KernelMode, FALSE,
&LiZero);
>
> Max
>
> “Linda Marcellus” wrote in message
>
news:LYRIS-11365-120733-2003.07.18-19.51.39–maxim#xxxxx@lists.os
r.c
> om…
> > Hi,
> > I want to check the state of an event object from a routine running at
> > DISPATCH_LEVEL, so I call KeWaitForSingleObject with a timeout of 0.
>
>
>
>