Key difference between read/write lock and the spinlock RRS feed

  • Question

  • Hi Experts,

    What is the key difference between read/write lock and the spin lock ?

    Where are they typically used ?


    Thursday, October 9, 2014 5:57 PM


  • The read/write lock (ERESOURCE) is a scheduler primitive, so it can be used by threads running at IRQL < 2. The ERESOURCE allows for many concurrent readers and a single writer, so it is useful for protecting a data structure that is read far more than it is written to. The ERESOURCE is used extensively throughout NTOSKRNL and especially file system drivers.

    The spinlock is much lighter weight, is not part of the scheduler, and typically is acquired at IRQL >= 2. The spinlock is used by NTOSKRNL and pretty much every driver, and is used to acquire exclusive access to a resource (data structure, or device registers) at a particular IRQL. The vast majority of spinlocks are acquired at IRQL 2.


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    • Marked as answer by Brian Catlin Thursday, October 9, 2014 7:18 PM
    Thursday, October 9, 2014 7:18 PM