Efficient ticket lock synchronization implementation using early wakeup in the presence of oversubscription
First Claim
Patent Images
1. A method comprising:
- obtaining a ticket value for a first thread among a plurality of threads from a monotonically increasing ticket counter;
selecting a first memory location based on the ticket value and the number of memory locations in a distributed polling data structure;
computing a difference between the ticket value and a value from the first memory location, wherein the difference represents a number of other threads among the plurality of threads waiting for access to a shared single-access resource in contention among the plurality of threads which is controlled by a processor;
yielding a remaining portion of a time slice on the processor which is allocated to the first thread, to one of the other threads, when the difference exceeds a threshold value;
polling the first memory location without yielding the remaining portion of the time slice on the processor, until the first memory location contains a value equal to the ticket value when the difference does not exceed the threshold value, wherein the ticket value is stored in a second memory location, and wherein the first memory location and the second memory location are n bytes apart, where n is equal to or exceeds a size of a cache line of the processor;
acquiring the shared single-access resource for the first thread when the value of the first memory location is equal the thread'"'"'s ticket value;
releasing the shared single-access resource when the first thread has completed access;
updating a memory location being polled by a next thread that will be woken up to switch from yield-waiting to busy-waiting; and
updating a memory location being polled by a next thread that is currently busy-waiting.
1 Assignment
0 Petitions
Accused Products
Abstract
A turn-oriented thread and/or process synchronization facility obtains a ticket value from a monotonically increasing ticket counter and waits until a memory location contains a value equal to the ticket value, yielding the processor between polls of the memory location only if a difference between the ticket value and the contents of the memory location exceeds a threshold value. Machine-readable media containing instructions to implement similar methods, and systems that can use the methods, are also described and claimed.
-
Citations
11 Claims
-
1. A method comprising:
-
obtaining a ticket value for a first thread among a plurality of threads from a monotonically increasing ticket counter; selecting a first memory location based on the ticket value and the number of memory locations in a distributed polling data structure; computing a difference between the ticket value and a value from the first memory location, wherein the difference represents a number of other threads among the plurality of threads waiting for access to a shared single-access resource in contention among the plurality of threads which is controlled by a processor; yielding a remaining portion of a time slice on the processor which is allocated to the first thread, to one of the other threads, when the difference exceeds a threshold value; polling the first memory location without yielding the remaining portion of the time slice on the processor, until the first memory location contains a value equal to the ticket value when the difference does not exceed the threshold value, wherein the ticket value is stored in a second memory location, and wherein the first memory location and the second memory location are n bytes apart, where n is equal to or exceeds a size of a cache line of the processor; acquiring the shared single-access resource for the first thread when the value of the first memory location is equal the thread'"'"'s ticket value; releasing the shared single-access resource when the first thread has completed access; updating a memory location being polled by a next thread that will be woken up to switch from yield-waiting to busy-waiting; and updating a memory location being polled by a next thread that is currently busy-waiting. - View Dependent Claims (2, 3, 4, 5, 6)
-
-
7. A non-transitory computer-readable medium containing instructions to cause a programmable processor to perform operations comprising:
-
obtaining a ticket value for a first thread among a plurality of threads from a monotonically increasing ticket counter; selecting a first memory location based on the ticket value and the number of memory locations in a distributed polling data structure; computing a difference between the ticket value and a value from the first memory location, wherein the difference represents a number of other threads among the plurality of threads waiting for access to a shared single-access resource in contention among the plurality of threads which is controlled by the programmable processor; yielding a remaining portion of a time slice on the programmable processor which is allocated to the first thread, to one of the other threads, when the difference exceeds a threshold value; polling the first memory location without yielding the remaining portion of the time slice on the programmable processor, until the first memory location contains a value equal to the ticket value when the difference does not exceed the threshold value, wherein the ticket value is stored in a second memory location, and wherein the first memory location and the second memory location are n bytes apart, where n is equal to or exceeds a size of a cache line of the programmable processor; acquiring the shared single-access resource for the first thread when the value of the first memory location is equal the thread'"'"'s ticket value; releasing the shared single-access resource when the first thread has completed access; updating a memory location being polled by a next thread that will be woken up to switch from yield-waiting to busy-waiting; and updating a memory location being polled by a next thread that is currently busy-waiting. - View Dependent Claims (8, 9, 10, 11)
-
Specification