Busy-wait time for threads
AssigneeHewlett-Packard Development Company, L.P.
InventorsRakesh Sasidharan Nair, Sherin Thyil George, Aswin Chandramouleeswaran
Life of this patent
Estimating the term…
Abstract
Method to selectively assign a reduced busy-wait time to threads is described. The method comprises determining whether at least one thread is spinning on a mutex lock associated with a condition variable and assigning, when the at least one thread is spinning on the mutex lock, a predetermined reduced busy-wait time for a subsequent thread spinning on the mutex lock.
Claims15
A method for controlling a busy-wait time assigned to a thread attempting to access a shared resource protected by a mutex lock associated with a condition variable, wherein a thread having acquired the mutex will access the shared resource when the state of the condition variable is favorable and will otherwise release the mutex and wait on the condition variable until the state becomes favorable, the method comprising:
- attempting to acquire the mutex by a first thread and determining the mutex is unavailable for acquisition by the first thread;
- and
- assigning one of a default busy-wait time and a reduced busy-wait time to the first thread in response to determining the mutex is unavailable, wherein the reduced busy-wait time is less than the default busy-wait time and greater than zero, the assigning comprising:
- assigning the default busy-wait time when there are no other threads waiting on the condition variable;
- and
- assigning the reduced busy-wait time when there is at least one other thread waiting on the condition variable.
A computer program thread control device comprising:
- a processor;
- a memory comprising computer-readable instructions which, when executed, cause the processor to control a busy-wait time assigned to a thread attempting to access a shared resource protected by a mutex lock associated with a condition variable, wherein a thread having acquired the mutex will access the shared resource when the state of the condition variable is favorable and will otherwise release the mutex and wait on the condition variable until the state becomes favorable, the processor to:
- attempt to acquire the mutex by a first thread and determine the mutex is unavailable for acquisition by the first thread;
- and
- assign one of a default busy-wait time and a reduced busy-wait time to the first thread in response to determining the mutex is unavailable, wherein the reduced busy-wait time is less than the default busy-wait time and greater than zero, the processor to:
- assign the default busy-wait time when there are no other threads waiting on the condition variable;
- and
- assign the reduced busy-wait time when there is at least one other thread waiting on the condition variable.
A non-transitory computer-readable storage medium (CRSM) having computer-executable instructions that when executed by a processor, causes the processor to control a busy-wait time assigned to a thread attempting to access a shared resource protected by a mutex lock associated with a condition variable, wherein a thread having acquired the mutex will access the shared resource when the state of the condition variable is favorable and will otherwise release the mutex and wait on the condition variable until the state becomes favorable, the instructions cause the processor to:
- attempt to acquire the mutex by a first thread and determine the mutex is unavailable for acquisition by the first thread;
- and
- assign one of a default busy-wait time and a reduced busy-wait time to the first thread in response to determining the mutex is unavailable, wherein the reduced busy-wait time is less than the default busy-wait time and greater than zero, the instructions cause the processor to:
- assign the default busy-wait time when there are no other threads waiting on the condition variable;
- and
- assign the reduced busy-wait time when there is at least one other thread waiting on the condition variable.
Dependencies are inferred from the claim text.