Method and system for managing lock contention in a computer system
First Claim
1. A lock contention management method, comprising:
- determining whether a code module has failed to acquire access to a lock to keep other code modules from accessing a resource;
allowing a higher-priority code module to access the lock first by changing from an original priority of the code module to a lower priority if the code module should continually request access to the lock, and allowing the code module to continue to request access at the lower priority if it is determined that there are no other code modules waiting to run; and
restoring the code module to its original priority after the code module either obtains the lock or is forced to sleep after some fixed period of time.
1 Assignment
0 Petitions
Accused Products
Abstract
A system and method for efficiently managing lock contention for a central processing unit (CPU) of a computer system. The present invention uses both spinning and blocking (or undispatching) to manage threads when they are waiting to acquire a lock. In addition, the present invention intelligently determines when the program thread should spin and when the program thread should become undispatched. If it is determined that the program thread should become undispatched, the present invention provides efficient undispatching of program threads that improves throughput by reducing wait time to acquire the lock. A lock contention management system includes a dispatcher for managing the execution of threads on CPUs as well as threads that are currently ready to run but not executing because they are waiting for an available CPU, a dispatch management module that determines when a program thread should become undispatched to wait on a lock and when the program thread should spin, and low-priority execution module for undispatching the program thread. The present invention also includes a lock contention management method using the above system.
-
Citations
16 Claims
-
1. A lock contention management method, comprising:
-
determining whether a code module has failed to acquire access to a lock to keep other code modules from accessing a resource;
allowing a higher-priority code module to access the lock first by changing from an original priority of the code module to a lower priority if the code module should continually request access to the lock, and allowing the code module to continue to request access at the lower priority if it is determined that there are no other code modules waiting to run; and
restoring the code module to its original priority after the code module either obtains the lock or is forced to sleep after some fixed period of time. - View Dependent Claims (2, 3, 4, 5, 6, 7)
-
-
8. A lock contention management system, comprising:
-
a dispatch management module that undispatches a code module when the code module has failed to acquire access to a lock to keep other code modules from accessing a resource, and other code modules are waiting to run; and
a low-priority execution module that lowers a priority of the code module when the code module becomes undispatched;
wherein, if the code module continually requests access to the lock, and if there are no other code modules waiting to run, allowing a higher-priority code module to access the lock first by changing from an original priority of the code module to the lower priority with the low-priority execution module, dispatching the code module with the dispatch management module and allowing the code module to spin at the lower priority;
wherein the code module is restored to its original priority after the code module either obtains the lock or is forced to sleep after some fixed period of time. - View Dependent Claims (9, 10, 11, 12, 13)
-
-
14. A method of acquiring a lock to allow execution of a program thread by a computer processor, comprising:
-
undispatching the program thread when the program thread has failed to acquire a lock and other program threads are waiting to run;
lowering a priority of the program thread before spinning or undispatching;
dispatching the program thread and allowing a higher-priority code module to access the lock first by changing from an original priority of the program thread to the lower priority if the program thread continually requests access to the lock and if there are no other program threads waiting to run and allowing the code module to spin at the lower priority; and
restoring the program thread to its original priority after the program thread either obtains the lock or is forced to sleep after some fixed period of time. - View Dependent Claims (15, 16)
-
Specification