Almost fair busy lock
First Claim
1. A method for managing exclusive control of a shareable resource, the method comprising:
- publishing a current state of a lock and a claim non atomically to the lock by a next owning thread in an ordered set of threads that have requested to own the lock, the claim comprising a structure capable of being read and written only in a single memory access;
determining by the next owning thread whether the next owning thread has been pre-empted;
determining by a subsequent owning thread whether the next owning thread has been preempted by comparing the current state of the lock with the claim,wherein the subsequent owning thread is scheduled to follow the next owning thread;
responsive to determining whether the next owning thread has been preempted, acquiring by the next owning thread the lock if the next owning thread has not been pre-empted;
responsive to determining whether the next owning thread has been preempted, retrying by the next owning thread acquisition of the lock if the next owning thread has been pre-empted; and
responsive to determining that the next owning thread has been pre-empted, acquiring by the subsequent owning thread the lock unfairly and atomically, consistently modifying the lock such that a next lock owner can determine that the next lock owner has been preempted.
1 Assignment
0 Petitions
Accused Products
Abstract
Managing exclusive control of a shareable resource includes publishing a claim non atomically to a lock by a thread that is next to own the lock in an ordered set of threads that have requested to own the lock. The claim includes a structure capable of being read and written only in a single memory access. A determination is made of whether the next owning thread has been pre-empted. Responsive to the determination, the next owning thread of the lock acquires the lock if the next owning thread has not been pre-empted and retries acquisition of the lock if the next owning thread has been pre-empted. Responsive to the next owning thread being pre-empted, a subsequent owning thread acquires the lock unfairly and atomically, consistently modifies the lock such that a next lock owner can determine that the next lock owner has been preempted.
-
Citations
15 Claims
-
1. A method for managing exclusive control of a shareable resource, the method comprising:
-
publishing a current state of a lock and a claim non atomically to the lock by a next owning thread in an ordered set of threads that have requested to own the lock, the claim comprising a structure capable of being read and written only in a single memory access; determining by the next owning thread whether the next owning thread has been pre-empted; determining by a subsequent owning thread whether the next owning thread has been preempted by comparing the current state of the lock with the claim, wherein the subsequent owning thread is scheduled to follow the next owning thread; responsive to determining whether the next owning thread has been preempted, acquiring by the next owning thread the lock if the next owning thread has not been pre-empted; responsive to determining whether the next owning thread has been preempted, retrying by the next owning thread acquisition of the lock if the next owning thread has been pre-empted; and responsive to determining that the next owning thread has been pre-empted, acquiring by the subsequent owning thread the lock unfairly and atomically, consistently modifying the lock such that a next lock owner can determine that the next lock owner has been preempted. - View Dependent Claims (2, 3, 4, 5)
-
-
6. A system for managing exclusive control of a shareable resource between a plurality of concurrently executing threads, comprising:
-
a lock for controlling access to the shareable resource, the lock maintaining an ordered set of threads requesting ownership of the lock; a claim structure, capable of being read and written only in a single memory access, non-atomically published by a next owning thread, in the ordered set of threads, making a claim to the lock; and one or more processors, one or more computer-readable memories, one or more computer-readable tangible storage devices, and program instructions stored on at least one of the one or more computer-readable storage devices for execution by at least one of the one or more processors via at least one of the one or more memories, wherein the system is capable of performing a method comprising after publishing a current state of the lock and the claim, determining by the next owning thread of the lock whether the next owning thread has been pre-empted, determining by a subsequent owning thread of the lock whether the next owning thread has been preempted by comparing the current state of the lock with the claim, wherein the subsequent owning thread is scheduled to follow the next owning thread, responsive to determining whether the next owning thread has been pre-empted, acquiring by the next owning thread the lock if the next owning thread has not been pre-empted, responsive to determining whether the next owning thread has been pre-empted, retrying acquisition of the lock if the next owning thread has been pre-empted, and responsive to determining that the next owning thread has been pre-empted, acquiring by the subsequent owning thread the lock unfairly and atomically, consistently modifying the lock such that a next lock owner can determine that the next lock owner has been preempted. - View Dependent Claims (7, 8, 9, 10)
-
-
11. A computer program product for managing exclusive control of a shareable resource, the computer program product comprising a computer-readable storage medium having program instructions embodied therewith, the program instructions executable by a processor to cause the processor to perform a method comprising:
-
publishing a current state of a lock and a claim non atomically to the lock by a next owing thread in an ordered set of threads that have requested to own the lock, the claim comprising a structure capable of being read and written only in a single memory access; determining by the next owning thread whether the next owning thread has been pre-empted; determining by a subsequent owning thread whether the next owning thread was preempted by comparing the current state of the lock with the claim, wherein the subsequent owning thread is scheduled to follow the next owning thread; responsive to determining whether the next owning thread has been preempted, acquiring by the next owning thread of the lock the lock if the next owning thread has not been pre-empted; responsive to determining whether the next owning thread has been preempted, retrying by the next owning thread acquisition of the lock if the next owning thread has been pre-empted; and responsive to determining that the next owning thread has been pre-empted, acquiring by the subsequent owning thread the lock unfairly and atomically, consistently modifying the lock such that a next lock owner can determine that the next lock owner has been preempted. - View Dependent Claims (12, 13, 14, 15)
-
Specification