A.2.3.12 Interlocked Functions

The NDIS interface library uses certain functions to process interlocked requests as Table A.2.15 shows. Operation for these functions is the same as acquiring a spin lock, performing a request, and then releasing the lock. However, internal implementation is efficient and may not involve acquiring an actual spin lock. Interlocked functions use executive spin locks; therefore an NDIS 3.0 driver cannot call them if it is running above IRQL DISPATCH_LEVEL.

The driver synchronizes code that calls interlocked functions with other operations that explicitly use spin locks. In other words, it can modify a variable using NdisInterlockedAddUlong in one place, and modify the same variable inside a spin lock acquisition in another place, without the possibility that the two threads will run simultaneously.

Table A.2.15 Interlocked Functions

Function

Definition

NdisInterlockedAddUlong

Adds an increment to a value that a spin lock protects.

NdisInterlockedInsertHeadList

Inserts a structure at the head of a linked list that a spin lock protects.

NdisInterlockedInsertTailList

Inserts a structure at the tail of a linked list that a spin lock protects.

NdisInterlockedRemoveHeadList

Removes a structure from the head of a linked list that a spin lock protects.