Updating shared variables atomically
First Claim
1. A method, in a data processing system, for performing a transaction to update shared variables atomically, the method comprising:
- reading a plurality of variables for an atomic transaction, wherein the atomic transaction comprises reading the plurality of variables and performing work and updating the plurality of variables;
responsive to the completion of reading the plurality of variables, attempting to acquire a plurality of locks corresponding to the plurality of variables, wherein the attempt to acquire the plurality of locks is unsuccessful if reading the plurality of variables and attempting to acquire the plurality of locks takes longer than a predetermined time period;
responsive to the attempt to acquire the plurality of locks being successful, performing work and updating the plurality of variables; and
responsive to the completion of performing and updating the plurality of variables, waiting the predetermined time period prior to releasing the plurality of locks.
1 Assignment
0 Petitions
Accused Products
Abstract
When a thread begins an atomic transaction, the thread reads one or more variables from one or more source addresses. The read portion of the transaction is constrained to a predetermined amount of time or number of cycles (N). The mechanism then performs a test and set operation to determine whether any other threads hold locks on the one or more source addresses. If the locks for the one or more source addresses are free, then the thread acquires locks on the one or more source addresses. The thread then performs work and updates the one or more variables. Thereafter, the mechanism delays for an amount of time or number of cycles greater than or equal to N before releasing the locks. If another thread attempts to acquire a lock on the one or more source addresses, then the test and set operation for that other thread will fail.
29 Citations
20 Claims
-
1. A method, in a data processing system, for performing a transaction to update shared variables atomically, the method comprising:
-
reading a plurality of variables for an atomic transaction, wherein the atomic transaction comprises reading the plurality of variables and performing work and updating the plurality of variables; responsive to the completion of reading the plurality of variables, attempting to acquire a plurality of locks corresponding to the plurality of variables, wherein the attempt to acquire the plurality of locks is unsuccessful if reading the plurality of variables and attempting to acquire the plurality of locks takes longer than a predetermined time period; responsive to the attempt to acquire the plurality of locks being successful, performing work and updating the plurality of variables; and responsive to the completion of performing and updating the plurality of variables, waiting the predetermined time period prior to releasing the plurality of locks. - View Dependent Claims (2, 6)
-
-
3. The method of claim further comprising:
responsive to the attempt to acquire the plurality of locks being unsuccessful, retrying the atomic transaction. - View Dependent Claims (4, 5)
-
7. A computer program product comprising a non-transitory computer readable storage medium having a computer readable program stored thereon, wherein the computer readable program, when executed on a computing device, causes the computing device to:
-
read a plurality of variables for an atomic transaction, wherein the atomic transaction comprises reading the plurality of variables and performing work and updating the plurality of variables; responsive to the completion of reading the plurality of variables, attempt to acquire a plurality of locks corresponding to the plurality of variables, wherein the attempt to acquire the plurality of locks is unsuccessful if reading the plurality of variables and attempting to acquire the plurality of locks takes longer than a predetermined time period; responsive to the attempt to acquire the plurality of locks being successful, perform work and update the plurality of variables; and responsive to the completion of performing and updating the plurality of variables, wait the predetermined time period prior to releasing the plurality of locks. - View Dependent Claims (8, 9, 10, 11, 12, 13, 14)
-
-
15. An apparatus, comprising:
-
a processing unit executing a thread; a shared memory; and a locking component coupled to the shared memory, wherein responsive to the completion of reading a plurality of variables from the shared memory for an atomic transaction from the thread, the locking component is configured to attempt to acquire a plurality of locks corresponding to the plurality of variables, wherein the atomic transaction comprises reading the plurality of variables and performing work and updating the plurality of variables, wherein the attempt to acquire the plurality of locks is unsuccessful if reading the plurality of variables and attempting to acquire the plurality of locks takes longer than a predetermined time period; wherein responsive to the attempt to acquire the plurality of locks being successful, the thread is configured to perform work and update the plurality of variables in the shared memory; and wherein responsive to the completion of performing work and updating the plurality of variables, the locking component is configured to wait the predetermined time period prior to releasing the plurality of locks. - View Dependent Claims (16, 17, 18, 19, 20)
-
Specification