…and the same thing goes for NdisInterlocked*()

A few days ago I wrote about how to keep ExInterlocked*() operations interlocked. Well, the same thing goes for NDIS drivers.

NDIS documents a set of routines that look a whole lot like the ExInterlocked* routines:

#define NdisInterlockedInsertHeadList(...) \
    ExInterlockedInsertHeadList(...)

Unsurprisingly, the rule is the same: Once you use a given spin lock with any NdisInterlocked* function, it must always be used with an NdisInterlocked* function. If you missed the first article, you may want to re-read it for a more detailed explanation.

Not only is there no documentation of this on MSDN, but what documentation there is is wrong: it says that the functions raise to DISPATCH_LEVEL, but in reality, they raise to the highest IRQL in the system (at least when #define‘d to their ExInterlocked counterparts, which is whenever BINARY_COMPATIBLE is not defined).

The documentation also states that the NdisInterlocked* routines must be called from <= DISPATCH_LEVEL; this is probably wrong but I would encourage following the docs regardless unless/until Microsoft clarifies them.

Leave a Reply