Systems and methods for interrupting latency optimized two-phase spinlock
AssigneeWind River Systems, Inc.
InventorsKenneth Jonsson, Markus Carlstedt
Life of this patent
Estimating the term…
Abstract
Described is a two-phase spinlock that controls access to a resource from a plurality of threads. The two-phase spinlock receives requests from threads to acquire the resource, places the threads in a first queue associated with a first phase of the two-phase spinlock, determines whether at least one of a predetermined number of slots in a second phase of the two-phase spinlock is available and when the slots are unavailable, processes an interrupt served by a select one of the threads based on a number of attempts by the selected thread to enter the second phase.
Claims18
A method, comprising:
- at a two-phase spinlock that controls access to a resource from a plurality of threads:
- receiving requests from threads to acquire the resource;
- placing the threads in a first queue associated with a first phase of the two-phase spinlock, wherein the placing the threads in the first queue is based on an atomic fetch-and-add operation;
- determining whether at least one of a predetermined number of slots in a second phase of the two-phase spinlock is available;
- and
- when the slots are unavailable, processing an interrupt served by a select one of the threads based on a number of attempts by the selected thread to enter the second phase.
A method, comprising:
- at a two-phase spinlock that controls access to a resource from a plurality of threads, the two-phase spinlock including a first phase including a plurality of first threads:
- determining whether a lock to access the resource is available;
- when the lock is available, selecting from a plurality of second threads in a second phase of the two-phase spinlock to acquire the lock;
- determining an age of the selected second thread;
- when the age is not the oldest among the second threads in the second phase, preventing any of the first threads from entering the second phase;
- and
- when the age is the oldest among the second threads in the second phase, selecting an oldest first thread among the first threads to enter the second phase.
A method, comprising:
- at a two-phase spinlock that controls access to a resource from a plurality of threads:
- receiving requests from threads to acquire the resource;
- placing the threads in a first queue as first threads associated with a first phase of the two-phase spinlock;
- determining whether at least one of a predetermined number of slots in a second phase of the two-phase spinlock is available;
- when the slots are unavailable, processing an interrupt served by one of the first threads associated with the first phase based on a number of attempts by the one of the first threads to enter the second phase;
- when the at least one of the slots is available, selecting one of the first threads to enter the second phase;
- determining whether a lock to access the resource is available;
- when the lock is available, selecting from a plurality of second threads in the second phase to acquire the lock;
- determining an age of the selected second thread;
- when the age is not the oldest among the second threads in the second phase, preventing any of the first threads from entering the second phase;
- and
- when the age is the oldest among the second threads in the second phase, selecting an oldest first thread among the first threads to enter the second phase.
Dependencies are inferred from the claim text.