InitializeListHead

This function initializes any doubly-linked, driver-managed interlocked queue or doubly-linked, driver-maintained list.

At a Glance

Header file: Ntcompat.h
Windows CE versions: 2.0 and later

Syntax

VOID InitializeListHead( IN PLIST_ENTRY ListHead );

Parameters

ListHead
Pointer to the driver-allocated storage for the head of the interlocked queue or list. For an interlocked queue, the storage must be resident and the driver must also provide storage for a spin lock.

Remarks

This function must be called from the DriverEntry function if a driver sets up internal interlocked queues for IRPs or manages internal linked lists.

The ListHead of type LIST_ENTRY is doubly linked. Entries in an interlocked queue can be queued and dequeued by calling the ExInterlockedInsertXXXList and ExInterlockedRemoveHeadList functions. Entries can be inserted into and removed from a driver-maintained list with InsertXXXList and RemoveXXXList.

For an interlocked queue, a driver must provide resident storage: 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 driver. The driver must also provide storage for a spin lock, which must be initialized with the KeInitializeSpinLock function before the driver’s initial call to the ExInterlockedXXX function with the spin lock.

For a driver-maintained list, the driver must synchronize access to the list so that it is impossible for any two routines to be inserting and/or removing entries from the list simultaneously in symmetric multiprocessing devices. Consequently, most drivers use the ExInterlockedXXX functions to manage the necessary synchronization, rather than setting up a driver-managed list, which is likely to require spin-lock protection anyway.

A driver that calls this function must be running at IRQL PASSIVE_LEVEL.