SYSTEM AND METHOD FOR LOAD-ADAPTIVE MUTUAL EXCLUSION WITH WAITING PROCESS COUNTS
First Claim
1. A method for mutually exclusively executing a critical section by a process in a computer system, wherein a lock permits the process an access to the critical section, the method comprising:
- upon detecting that the lock is held by another process, adding one (1) to a waiter count that represents the number of processes waiting for the lock, measuring a detection time that represents the time of said detecting, and measuring a current time representing a present time;
subsequent to said adding, repeating at least one iteration comprising steps of determining a waiting mode of the process, and subsequently attempting to acquire the lock, wherein the waiting mode is determined such that the process in the waiting mode wastes the least amount of time while waiting for the lock pursuant to at least one delay stored in a lock delay history data structure and a suspension overhead time of the computer system;
subsequent to said repeating, acquiring the lock for the process;
subsequent to said acquiring, calculating a delay representing a difference between a release time representing when the lock is released and the detection time;
subsequent to said calculating, storing the calculated delay in the lock delay history data structure; and
subsequent to said storing, subtracting one (1) from the waiter count,wherein said adding, said repeating, said acquiring, said calculating, said storing, and said subtracting are performed by a locking function invoked by the process.
1 Assignment
0 Petitions
Accused Products
Abstract
A system and associated method for mutually exclusively executing a critical section by a process in a computer system. The critical section accessing a shared resource is controlled by a lock. The method measures a detection time when a lock contention is detected, a wait time representing a duration of wait for the lock at each failed attempt to acquire the lock, and a delay representing a total lapse of time from the detection time till the lock is acquired. The delay is logged and used to calculate an average delay, which is compared with a suspension overhead time of the computer system to determine whether to spin or to suspend the process while waiting for the lock to be released. The number of processes waiting for the lock and the number of processes suspended are respectively counted to optimize the method.
67 Citations
20 Claims
-
1. A method for mutually exclusively executing a critical section by a process in a computer system, wherein a lock permits the process an access to the critical section, the method comprising:
-
upon detecting that the lock is held by another process, adding one (1) to a waiter count that represents the number of processes waiting for the lock, measuring a detection time that represents the time of said detecting, and measuring a current time representing a present time; subsequent to said adding, repeating at least one iteration comprising steps of determining a waiting mode of the process, and subsequently attempting to acquire the lock, wherein the waiting mode is determined such that the process in the waiting mode wastes the least amount of time while waiting for the lock pursuant to at least one delay stored in a lock delay history data structure and a suspension overhead time of the computer system; subsequent to said repeating, acquiring the lock for the process; subsequent to said acquiring, calculating a delay representing a difference between a release time representing when the lock is released and the detection time; subsequent to said calculating, storing the calculated delay in the lock delay history data structure; and subsequent to said storing, subtracting one (1) from the waiter count, wherein said adding, said repeating, said acquiring, said calculating, said storing, and said subtracting are performed by a locking function invoked by the process. - View Dependent Claims (2, 3, 4, 5, 6, 7)
-
-
8. A computer program product, comprising a computer usable storage medium having a computer readable program code embodied therein, said computer readable program code containing instructions that when executed by a processor of a computer system implement a method for mutually exclusively executing a critical section by a process in a computer system, wherein a lock permits the process an access to the critical section, the method comprising:
-
upon detecting that the lock is held by another process, adding one (1) to a waiter count that represents the number of processes waiting for the lock, measuring a detection time that represents the time of said detecting, and measuring a current time representing a present time; subsequent to said adding, repeating at least one iteration comprising steps of determining a waiting mode of the process, and subsequently attempting to acquire the lock, wherein the waiting mode is determined such that the process in the waiting mode wastes the least amount of time while waiting for the lock pursuant to at least one delay stored in a lock delay history data structure and a suspension overhead time of the computer system; subsequent to said repeating, acquiring the lock for the process; subsequent to said acquiring, calculating a delay representing a difference between a release time representing when the lock is released and the detection time; subsequent to said calculating, storing the calculated delay in the lock delay history data structure; and subsequent to said storing, subtracting one (1) from the waiter count, wherein said adding, said repeating, said acquiring, said calculating, said storing, and said subtracting are performed by a locking function invoked by the process. - View Dependent Claims (9, 10, 11, 12, 13, 14)
-
-
15. A computer system comprising a processor and a computer readable memory unit coupled to the processor, said memory unit containing instructions that when executed by the processor implement a method for mutually exclusively executing a critical section by a process in a computer system, wherein a lock permits the process an access to the critical section, the method comprising:
-
upon detecting that the lock is held by another process, adding one (1) to a waiter count that represents the number of processes waiting for the lock, measuring a detection time that represents the time of said detecting, and measuring a current time representing a present time; subsequent to said adding, repeating at least one iteration comprising steps of determining a waiting mode of the process, and subsequently attempting to acquire the lock, wherein the waiting mode is determined such that the process in the waiting mode wastes the least amount of time while waiting for the lock pursuant to at least one delay stored in a lock delay history data structure and a suspension overhead time of the computer system; subsequent to said repeating, acquiring the lock for the process; subsequent to said acquiring, calculating a delay representing a difference between a release time representing when the lock is released and the detection time; subsequent to said calculating, storing the calculated delay in the lock delay history data structure; and subsequent to said storing, subtracting one (1) from the waiter count, wherein said adding, said repeating, said acquiring, said calculating, said storing, and said subtracting are performed by a locking function invoked by the process, and wherein the detection time, the current time, the delay, and the suspension overhead time is measured by a respective count of processor cycles of the computer system. - View Dependent Claims (16, 17, 18, 19, 20)
-
Specification