Queue-based spin lock with timeout
First Claim
Patent Images
1. A method of implementing a queue-based spin lock with timeout in a computing device running a plurality of threads, the method comprising:
- (a) providing a queue as a linked list of nodes, the nodes in the linked list representing threads waiting for the lock, the list being accessed through a tail pointer,(b) permitting a thread to acquire the lock when the thread reaches the head of the queue; and
(c) when a thread times out and abandons its attempt to acquire the lock, removing the node corresponding to the timed-out thread from the linked list, so that the nodes of the predecessor and the successor of the timed-out thread out become neighbors in the queue.
2 Assignments
0 Petitions
Accused Products
Abstract
A queue-based spin lock with timeout allows a thread to obtain contention-free mutual exclusion in fair, FIFO order, or to abandon its attempt and time out. A thread may handshake with other threads to reclaim its queue node immediately (in the absence of preemption), or mark its queue node to allow reclamation by a successor thread.
-
Citations
33 Claims
-
1. A method of implementing a queue-based spin lock with timeout in a computing device running a plurality of threads, the method comprising:
-
(a) providing a queue as a linked list of nodes, the nodes in the linked list representing threads waiting for the lock, the list being accessed through a tail pointer, (b) permitting a thread to acquire the lock when the thread reaches the head of the queue; and (c) when a thread times out and abandons its attempt to acquire the lock, removing the node corresponding to the timed-out thread from the linked list, so that the nodes of the predecessor and the successor of the timed-out thread out become neighbors in the queue. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
-
-
11. A method of implementing a queue-based spin lock with timeout in a computing device running a plurality of threads, the method comprising:
-
(a) providing a queue as a linked list of nodes, the nodes in the linked list representing threads waiting for the lock, the list being accessed through a tail pointer; (b) permitting a thread to acquire the lock when the thread reaches the head of the queue; (c) causing each thread to spin on a queue node allocated by its predecessor; and (d) indicating an unheld lock by a queue containing only one node, marked available, or by a queue containing zero nodes (e) causing a thread that releases the lock (by marking its queue node available), or that times out and marks its queue node abandoned, to perform a compare-and-swap operation on the queue tail pointer in an attempt to remove its node from the queue.
-
-
12. An article of manufacture for implementing a queue-based spin lock with timeout in a computing device running a plurality of threads, the article of manufacture comprising:
-
a storage medium readable by the computing device; and code, stored on the storage medium, for controlling the computing device to perform the following operational steps; (a) providing a queue as a linked list of nodes, the nodes in the linked list representing threads waiting for the lock, the list being accessed through a tail pointer, (b) permitting a thread to acquire the lock when the thread reaches the head of the queue; and (c) when a thread times out and abandons its attempt to acquire the lock, removing the node corresponding to the timed-out thread from the linked list, so that the nodes of the predecessor and the successor of the timed-out thread out become neighbors in the queue. - View Dependent Claims (13, 14, 15, 16, 17, 18, 19, 20, 21)
-
-
22. An article of manufacture for implementing a queue-based spin lock with timeout in a computing device running a plurality of threads, the article of manufacture comprising:
-
a storage medium readable by the computing device; and code, stored on the storage device, for controlling the computing device to perform the following operational steps; (a) providing a queue as a linked list of nodes, the nodes in the linked list representing threads waiting for the lock, the list being accessed through a tail pointer; (b) permitting a thread to acquire the lock when the thread reaches the head of the queue; (c) causing each thread to spin on a queue node allocated by its predecessor; and (d) indicating an unheld lock by a queue containing only one node, marked available, or by a queue containing zero nodes (e) causing a thread that releases the lock (by marking its queue node available), or that times out and marks its queue node abandoned, to perform a compare-and-swap operation on the queue tail pointer in an attempt to remove its node from the queue.
-
-
23. A computing device for implementing a queue-based spin lock with timeout while running a plurality of threads, the computing device comprising:
-
a memory; and a plurality of processors, in communication with the memory, for running the plurality of threads and for performing the following operational steps; (a) providing a queue as a linked list of nodes, the nodes in the linked list representing threads waiting for the lock, the list being accessed through a tail pointer, (b) permitting a thread to acquire the lock when the thread reaches the head of the queue; and (c) when a thread times out and abandons its attempt to acquire the lock, removing the node corresponding to the timed-out thread from the linked list, so that the nodes of the predecessor and the successor of the timed-out thread out become neighbors in the queue. - View Dependent Claims (24, 25, 26, 27, 28, 29, 30, 31, 32)
-
-
33. A computing device for implementing a queue-based spin lock with timeout while running a plurality of threads, the computing device comprising:
-
a memory; and a plurality of processors, in communication with the memory, for running the plurality of threads and for performing the following operational steps; (a) providing a queue as a linked list of nodes, the nodes in the linked list representing threads waiting for the lock, the list being accessed through a tail pointer; (b) permitting a thread to acquire the lock when the thread reaches the head of the queue; (c) causing each thread to spin on a queue node allocated by its predecessor; and (d) indicating an unheld lock by a queue containing only one node, marked available, or by a queue containing zero nodes (e) causing a thread that releases the lock (by marking its queue node available), or that times out and marks its queue node abandoned, to perform a compare-and-swap operation on the queue tail pointer in an attempt to remove its node from the queue.
-
Specification