Hierarchical queue-based locks
First Claim
Patent Images
1. A method of managing queue-based locks, comprising:
- obtaining, within a first cluster of a system, a first thread comprising a critical section requiring a lock to access a shared resource of the system;
initializing, by the first thread executing on a processor in the first cluster, a first qnode representing the first thread in response to the critical section requiring the lock, wherein the first qnode is a data structure referenced by a first pointer of the first thread;
inserting, by the first thread and in response to the critical section requiring the lock, the first qnode into a local queue of the first cluster by setting a tail pointer of the local queue to reference the first qnode, wherein the first thread comprises a second pointer referencing a predecessor qnode of the first qnode;
determining, by the first thread and based on a first qnode in the predecessor qnode, the first qnode is at a head of the local queue;
splicing, by the first thread and in response to the first field being at the head of the local queue, the local queue into a global queue of the system for the shared resource,wherein splicing the local queue into the global queue comprises setting a tail pointer of the global queue to reference a tail qnode in the local queue;
determining, by the first thread and based on a second field in the predecessor qnode, the first qnode is at a head of the global qnode;
obtaining, by the first thread and in response to the first qnode being at the head of the global queue, the lock for the shared resource; and
executing the critical section of the first thread after obtaining the lock.
2 Assignments
0 Petitions
Accused Products
Abstract
In general, in one aspect, the invention relates to a method of establishing a queue-based lock including inserting a first qnode into a local queue, where the first qnode is associated with a first thread, splicing the local queue into the global queue, obtaining a lock for the first thread when the first qnode is at the head of the global queue, and executing a critical section of the first thread after obtaining the lock.
9 Citations
19 Claims
-
1. A method of managing queue-based locks, comprising:
-
obtaining, within a first cluster of a system, a first thread comprising a critical section requiring a lock to access a shared resource of the system; initializing, by the first thread executing on a processor in the first cluster, a first qnode representing the first thread in response to the critical section requiring the lock, wherein the first qnode is a data structure referenced by a first pointer of the first thread; inserting, by the first thread and in response to the critical section requiring the lock, the first qnode into a local queue of the first cluster by setting a tail pointer of the local queue to reference the first qnode, wherein the first thread comprises a second pointer referencing a predecessor qnode of the first qnode; determining, by the first thread and based on a first qnode in the predecessor qnode, the first qnode is at a head of the local queue; splicing, by the first thread and in response to the first field being at the head of the local queue, the local queue into a global queue of the system for the shared resource, wherein splicing the local queue into the global queue comprises setting a tail pointer of the global queue to reference a tail qnode in the local queue; determining, by the first thread and based on a second field in the predecessor qnode, the first qnode is at a head of the global qnode; obtaining, by the first thread and in response to the first qnode being at the head of the global queue, the lock for the shared resource; and executing the critical section of the first thread after obtaining the lock. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9)
-
-
10. A system for managing queue-based locks, comprising:
-
a shared resource; a first processor located in a first cluster of the system and configured to execute a first thread comprising a first critical section requiring a lock to access the shared resource; a second processor located in a second cluster of the system and configured to execute a second thread comprising a second critical section requiring the lock to access the shared resource; a first local queue located in the first cluster and configured to enqueue a first qnode representing the first thread, wherein the first qnode is a data structure referenced by a first pointer of the first thread; a second local queue located in the second cluster and configured to enqueue a second qnode representing the second thread; and a global queue corresponding to the shared resource and configured to enqueue the first qnode after the first local queue is spliced with the global queue and enqueue the second qnode after the second local queue is spliced with the global queue, wherein the first thread obtains the lock and executes the first critical section after the first qnode is identified by the first thread as a head of the global queue, and wherein the second thread obtains the lock and executes the second critical section after the second qnode is identified by the second thread as the head of the global queue. - View Dependent Claims (11, 12, 13)
-
-
14. A computer readable medium storing instructions for managing queue-based locks, the instructions when executed by a processor, comprising functionality to:
-
identify, within a first cluster of a system, a first thread comprising a critical section requiring a lock to access a shared resource of the system; initialize a first qnode representing the first thread in response to the critical section requiring the lock, wherein the first qnode is a data structure referenced by a first pointer of the first thread; insert, in response to the critical section requiring the lock, the first qnode into a local queue of the first cluster by setting a tail pointer of the local queue to reference the first qnode, wherein the first thread comprises a second pointer referencing a predecessor qnode of the first qnode; determine, based on a first field in the predecessor qnode, the first qnode is at a head of the local queue; splice, in response to the first qnode being at the head of the local queue, the local queue into a global queue of the system for the shared resource, wherein splicing the local queue into the global queue comprises setting a tail pointer of the global queue to reference a tail qnode in the local queue; determine, based on a second field in the predecessor qnode, the first qnode is at a head of the global qnode; obtain, in response to the first qnode being at the head of the global queue, the lock on the shared resource for the first thread; and execute the critical section of the first thread after obtaining the lock. - View Dependent Claims (15, 16, 17, 18, 19)
-
Specification