Concurrency Control Using Slotted Read-Write Locks
First Claim
1. A computer-readable storage medium storing program instructions executable by one or more processors to implement:
- assigning a plurality of threads to respective slots of a data structure, 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 the data structure indicates whether any thread has a read lock for a shared memory area and whether any thread has a write lock for the shared memory area, 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 the thread'"'"'s assigned slot in the data structure for 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.
42 Citations
20 Claims
-
1. A computer-readable storage medium storing program instructions executable by one or more processors to implement:
-
assigning a plurality of threads to respective slots of a data structure, 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 the data structure indicates whether any thread has a read lock for a shared memory area and whether any thread has a write lock for the shared memory area, 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 the thread'"'"'s assigned slot in the data structure for 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 a plurality of threads to respective slots of a data structure, 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 the data structure indicates whether any thread has a read lock for a shared memory area and whether any thread has a write lock for the shared memory area, 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 the thread'"'"'s assigned slot in the data structure for 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.
-
-
13. The computer-implemented method of claim 13, further comprising:
- a thread not assigned to any of the slots of the data structure attempting to acquire the read lock for the shared memory area, wherein said attempting to acquire the read lock for the thread not assigned to any of the slots comprises the thread not assigned to any of the slots performing an atomic operation to increment a reader count field of the data structure, wherein the reader count field indicates whether one or more threads not assigned to one of the slots has the read lock.
- View Dependent Claims (12, 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 a plurality of threads to respective slots of a data structure, 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 the data structure indicates whether any thread has a read lock for a shared memory area and whether any thread has a write lock for the shared memory area, 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 the thread'"'"'s assigned slot in the data structure for 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