Patent ID: 7945912

Claim:
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.