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

WaitForSingleObject doesnt timeout

3 views
Skip to first unread message

Alan Previn

unread,
Nov 19, 2009, 6:35:02 PM11/19/09
to
Hi folks - i am doing a driver and have a couple of threads running in it -
one threas is to handle instruction dispatching to the hardware and a second
to handle interrupt capturing. One can guess the former does depend on the
latter via event handles (to signal an interrupt from the device that the
first thread checks HW to see if it can start dispatching the next one). So
the problem i have here is that in the cases where we have too many
interrupts coming around... it happens occasionally that the 1st thread's
WaitForSingleObject just dies. Never returns. I call this function with a
timeout of 3 miliseconds (its a very fast CPU, so 3 miliseconds is very
long). And when this function hangs, its stuck forever,... the rest of the
system is actually running - i can break into other threads and set
breakpoints and see them move. But within this WaitForSingleObject - i am not
sure what happened - it reaches until some lower level kernel function - but
when i try to set breakpoints there it gets triggered too frequently because
many other processes also invoke object inspection functions.

Anyone has any idea how i can overcome this problem?

Paul G. Tobey [ eMVP ]

unread,
Nov 20, 2009, 10:04:01 AM11/20/09
to
Are you sure that the thread isn't deadlocked? You know, waiting on an event
that can never be set because some other thread is waiting for the locked
thread to do something before it will set the event? That's what it sounds
like. If you set a time-out in the Wait, does the call always return? You
can write your code to just try again if there's a time-out (WAIT_TIMEOUT).
If so, that seems to confirm that you are deadlocked in some way or
another...

Paul T.

Alan Previn

unread,
Nov 25, 2009, 3:00:01 PM11/25/09
to
Hi Paul - sorry for the late reply. (actually i replied this already but i
forgot my IE crashed moments after pressing the "Post" button). Basically
we've always been using the timeout of 3 miliseconds. Also, we only have 1
thread that ever waits for the event and another thread that only sets it -
so 2 threads can never ever wait on that same handle.

any ideas?

AndrewScholan[MCTS]

unread,
Nov 26, 2009, 4:13:55 AM11/26/09
to
On Nov 25, 8:00 pm, Alan Previn <AlanPre...@discussions.microsoft.com>
wrote:
> > > Anyone has any idea how i can overcome this problem?- Hide quoted text -
>
> - Show quoted text -

Are you sure that there's not another higher priority thread in the
system that's hogging (i.e. it never gives up the run slot)? This can
easily happen if you have something that's doing polling without
calling Sleep() or SleepTilTick(). If this is the case then the Wait
will be timing out, become runnable but never getting to the run
state.
If you are in debug build you can see what the run state of the thread
is by looking in the thread window.
Andrew.

0 new messages