NdisInterlockedInsertHeadList (NDIS 5.1) function
Note NDIS 5. x has been deprecated and is superseded by NDIS 6. x. For new NDIS driver development, see Network Drivers Starting with Windows Vista. For information about porting NDIS 5. x drivers to NDIS 6. x, see Porting NDIS 5.x Drivers to NDIS 6.0.
NdisInterlockedInsertHeadList inserts an entry, usually a packet, at the head of a doubly linked list so that access to the list is synchronized in a multiprocessor-safe way.
Syntax
PLIST_ENTRY NdisInterlockedInsertHeadList(
_In_ PLIST_ENTRY ListHead,
_In_ PLIST_ENTRY ListEntry,
_In_ PNDIS_SPIN_LOCK SpinLock
);
Parameters
ListHead [in]
Pointer to the head of the doubly linked list into which an entry is to be inserted.ListEntry [in]
Pointer to the entry to be inserted at the head of the list.SpinLock [in]
Pointer to a caller-supplied spin lock, used to synchronize access to the list.
Return value
NdisInterlockedInsertHeadList returns a pointer to the entry that was at the head of the queue before the given entry was inserted. If the queue was empty, it returns NULL.
Remarks
Before calling NdisInterlockedInsertHeadList, a driver must initialize the variable at ListHead with NdisInitializeListHead and the variable at SpinLock with NdisAllocateSpinLock. The driver also must provide resident storage for these variables and for its internal queue.
The caller-supplied spin lock prevents any other function from accessing the driver's internal queue while NdisInterlockedInsertHeadList is inserting the given entry, even when the driver is running on a multiprocessor machine.
NdisInterlockedInsertHeadList raises IRQL to DISPATCH_LEVEL when it acquires the given spin lock and restores the original IRQL before it returns control. Consequently, any driver function that calls NdisInterlockedInsertHeadList cannot be pageable code.
Most NDIS drivers process packets in FIFO order, so any driver that uses an interlocked queue tends to call NdisInterlockedInsertTailList far more frequently than NdisInterlockedInsertHeadList. Such a driver usually calls NdisInterlockedInsertHeadList only to requeue a packet for a retry operation.
To convert a returned value back to the address of the inserted entry, a driver can use the CONTAINING_RECORD macro.
Requirements
Target platform |
Universal |
Version |
|
Header |
Ndis.h (include Ndis.h) |
Library |
Ndis.lib |
IRQL |
<= DISPATCH_LEVEL |
See also