Previous Next

KeInitializeEvent

The KeInitializeEvent routine initializes an event object as a synchronization (single waiter) or notification type event and sets it to a signaled or not signaled state.

VOID 
  KeInitializeEvent(
    IN PRKEVENT  Event,
    IN EVENT_TYPE  Type,
    IN BOOLEAN  State
    );

Parameters

Event
Pointer to an event object, for which the caller provides the storage.
Type
Specifies the event type, either NotificationEvent or SynchronizationEvent.
State
Specifies the initial state of the event. TRUE indicates a signaled state.

Return Value

None

Headers

Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.

Comments

A caller cannot wait at raised IRQL for a nonzero interval on an event object or in a nonarbitrary thread context.

Storage for an event object must be resident: in the device extension of a driver-created device object, in the controller extension of a driver-created controller object, or in nonpaged pool allocated by the caller. If you allocate the event on the stack, you must specify a KernelMode wait when calling KeWaitForSingleObject, KeWaitForMutexObject, or KeWaitForMultipleObjects. During a KernelMode wait, the stack containing the event will not be paged out

Drivers typically use a NotificationEvent to wait for an I/O operation to complete. When a notification event is set to the signaled state, all threads that were waiting on the event become eligible for execution. The event remains in the signaled state until a thread calls KeResetEvent or KeClearEvent to set the event in the not-signaled state.

A SynchronizationEvent is also called an autoreset or autoclearing event. When such an event is set, a single waiting thread becomes eligible for execution. The Kernel automatically resets the event to the not-signaled state each time a wait is satisfied. A driver might use a synchronization event to protect a shared resource that is used in synchronizing the operations of several threads. Synchronization events are rarely used in a typical driver.

Callers of this routine can be running at any IRQL.

See Also

KeClearEvent, KeReadStateEvent, KeResetEvent, KeSetEvent, KeWaitForMultipleObjects, KeWaitForSingleObject