Concurrency control using slotted read-write locks
First Claim
1. A non-transitory computer-readable storage medium storing program instructions executable by one or more processors to implement:
- assigning each one of a plurality of threads to a respective one of a plurality of slots of a data structure, wherein the data structure comprises a pre-determined number of slots, each of which is individually addressable by the plurality of threads using a respective slot index, wherein each one of the plurality of threads is assigned to a different slot in the data structure such that at most only a single thread is assigned to any given one of the slots, wherein each of the respective slots in the data structure indicates whether the thread assigned to the slot has a read lock for a shared memory area, wherein the data structure further indicates whether any thread has a write lock for the shared memory area, and wherein multiple threads can concurrently have the read lock but only one thread can have the write lock at any given time; and
one of the plurality of threads attempting to acquire the read lock for the shared memory area, wherein said attempting to acquire the read lock comprises;
performing a store operation to set a field associated with the read lock in the thread'"'"'s assigned slot in the data structure to a value indicating acquisition of the read lock; and
performing a load operation from the data structure to determine whether any thread has the write lock for the shared memory area, wherein the thread acquires the read lock for the shared memory area if no other thread has the write lock for the shared memory area.
2 Assignments
0 Petitions
Accused Products
Abstract
A system and method for concurrency control may use slotted read-write locks. A slotted read-write lock is a lock data structure associated with a shared memory area, wherein the slotted read-write lock indicates whether any thread has a read-lock and/or a write-lock for the shared memory area. Multiple threads may concurrently have the read-lock but only one thread can have the write-lock at any given time. The slotted read-write lock comprises multiple slots, each associated with a single thread. To acquire the slotted read-write lock for reading, a thread assigned to a slot performs a store operation to the slot and then attempts to determine that no other thread holds the slotted read-write lock for writing. To acquire the slotted read-write lock for writing, a thread assigned to a slot sets its write-bit and then attempts to determine that the write-lock is not held.
15 Citations
20 Claims
-
1. A non-transitory computer-readable storage medium storing program instructions executable by one or more processors to implement:
-
assigning each one of a plurality of threads to a respective one of a plurality of slots of a data structure, wherein the data structure comprises a pre-determined number of slots, each of which is individually addressable by the plurality of threads using a respective slot index, wherein each one of the plurality of threads is assigned to a different slot in the data structure such that at most only a single thread is assigned to any given one of the slots, wherein each of the respective slots in the data structure indicates whether the thread assigned to the slot has a read lock for a shared memory area, wherein the data structure further indicates whether any thread has a write lock for the shared memory area, and wherein multiple threads can concurrently have the read lock but only one thread can have the write lock at any given time; and one of the plurality of threads attempting to acquire the read lock for the shared memory area, wherein said attempting to acquire the read lock comprises; performing a store operation to set a field associated with the read lock in the thread'"'"'s assigned slot in the data structure to a value indicating acquisition of the read lock; and performing a load operation from the data structure to determine whether any thread has the write lock for the shared memory area, wherein the thread acquires the read lock for the shared memory area if no other thread has the write lock for the shared memory area. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
-
-
11. A computer-implemented method comprising:
-
assigning each one of a plurality of threads to a respective one of a plurality of slots of a data structure, wherein the data structure comprises a pre-determined number of slots, each of which is individually addressable by the plurality of threads using a respective slot index, wherein each one of the plurality of threads is assigned a different slot in the data structure such that at most only a single thread is assigned to any given one of the slots, wherein each of the respective slots in the data structure indicates whether the thread assigned to the slot has a read lock for a shared memory area, wherein the data structure further indicates whether any thread has a write lock for the shared memory area, and wherein multiple threads can concurrently have the read lock but only one thread can have the write lock at any given time; and one of the plurality of threads attempting to acquire the read lock for the shared memory area, wherein said attempting to acquire the read lock comprises; performing a store operation to set a field associated with the read lock in the thread'"'"'s assigned slot in the data structure to a value indicating acquisition of the read lock; and performing a load operation from the data structure to determine whether any thread has the write lock for the shared memory area, wherein the thread acquires the read lock for the shared memory area if no other thread has the write lock for the shared memory area. - View Dependent Claims (12, 13, 14, 15, 16)
-
-
17. A system, comprising:
-
one or more processors; a memory coupled to the one or more processors and storing program instructions executable by the one or more processors to implement; assigning each one of a plurality of threads to a respective one of a plurality of slots of a data structure, wherein the data structure comprises a pre-determined number of slots, each of which is individually addressable by the plurality of threads using a respective slot index, wherein each one of the plurality of threads is assigned a different slot in the data structure such that at most only a single thread is assigned to any given one of the slots, wherein each of the respective slots in the data structure indicates whether the thread assigned to the slot has a read lock for a shared memory area, wherein the data structure further indicates whether any thread has a write lock for the shared memory area, and wherein multiple threads can concurrently have the read lock but only one thread can have the write lock at any given time; and one of the plurality of threads attempting to acquire the read lock for the shared memory area, wherein said attempting to acquire the read lock comprises; performing a store operation to set a field associated with the read lock in the thread'"'"'s assigned slot in the data structure to a value indicating acquisition of the read lock; and performing a load operation from the data structure to determine whether any thread has the write lock for the shared memory area, wherein the thread acquires the read lock for the shared memory area if no other thread has the write lock for the shared memory area. - View Dependent Claims (18, 19, 20)
-
Specification