ExInitializeWorkItem routine

ExInitializeWorkItem initializes a work-queue item with a caller-supplied context and callback routine to be queued for execution when a system worker thread is given control.

Note  Use this routine with extreme caution. (See the following Remarks section.)

Syntax


VOID ExInitializeWorkItem(
  _In_  PWORK_QUEUE_ITEM Item,
  _In_  PWORKER_THREAD_ROUTINE Routine,
  _In_  PVOID Context
);

Parameters

Item [in]

Pointer to a caller-allocated WORK_QUEUE_ITEM structure to be initialized. This structure must be allocated from nonpaged pool. The callback routine specified in the Routine parameter is responsible for freeing this work item when it is no longer needed by calling ExFreePool or ExFreePoolWithTag.

Routine [in]

Pointer to a caller-defined routine that will be called to process the work item. This routine will be called in the context of a system thread at IRQL PASSIVE_LEVEL. This routine is declared as follows:


VOID
(*PWORKER_THREAD_ROUTINE)(
    IN PVOID Parameter
    );

Parameter

Context information pointer that was passed in the Context parameter.

Context [in]

Pointer to caller-supplied context information to be passed to the callback routine specified in the Routine parameter.

Return value

None

Remarks

ExInitializeWorkItem initializes the work item with the specified callback routine and context pointer and NULL list pointers.

To add the work item to a system work queue, call ExQueueWorkItem.

Work items are a limited resource, and drivers should only allocate them as needed. For example, do not allocate a work item in DriverEntry for the driver's dedicated use.

ExInitializeWorkItem and ExQueueWorkItem can only be used in cases where the specified work item is not associated with any device object or device stack. In all other cases, drivers should use IoAllocateWorkItem , IoFreeWorkItem , and IoQueueWorkItem, because only these routines ensure that the device object associated with the specified work item remains available until the work item has been processed.

Requirements

Header

Wdm.h (include FltKernnel.h, Ntifs.h, Ntddk.h, or Wdm.h)

IRQL

Any level

See also

ExFreePool
ExFreePoolWithTag
ExQueueWorkItem
IoAllocateWorkItem
IoFreeWorkItem
IoQueueWorkItem
WORK_QUEUE_ITEM

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft