none
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 ?


    lyf4sci

    Thursday, October 9, 2014 5:57 PM

Answers

  • 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.

     -Brian


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

    Thursday, October 9, 2014 7:18 PM
    Moderator