Adaptive spin-then-block mutual exclusion in multi-threaded processing
First Claim
1. A computer-implemented method of acquiring ownership of a shared resource in a multi-threaded computing environment, comprising:
- measuring the duration of a context switching operation within the computing environment, including in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated;
in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and
in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation;
executing a spin procedure as part of an attempt by a first thread to acquire ownership of the shared resource, the spin procedure terminating upon the earlier of (i) successfully obtaining ownership of the shared resource, and (ii) reaching predetermined execution time limit equal to the measured duration of a context switching operation; and
if the spin procedure terminates by reaching the predetermined execution time limit, then executing a blocking procedure which temporarily suspends execution of the first thread.
2 Assignments
0 Petitions
Accused Products
Abstract
Adaptive modifications of spinning and blocking behavior in spin-then-block mutual exclusion include limiting spinning time to no more than the duration of a context switch. Also, the frequency of spinning versus blocking is limited to a desired amount based on the success rate of recent spin attempts. As an alternative, spinning is bypassed if spinning is unlikely to be successful because the owner is not progressing toward releasing the shared resource, as might occur if the owner is blocked or spinning itself. In another aspect, the duration of spinning is generally limited, but longer spinning is permitted if no other threads are ready to utilize the processor. In another aspect, if the owner of a shared resource is ready to be executed, a thread attempting to acquire ownership performs a “directed yield” of the remainder of its processing quantum to the other thread, and execution of the acquiring thread is suspended.
167 Citations
25 Claims
-
1. A computer-implemented method of acquiring ownership of a shared resource in a multi-threaded computing environment, comprising:
-
measuring the duration of a context switching operation within the computing environment, including in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation; executing a spin procedure as part of an attempt by a first thread to acquire ownership of the shared resource, the spin procedure terminating upon the earlier of (i) successfully obtaining ownership of the shared resource, and (ii) reaching predetermined execution time limit equal to the measured duration of a context switching operation; and if the spin procedure terminates by reaching the predetermined execution time limit, then executing a blocking procedure which temporarily suspends execution of the first thread. - View Dependent Claims (2, 3, 4, 5, 6)
-
-
7. A computer-implemented method by which a first thread acquires ownership of a shared resource currently owned by another thread in a multi-threaded computing environment, comprising:
-
determining, as part of an attempt by the first thread to acquire ownership of the shared resource, whether an execution status of the another thread indicates that the another thread is not progressing toward releasing its ownership of the shared resource; if the execution status of the another thread indicates that the another thread is not progressing toward releasing its ownership of the shared resource, then executing a blocking procedure which temporarily suspends execution of the first thread; if the execution status of the another thread does not indicate that the another thread is not progressing toward releasing its ownership of the shared resource, then executing a spin procedure during which the first thread repeatedly determines whether the shared resource is still owned by the another thread, the spin procedure terminating upon the earlier of (i) determining that the shared resource is not owned by another thread, and (ii) reaching a predetermined execution time limit; and measuring the duration of a context switching operation within the computing environment, wherein the predetermined execution time limit is made equal to the measured duration of the context switching operation, including, in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation. - View Dependent Claims (8, 9, 10)
-
-
11. A computer-implemented method by which a first thread acquires ownership of a shared resource currently owned by another thread in a multi-threaded computing environment, comprising:
-
in connection with the execution of a spin procedure by which the first thread attempts to acquire ownership of the shared resource, determining whether respective execution statuses of other threads indicate that any of the other threads is ready to be executed; if the respective execution statuses of the other threads indicate that any of the other threads is ready to be executed, then limiting the duration of the spin procedure to a predetermined execution time limit before executing a blocking procedure which temporarily suspends execution of the first thread; and
if the respective execution statuses of the other threads indicate that none of the other threads is ready to be executed, then permitting the spin procedure to execute beyond the predetermined execution time limit; andmeasuring a duration of a context switching operation within the computing environment, including, in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation, and wherein the predetermined execution time limit is made equal to the measured duration of a context switching operation.
-
-
12. A computer-implemented method by which a first preemptible thread acquires ownership of a shared resource currently owned by another preemptible thread in a multi-threaded computing environment, comprising:
-
in connection with the execution of a spin-then-block procedure by which the first preemptible thread attempts to acquire ownership of the shared resource, determining whether an execution status of the another preemptible thread indicates that the another preemptible thread is ready to be executed; if the execution status of the another preemptible thread indicates that the another preemptible thread is ready to be executed, then (i) yielding the remainder of a processing quantum for the first thread to the another preemptible thread, and (ii) suspending execution of the first preemptible thread; and
if the execution status of the another preemptible thread indicates that the another preemptible thread is not ready to be executed, then continuing the execution of the spin-then-block procedure by the first preemptible thread; andmeasuring a duration of a context switching operation within the computing environment, including, in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation, and wherein the spin-then-block procedure has a spinning portion employing a predetermined execution time limit equal to the measured duration of the context switching operation. - View Dependent Claims (13)
-
-
14. A computerized system, comprising:
-
a shared resource; and control circuitry including a set of one or more processors operative to execute a mutual exclusion mechanism, the mutual exclusion mechanism including a computer-implemented method of acquiring ownership of the shared resource, the method including; measuring a duration of a context switching operation within the computing environment, including, in a first measuring thread marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation; executing a spin procedure as part of an attempt by a first thread to acquire ownership of the shared resource, the spin procedure terminating upon the earlier of (i) successfully obtaining ownership of the shared resource, and (ii) reaching a predetermined execution time limit equal to the measured duration of a context switching operation; and
if the spin procedure terminates by reaching the predetermined execution time limit, then executing a blocking procedure which temporarily suspends execution of the first thread.
-
-
15. A computerized system, comprising:
-
a shared resource; and control circuitry including a set of one or more processors operative to execute a mutual exclusion mechanism in a multi-threaded computing environment, the mutual exclusion mechanism including a computer implemented method by which a first thread acquires ownership of the shared resource, the shared resource being currently owned by another thread, the method including; determining, as part of an attempt by the first thread to acquire ownership of the shared resource, whether an execution status of the another thread indicates that the another thread is not progressing toward releasing its ownership of the shared resource; if the execution status of the another thread indicates that the another thread is not progressing toward releasing its ownership of the shared resource, then executing a blocking procedure which temporarily suspends execution of the first thread;
if the execution status of the another thread does not indicate that the another thread is not progressing toward releasing, its ownership of the shared resource, then executing a spin procedure during which the first thread repeatedly determines whether the shared resource is still owned by the another thread, the spin procedure terminating upon the earlier of (i) determining that the shared resource is not owned by another thread, and (ii) reaching a predetermined execution time limit; andmeasuring the duration of a context switching operation within the computing environment, including, in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation, wherein the predetermined execution time limit is made equal to the measured duration of the context switching operation.
-
-
16. A computerized system, comprising:
-
a shared resource; and control circuitry including a set of one or more processors operative to execute a mutual exclusion mechanism in a multi-threaded computing environment, the mutual exclusion mechanism including a computer-implemented method by which a first thread acquires ownership of the shared resource, the shared resource being currently owned by another thread, the method including; in connection with the execution of a spin procedure by which the first thread attempts to acquire ownership of the shared resource, determining whether respective execution statuses of other threads indicate that any of the other threads is ready to be executed; if the respective execution statuses of the other threads indicate that any of the other threads is ready to be executed, then limiting the duration of the spin procedure to a predetermined execution time limit before executing a blocking procedure which temporarily suspends execution of the first thread; and
if the respective execution statuses of the other threads indicate that none of the other threads is ready to be executed, then permitting the spin procedure to execute beyond the predetermined execution time limit; andmeasuring the duration of a context switching operation within the computing environment, including, in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation, wherein the predetermined execution time limit is made equal to the measured duration of the context switching operation.
-
-
17. A computerized system, comprising:
-
a shared resource; and control circuitry including a set of one or more processors operative to execute a mutual exclusion mechanism in a multi-threaded computing environment, the mutual exclusion mechanism including a computer-implemented method by which a first preemptible thread acquires ownership of the shared resource, the shared resource being currently owned by another preemptible thread, the method including; in connection with the execution of a spin-then-block procedure by which the first preemptible thread attempts to acquire ownership of the shared resource, determining whether an execution status of the another preemptible thread indicates that the another preemptible thread is ready to be executed;
if the execution status of the another preemptible thread indicates that the another preemptible thread is ready to be executed, then (i) yielding the remainder of a processing quantum for the first preemptible thread to the another preemptible thread, and (ii) suspending execution of the first preemptible thread;if the execution status of the another preemptible thread indicates that the another preemptible thread is not ready to be executed, then continuing the execution of the spin-then-block procedure by the first preemptible thread; and measuring a duration of a context switching operation within the computing environment, including in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation, and wherein the spin-then-block procedure has a spinning portion employing a predetermined execution time limit equal to the measured duration of the context switching operation.
-
-
18. A computerized system including at least a central processor running a multi-threaded computing environment in which a first thread acquires ownership of a shared resource from another thread, comprising:
-
means, executed by the processor, for measuring the duration of a context switching operation within the computing environment, including, in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation; means, executed by the processor, for executing a spin procedure as part of an attempt by the first thread to acquire ownership of the shared resource, the spin procedure terminating upon the earlier of (i) successfully obtaining ownership of the shared resource, and (ii) reaching predetermined execution time limit equal to the measured duration of the context switching operation; and
means for executing a blocking procedure if the spin procedure terminates by reaching the predetermined execution time limit, the blocking procedure temporarily suspending execution of the first thread.
-
-
19. A computerized system including at least a central processor running a multi-threaded computing environment in which a first thread acquires ownership of a shared resource from another thread, comprising:
-
means, executed by the processor, for determining, as part of an attempt by the first thread to acquire ownership of the shared resource, whether an execution status of the another thread indicates that the another thread is not progressing toward releasing its ownership of the shared resource; means, executed by the processor, for executing a blocking procedure if the execution status of the another thread indicates that the another thread is not progressing toward releasing its ownership of the shared resource, the blocking procedure temporarily suspending execution of the first thread; means, executed by the processor, for executing a spin procedure if the execution status of the another thread does not indicate that the another thread is not progressing toward releasing its ownership of the shared resource, the spin procedure repeatedly determining whether the shared resource is owned by another thread, the spin procedure terminating upon the earlier of (i) determining that the shared resource is not owned by another thread, and (ii) reaching a predetermined execution time limit; and means, executed by the processor, for measuring the duration of a context switching operation within the computing environment, including, in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation, wherein the predetermined execution time limit is made equal to the measured duration of the context switching operation.
-
-
20. A computerized system including at least a central processor running a multi-threaded computing environment in which a first thread acquires ownership of a shared resource from another thread, comprising:
-
means, executed by the processor, for determining, in connection with the execution of a spin procedure by which the first thread attempts to acquire ownership of the shared resource, whether respective execution statuses of other threads indicate that any of the other threads is ready to be executed; means, executed by the processor, for then limiting the duration of the spin procedure if the respective execution statuses of the other threads indicate that any of the other threads is ready to be executed, the duration of the spin procedure being limited to a predetermined execution time limit before executing a blocking procedure which temporarily suspends execution of the first thread; and
means for permitting the spin procedure to execute beyond the predetermined execution time limit if the respective execution statuses of the other threads indicate that none of the other threads is ready to be executed;means, executed by the processor, for measuring the duration of a context switching operation within the computing environment, including, in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation, wherein the predetermined execution time limit is made equal to the measured duration of the context switching operation.
-
-
21. A computerized system including at least a central processor running a multi-threaded computing environment in which a first preemptible thread acquires ownership of a shared resource from another preemptible thread, comprising:
-
means, executed by the processor, for determining, in connection with the execution of a spin-then-block procedure by which the first preemptible thread attempts to acquire ownership of the shared resource, whether an execution status of the another preemptible thread indicates that the another preemptible thread is ready to be executed; means, executed by the processor, operative if the execution status of the another preemptible thread indicates that the another preemptible thread is ready to be executed, for (i) yielding the remainder of a processing quantum for the first preemptible thread to the another preemptible thread, and (ii) suspending execution of the first preemptible thread; means, executed by the processor, for continuing the execution of the spin-then-block procedure by the first preemptible thread if the execution status of the another preemptible thread indicates that the another preemptible thread is not ready to be executed; and means, executed by the processor for measuring the duration of a context switching operation within the computing environment, including, in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation.
-
-
22. A computer program product that includes a computer readable storage medium having instructions stored thereon for accessing a shared resource of a computerized system, such that the instructions, when carried out by the computerized system, cause the computerized system to:
-
measure the duration of a context switching operation within the computing environment, including, in a first measuring thread, marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation; execute a spin procedure as part of an attempt by a first thread to acquire ownership of the shared resource, the spin procedure terminating upon the earlier of (i) successfully obtaining ownership of the shared resource, and (ii) reaching a predetermined execution time limit equal to the measured duration of the context switching operation; and if the spin procedure terminates by reaching the predetermined execution time limit, then execute a blocking procedure which temporarily suspends execution of the first thread.
-
-
23. A computer program product that includes a computer readable storage medium having instructions stored thereon for accessing a shared resource of a computerized system, such that the instructions, when carried out by the computerized system, cause the computerized system to:
-
determine, as part of an attempt by the first thread to acquire ownership of the shared resource, whether an execution status of the another thread indicates that the another thread is not progressing toward releasing its ownership of the shared resource; if the execution status of the another thread indicates that the another thread is not progressing toward releasing its ownership of the shared resource, then execute a blocking procedure which temporarily suspends execution of the first thread; if the execution status of the another thread does not indicate that the another thread is not progressing toward releasing its ownership of the shared resource, then execute a spin procedure during which the first thread repeatedly determines whether the shared resource is owned by another thread, the spin procedure terminating upon the earlier of (i) determining that the shared resource is not owned by another thread, and (ii) reaching a predetermined execution time limit; and measuring the duration of a context switching operation within the computing environment, including, in a first measuring thread marking an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generating a request to wake up the first measuring thread; and in the first measuring thread, marking a finish time at which it is awakened by the request of the second thread, and calculating one-half the difference of the finish and initial times to determine the duration of the context switching operation, wherein the predetermined execution time limit is made equal to the measured duration of the context switching operation.
-
-
24. A computer program product that includes a computer readable storage medium having instructions stored thereon for accessing a shared resource of a computerized system, such that the instructions, when carried out by the computerized system, cause the computerized system to:
-
in connection with the execution of a spin procedure by which the first thread attempts to acquire ownership of the shared resource, determine whether the respective execution statuses of other threads indicate that any of the other threads is ready to be executed; if the respective execution statuses of the other threads indicate that any of the other threads is ready to be executed, then limit the duration of the spin procedure to a predetermined execution time limit before executing a blocking procedure which temporarily suspends execution of the first thread; and if the respective execution statuses of the other threads indicate that none o of the other threads is ready to be executed, then permit the spin procedure to execute beyond the predetermined execution time limit; and measure a duration of a context switching operation within the computing environment, including, in a first measuring thread, mark an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generate a request to wake up the first measuring thread; and in the first measuring thread, mark a finish time at which it is awakened by the request of the second thread, and calculate one-half the difference of the finish and initial times to determine the duration of the context switching operation, and wherein the spin-then-block procedure has a spinning portion employing a predetermined execution time limit equal to the measured duration of the context switching operation.
-
-
25. A computer program product that includes a computer readable storage medium having instructions stored thereon for accessing a shared resource of a computerized system, such that the instructions, when carried out by the computerized system, cause the computerized system to:
-
in connection with the execution of a spin-then-block procedure by which the first thread attempts to acquire ownership of the shared resource, determine whether an execution status of the another preemptible thread indicates that the another preemptible thread is ready to be executed; if the execution status of the another preemptible thread indicates that the another preemptible thread is ready to be executed, then (i) yield the remainder of a processing quantum for the first preemptible thread to the another preemptible thread, and (ii) suspend execution of the first preemptible thread; and if the execution status of the another preemptible thread indicates that the another preemptible thread is not ready to be executed, then continue the execution of the spin-then-block procedure by the first preemptible thread; and measure a duration of a context switching operation within the computing environment, including, in a first measuring thread, mark an initial time at which a request is generated to wake up a second measuring thread, the first measuring thread entering a sleeping state after the wake-up request is generated; in the second measuring thread upon being awakened, generate a request to wake up the first measuring thread; and in the first measuring thread, mark a finish time at which it is awakened by the request of the second thread, and calculate one-half the difference of the finish and initial times to determine the duration of the context switching operation, and wherein the spin-then-block procedure has a spinning portion employing a predetermined execution time limit equal to the measured duration of the context switching operation.
-
Specification