×

Efficient ticket lock synchronization implementation using early wakeup in the presence of oversubscription

  • US 8,434,082 B2
  • Filed: 06/22/2006
  • Issued: 04/30/2013
  • Est. Priority Date: 06/22/2006
  • Status: Active Grant
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.

View all claims
  • 1 Assignment
Timeline View
Assignment View
    ×
    ×