Reader-writer lock
First Claim
Patent Images
1. A computer-implemented method for processing a set of access requests of a resource shared by a set of threads, the method comprising:
- creating a set of pools for storing the set of access requests of the resource, the set of pools including a first pool configured to be active and a second pool configured to be inactive;
processing a first request of a first type of the set of access requests of the first pool, wherein processing a first request of a first type further comprises;
counting with a first counter, using an atomic process to increment the first counter in response to a first bit of the first counter being enabled, a number of read locks held in the first pool, wherein the first bit is initially set to be enabled;
counting with a second counter, using the atomic process to increment the second counter in response to a second bit of the second counter being enabled, a number of outstanding read lock requests in the first pool, wherein the second bit is initially set to be disabled; and
indicating with a flag either the first counter or the second counter but not both, configured to discern the first counter from the second counter, wherein the flag is initially set to identify the first counter; and
switching, in response to processing a second request of a second type of the set of access requests of the first pool, the first pool to be the second pool configured to be inactive and the second pool to be the first pool configured to be active.
1 Assignment
0 Petitions
Accused Products
Abstract
A method and system for implementing a reader-writer lock having a write lock requested by a thread is disclosed. The reader-writer lock is structured to have counters and a flag. The counters use an atomic process to count read locks held or outstanding read lock requests. The flag identifies a counter and is configured to distinguish between counters. A read lock is prepared, acquired, and released. The atomic process is used and the flag or flagged counter is polled. A write lock is prepared, acquired, and released.
-
Citations
18 Claims
-
1. A computer-implemented method for processing a set of access requests of a resource shared by a set of threads, the method comprising:
-
creating a set of pools for storing the set of access requests of the resource, the set of pools including a first pool configured to be active and a second pool configured to be inactive; processing a first request of a first type of the set of access requests of the first pool, wherein processing a first request of a first type further comprises; counting with a first counter, using an atomic process to increment the first counter in response to a first bit of the first counter being enabled, a number of read locks held in the first pool, wherein the first bit is initially set to be enabled; counting with a second counter, using the atomic process to increment the second counter in response to a second bit of the second counter being enabled, a number of outstanding read lock requests in the first pool, wherein the second bit is initially set to be disabled; and indicating with a flag either the first counter or the second counter but not both, configured to discern the first counter from the second counter, wherein the flag is initially set to identify the first counter; and switching, in response to processing a second request of a second type of the set of access requests of the first pool, the first pool to be the second pool configured to be inactive and the second pool to be the first pool configured to be active. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 16, 17, 18)
-
-
9. A system processing a set of access requests of a resource shared by a set of threads, the system comprising:
-
a reader-writer lock configured to; provide a set of pools for storing data access requests; assign a first pool of the set of pools to a first pool position; assign a second pool of the set of pools to a second pool position; wait for data access requests to access data by performing the following steps; storing received read requests to the pool in the first position until a write request acquires a first ticket of a ticket lock and spins until a first turn associated with the pool in the first position, and subsequently storing received read requests to the pool in the second position until a write request acquires a second ticket of the ticket lock and spins until a second turn associated with the pool in the second position, atomically process the stored data access requests in the pool in the first pool position; and exchange the first and second pool positions of the pools in response to processing each respective read request and each respective write request of the pool in the first pool position; wherein the reader-writer lock comprises; a first counter configured to count, using an atomic process to increment the first counter in response to a first bit of the first counter being enabled, a number of read locks held, wherein the first bit is initially set to be enabled; a second counter configured to count, using the atomic process to increment the second counter in response to a second bit of the second counter being enabled, a number of outstanding read lock requests, wherein the second bit is initially set to be disabled; and a flag, identifying either the first counter or the second counter but not both, configured to discern the first counter from the second counter, wherein the flag is initially set to identify the first counter. - View Dependent Claims (10, 11, 12, 13, 14, 15)
-
Specification