System and method for implementing scalable adaptive reader-writer locks
First Claim
1. A method, comprising:
- performing by a computer;
beginning execution of a multithreaded application that comprises one or more requests to acquire a reader-writer lock, wherein the reader-writer lock controls write access to a critical section of code by concurrently executing threads of the application and further controls access to the critical section of code in read-only mode, wherein the reader-writer lock allows at most one writer thread to hold the reader-writer lock for writing at a time, and wherein the reader-writer lock allows multiple reader threads to hold the reader-writer lock in read-only mode at the same time;
a given thread of the application requesting acquisition of the reader-writer lock;
determining that another thread has acquired the reader-writer lock;
determining one of a plurality of available actions to be taken in response to said requesting;
taking the determined action; and
the other thread releasing the reader-writer lock, wherein said releasing comprises waking one or more reader threads wishing to acquire the reader-writer lock that are in a sleep state and a single writer thread of a plurality of writer threads wishing to acquire the reader-writer lock that are in a sleep state.
1 Assignment
0 Petitions
Accused Products
Abstract
NUMA-aware reader-writer locks may leverage lock cohorting techniques and may support reader re-entrancy. They may implement a delayed sleep mechanism by which a thread that fails to acquire a lock spins briefly, hoping the lock will be released soon, before blocking on the lock (sleeping). The maximum spin time may be based on the time needed to put a thread to sleep and wake it up. If a lock holder is not executing on a processor, an acquiring thread may go to sleep without first spinning. Threads put in a sleep state may be placed on a turnstile sleep queue associated with the lock. When a writer thread that holds the lock exits a critical section protected by the lock, it may wake all sleeping reader threads and one sleeping writer thread. Reader threads may increment and decrement node-local reader counters upon arrival and departure, respectively.
44 Citations
20 Claims
-
1. A method, comprising:
performing by a computer; beginning execution of a multithreaded application that comprises one or more requests to acquire a reader-writer lock, wherein the reader-writer lock controls write access to a critical section of code by concurrently executing threads of the application and further controls access to the critical section of code in read-only mode, wherein the reader-writer lock allows at most one writer thread to hold the reader-writer lock for writing at a time, and wherein the reader-writer lock allows multiple reader threads to hold the reader-writer lock in read-only mode at the same time; a given thread of the application requesting acquisition of the reader-writer lock; determining that another thread has acquired the reader-writer lock; determining one of a plurality of available actions to be taken in response to said requesting; taking the determined action; and the other thread releasing the reader-writer lock, wherein said releasing comprises waking one or more reader threads wishing to acquire the reader-writer lock that are in a sleep state and a single writer thread of a plurality of writer threads wishing to acquire the reader-writer lock that are in a sleep state. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
-
18. A system, comprising:
-
a plurality of nodes, each of which comprises two or more processor cores that support multithreading and that share a local memory; a system memory coupled to the plurality of nodes; wherein the system memory stores program instructions that when executed on one or more processor cores in the plurality of nodes cause the one or more processor cores to perform; beginning execution of a multithreaded application that comprises one or more requests to acquire a reader-writer lock, wherein the reader-writer lock controls write access to a critical section of code by concurrently executing threads of the application and further controls access to the critical section of code in read-only mode, wherein the reader-writer lock allows at most one writer thread to hold the reader-writer lock for writing at a time, and wherein the reader-writer lock allows multiple reader threads to hold the reader-writer lock in read-only mode at the same time; a given thread of the application requesting acquisition of the reader-writer lock; determining that another thread has acquired the reader-writer lock; determining one of a plurality of available actions to be taken in response to said requesting; taking the determined action; and the other thread releasing the reader-writer lock, wherein said releasing comprises waking one or more reader threads wishing to acquire the reader-writer lock that are in a sleep state and a single writer thread of a plurality of writer threads wishing to acquire the reader-writer lock that are in a sleep state. - View Dependent Claims (19)
-
-
20. A non-transitory, computer-readable storage medium storing program instructions that when executed on one or more computers cause the one or more computers to perform:
-
beginning execution of a multithreaded application that comprises one or more requests to acquire a reader-writer lock, wherein the reader-writer lock controls write access to a critical section of code by concurrently executing threads of the application and further controls access to the critical section of code in read-only mode, wherein the reader-writer lock allows at most one writer thread to hold the reader-writer lock for writing at a time, and wherein the reader-writer lock allows multiple reader threads to hold the reader-writer lock in read-only mode at the same time; a given thread of the application requesting acquisition of the reader-writer lock; determining that another thread has acquired the reader-writer lock; determining one of a plurality of available actions to be taken in response to said requesting; taking the determined action; and the other thread releasing the reader-writer lock, wherein said releasing comprises waking one or more reader threads wishing to acquire the reader-writer lock that are in a sleep state and a single writer thread of a plurality of writer threads wishing to acquire the reader-writer lock that are in a sleep state.
-
Specification