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.