Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

KeWaitForSingleObject not working with a timeout

896 views
Skip to first unread message

Colin Caughie

unread,
Feb 13, 2001, 6:28:08 AM2/13/01
to
I've got a really wierd situation where KeWaitForSingleObject just doesn't
seem to be waiting. It's being called from a driver created thread, and
waits for a semaphore to be signalled with a timeout of 1 second (10000000
100ns intervals). If I set the timeout argument to NULL it waits
indefinitely as expected, but if I do use a timeout it returns immediately,
causing the driver thread to hog the CPU.

The code looks something like this:

LARGE_INTEGER lnTimeout;

lnTimeout.QuadPart = (LONGLONG) ( nTimeout * 10000 );

DTRACE(( "WaitEvent: Timeout is %d\n", lnTimeout.LowPart ));
DTRACE(( "WaitEvent: IRQL is %d\n", KeGetCurrentIrql() ));
DTRACE((
"Semaphore: %d,%d,%d,%d,%d,%d\n",
(int) pExtension->semWakeUp.Header.Type,
(int) pExtension->semWakeUp.Header.Absolute,
(int) pExtension->semWakeUp.Header.Size,
(int) pExtension->semWakeUp.Header.Inserted,
(int) pExtension->semWakeUp.Header.SignalState,
(int) pExtension->semWakeUp.Limit
));

return KeWaitForSingleObject(
&pExtension->semWakeUp,
Executive,
KernelMode,
TRUE,
&lnTimeout
);

I've put a lot of trace information in to try to figure out what's causing
it. What comes out is:

WaitEvent: Timeout is 10000000
WaitEvent: IRQL is 0
Semaphore: 5,0,5,0,0,100

If I put timing information around the call to KeWaitForSingleObject it
reports that no time has elapsed during the call.

I'm running Windows 2000 SP1.

Can anyone help???

Thanks in advance,

Colin Caughie

Clemens Fischer

unread,
Feb 13, 2001, 6:33:52 AM2/13/01
to
Hi Colin,

I once also faced this problem and i think ( know ) it has to do with
the type/cast and pls concider that when using
a positive multiplier its absolute time !

I´m doing like this :

DueTime.QuadPart = (LONGLONG)( UInt32x32To64 ( 1000 /*ms*/ , 1 )
* -10000 /*100-ns-intervals*/ );

So long,
Clemens


Colin Caughie

unread,
Feb 13, 2001, 6:40:31 AM2/13/01
to
Thanks Clemens, it was indeed the absolute time thing. I figured it out
about thirty seconds after writing my last post (funny how that tends to
happen!). If I make the value negative it works fine.

Colin

"Clemens Fischer" <Clemens...@sea.ericsson.se> wrote in message
news:96b5d1$k4r$1...@newstoo.ericsson.se...

billy_driverhound

unread,
Feb 13, 2001, 12:31:17 PM2/13/01
to
What is the return value from the call to KeWait...? You have alertable set
to TRUE, so your wait may have been alerted. Also, you have specified an
absolute interval, so if something is jacking with your system time, you
will get inaccurate results. I would multiply your timeout by -1, to make
it relative and set Alertable to FALSE, and I bet your wait will work just
fine.

Bill M.


"Colin Caughie" <c.ca...@NOSPAMindigovision.com> wrote in message
news:96b5mk$6hk$1...@soap.pipex.net...

0 new messages