SUPPORTING EFFICIENT SPIN-LOCKS AND OTHER TYPES OF SYNCHRONIZATION IN A CACHE-COHERENT MULTIPROCESSOR SYSTEM
First Claim
1. A method for acquiring a lock for a thread in a shared memory multiprocessor system, comprising:
- loading the lock into a cache associated with the thread;
reading a value of the lock; and
if the value indicates that the lock is currently held by another thread, periodically executing an instruction that tests a status of the lock, whereinif the status indicates that the lock is valid, continuing to test the status of the lock;
if the status indicates that the lock was invalidated by a store, attempting the acquire the lock by executing an atomic operation; and
if the status indicates that the lock was invalidated by an atomic operation, or that the lock is not present in the cache, repeating the loading and reading operations.
2 Assignments
0 Petitions
Accused Products
Abstract
Some embodiments of the present invention provide a system that acquires a lock in a shared memory multiprocessor system. During operation, the system loads the lock into a cache associated with the thread and then reads a value of the lock. If the value indicates that the lock is currently held by another thread, the system periodically executes an instruction that tests a status of the lock. If the status indicates the lock is valid, the system continues to test the status of the lock. Otherwise, if the status indicates that the lock was invalidated by a store, the system attempts to acquire the lock by executing an atomic operation. On the other hand, if the status indicates that the lock was invalidated by an atomic operation, or that the lock is not present in the cache, the system repeats the loading and reading operations.
32 Citations
20 Claims
-
1. A method for acquiring a lock for a thread in a shared memory multiprocessor system, comprising:
-
loading the lock into a cache associated with the thread; reading a value of the lock; and if the value indicates that the lock is currently held by another thread, periodically executing an instruction that tests a status of the lock, wherein if the status indicates that the lock is valid, continuing to test the status of the lock; if the status indicates that the lock was invalidated by a store, attempting the acquire the lock by executing an atomic operation; and if the status indicates that the lock was invalidated by an atomic operation, or that the lock is not present in the cache, repeating the loading and reading operations. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
-
-
11. A system that facilitates acquiring a lock for a thread, comprising:
-
a multiprocessor comprising a plurality of processors; a lock-acquiring mechanism in a processor in the plurality of processors, wherein the lock-acquiring mechanism is configured to perform an atomic operation to acquire the lock; and a lock-testing mechanism in the processor, wherein the lock-testing mechanism is configured to load the lock into a cache associated with the thread, and read a value of the lock; and wherein if the value indicates that the lock is currently held by another thread, the lock-testing mechanism is configured to periodically execute an instruction that tests a status of the lock; wherein if the status indicates that the lock is valid, the lock-testing mechanism is configured to continue to test the status of the lock; wherein if the status indicates that the lock was invalidated by an atomic operation, or that the lock is not present in the cache, the lock-testing mechanism is configured to repeat the loading and reading operations; and wherein if the status indicates that the lock was invalidated by a store, the lock-acquiring mechanism is configured to attempt to acquire the lock by executing the atomic operation. - View Dependent Claims (12, 13, 14, 15, 16, 17, 18, 19)
-
-
20. A multiprocessor system that facilitates acquiring a lock for a thread, comprising:
-
a plurality of processors; wherein a processor in the plurality of processors provides a lock-acquiring instruction which is configured to perform an atomic operation to acquire the lock; wherein the processor also provides a lock-testing instruction, which is configured to load the lock into a cache associated with the thread, and read a value of the lock; wherein if the value indicates that the lock is currently held by another thread, the lock-testing instruction is configured to periodically execute an instruction that tests a status of the lock; wherein if the status indicates that the lock is valid, the lock-testing instruction is configured to continue testing the status of the lock; wherein if the status indicates that the lock was invalidated by an atomic operation, or that the lock is not present in the cache, the lock-testing instruction is configured to repeat the loading and reading operations; and wherein if the status indicates that the lock was invalidated by a store, the processor is configured to execute the lock-acquiring instruction to attempt to acquire the lock.
-
Specification