NdisInterlockedInsertTailList

PLIST_ENTRY
NdisInterlockedInsertTailList(

IN PLIST_ENTRY ListHead,
IN PLIST_ENTRY ListEntry,
IN PNDIS_SPIN_LOCK SpinLock
);

NdisInterlockedInsertTailList inserts an entry, usually a packet, at the tail of a doubly linked list so that access to the list is synchronized in a multiprocessor-safe way.

Parameters

ListHead

Points to the head of the doubly linked list into which an entry is to be inserted.

ListEntry

Points to the entry to be inserted at the end of the list.

SpinLock

Points to a caller-supplied spin lock, used to synchronize access to the list.

Return Value

NdisInterlockedInsertTailList returns a pointer to the entry that was at the tail of the queue before the given entry was inserted. If the queue was empty, it returns NULL.

Comments

Before calling NdisInterlockedInsertTailList, 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 NdisInterlockedInsertTailList is inserting the given entry, even when the driver is running on a multiprocessor machine.

NdisInterlockedInsertTailList 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 NdisInterlockedInsertTailList cannot be pageable code.

To convert a returned value back to the address of the inserted entry, a driver can use the CONTAINING_RECORD macro (see the Kernel-Mode Driver Reference).

Callers of NdisInterlockedInsertTailList run at IRQL <= DISPATCH_LEVEL.

See Also

NdisAllocateSpinLock, NdisInitializeListHead, NdisInterlockedInsertHeadList, NdisInterlockedRemoveHeadList