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

Does KeInitializeEvent clear event status like KeClear/ResetEvent?

43 views
Skip to first unread message

gekkon

unread,
Jul 21, 2009, 5:24:02 PM7/21/09
to
Hi, I have a NotificationEvent which is signaled by KeSetEvent before another
thread calls KeWaitForSingleObject. Several lines after KeSetEvent is a call
to KeInitializeEvent. Will the signaled event be cleared by KeInitializeEvent
before the other thread start waiting on this event? Many thanks in advance!

Gianluca Varenni

unread,
Jul 21, 2009, 5:35:57 PM7/21/09
to
Why are you initializing the event after signalling it? Events should be
initialized before using them.

Have a nice day
GV


"gekkon" <gek...@discussions.microsoft.com> wrote in message
news:13DFBA25-579B-4A4D...@microsoft.com...

gekkon

unread,
Jul 21, 2009, 5:45:01 PM7/21/09
to
That's existing old code unfortunately.

Gianluca Varenni

unread,
Jul 21, 2009, 5:49:32 PM7/21/09
to
I would try to fix the code and initialize the event before using it. In any
case KeInitializeEvent has a parameter that specifies if the initialized
event should be signalled or not.

Have a nice day
GV


"gekkon" <gek...@discussions.microsoft.com> wrote in message

news:877150F9-0B2B-4441...@microsoft.com...

Pavel A.

unread,
Jul 21, 2009, 5:50:06 PM7/21/09
to
"gekkon" <gek...@discussions.microsoft.com> wrote in message
news:877150F9-0B2B-4441...@microsoft.com...

> That's existing old code unfortunately.

Then you've found a bug that can result in undefined behaviour or failure.
Fix it ASAP.

--pa

gekkon

unread,
Jul 21, 2009, 6:00:01 PM7/21/09
to
Yes, that's an option. I'm also interested in knowing the behavior of
KeInitializeEvent in this case. Since MSDN only mentions that
KeClear/ResetEvent will clear the signal state, I'm wondering what would
KeInitializeEvent do, maybe undefined?

Thanks.

gekkon

unread,
Jul 21, 2009, 6:33:01 PM7/21/09
to
Thanks.

Ben Voigt [C++ MVP]

unread,
Jul 21, 2009, 7:55:49 PM7/21/09
to
It will construct a brand new event in the buffer you provided. The event
will be signaled or not according to the documented parameters of
KeInitializeEvent.

Any threads that were using the previous event instance are now going to
behave very badly. The set/reset/clear operations are guaranteed to be
atomic and well behaved with respect to other users, initialize is not.

"gekkon" <gek...@discussions.microsoft.com> wrote in message

news:86E402BD-9020-4E97...@microsoft.com...

Volodymyr Shcherbyna

unread,
Jul 22, 2009, 10:27:23 AM7/22/09
to
"gekkon" <gek...@discussions.microsoft.com> wrote in message
news:13DFBA25-579B-4A4D...@microsoft.com...

If I recall correctly, the waiting threads will KeBugCheck if you will run
your code under verifier ...

--
Volodymyr M. Shcherbyna, blog: http://www.shcherbyna.com/
(This posting is provided "AS IS" with no warranties, and confers no
rights)


Doron Holan [MSFT]

unread,
Jul 22, 2009, 1:51:18 PM7/22/09
to
KeInitializeEvent will clear the list of all waiting threads. it should
only be called once on a given buffer, you have a bug. you need to fix it.
only call this API once

d

--

This posting is provided "AS IS" with no warranties, and confers no rights.


"gekkon" <gek...@discussions.microsoft.com> wrote in message
news:13DFBA25-579B-4A4D...@microsoft.com...

0 new messages