Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

InterlockedPushEntrySList() vs ExInterlockedPushEntryList()

rstruempfrstruempf Member Posts: 103
edited May 14 in NTFSD

My understanding is that InterlockedPushEntrySList() and ExInterlockedPushEntryList() (or ExInterlockedPushEntrySList()) are both available to KM drivers, both atomically insert an item at the top of a singly linked list, but ExInterlockedPushEntryList() uses a spinlock, where InterlockedPushEntrySList() is non-blocking.

Is my understanding correct? If so, is there a reason I would choose a blocking version over a non-blocking one?

The docs.microsoft.com pages for the non-blocking API are aimed at user land usage, which doesn't fill me with confidence. E.g. The examples are clearly user mode code, and there are no IRQL specs at the bottom of the pages.

Comments

  • Scott_Noone_(OSR)Scott_Noone_(OSR) Administrator Posts: 3,142

    They've been the same implementation for quite a while (maybe XP?). For example, here how wdm.h defines them for the x64:

    #define ExInterlockedPushEntrySList(Head, Entry, Lock) \
        ExpInterlockedPushEntrySList(Head, Entry)
    ...
    #define InterlockedPushEntrySList(Head, Entry) \
        ExpInterlockedPushEntrySList(Head, Entry)
    

    -scott
    OSR

  • rstruempfrstruempf Member Posts: 103

    I understand, but what factors would lead to choosing one over the other? My understanding is that the non-blocking interlocked API functions are more efficient than those that use locking, especially the Ex... version here that must transition to DISPATCH_LEVEL IRQL in order to add or remove entries

  • Scott_Noone_(OSR)Scott_Noone_(OSR) Administrator Posts: 3,142

    ExInterlockedPushEntrySList doesn't use the lock.

    #define ExInterlockedPushEntrySList(Head, Entry, Lock) \
        ExpInterlockedPushEntrySList(Head, Entry)
    

    -scott
    OSR

  • rstruempfrstruempf Member Posts: 103

    @Scott_Noone_(OSR) said:
    ExInterlockedPushEntrySList doesn't use the lock.

    Doh! I didn't even look at what it was defined as. Sigh. Thanks for pointing that out.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Developing Minifilters 29 July 2019 OSR Seminar Space
Writing WDF Drivers 23 Sept 2019 OSR Seminar Space
Kernel Debugging 21 Oct 2019 OSR Seminar Space
Internals & Software Drivers 18 Nov 2019 Dulles, VA