摘要 |
A system and method for implementing mutual exclusion locks (mutexes) is provided. Mutexes of the present invention designate whether they are to be synchronized using fast nonatomic load/store sequences or, alternatively, expensive atomic hardware instructions. When a requesting thread requests a target mutex, the target mutex is synchronized using the method designated by the target mutex. In some embodiments, the designated synchronization method may be changed to the atomic method when the requesting thread is not the thread associated with the target mutex. In other embodiments, the designated synchronization method may be determined by a heuristic function. For example, the synchronization method may be changed to the atomic method when a mutex request counter, which penalizes thread changes, underflows. Other possible heuristic functions may consider factors such as whether the recursion overflow bit of the target mutex has been set, the percentage of mutexes, created by a predetermined call state, that have been converted to the atomic method, and/or the overall percentage of mutexes in the system that have been converted to the atomic method.
|