Relaxed lock protocol
First Claim
1. A computer system configured by computer instructions to operate as a compiler/interpreter that:
- A) in response to electrical signals representing source code that calls for an execution thread to lock an object for which there has been allocated an object structure that includes synchronization information that indicates whether the object'"'"'s monitor has been inflated, and, if so, identifies a monitor record, thereby associated with the object, that includes a reference count and a lock indicator that indicates whether the object is locked, produces electrical signals representing object code that directs a processor to perform a lock operation by;
i) reading the synchronization information in the object structure;
ii) if the synchronization information thereby read does not indicate that the object has been inflated, inflating the object'"'"'s monitor by so changing the synchronization information in the object structure as to make the synchronization information indicate that the object'"'"'s monitor is inflated and associate with that object a monitor record whose lock indicator indicates that the object is locked; and
iii) if the synchronization information does indicate that the object'"'"'s monitor has been inflated and identifies a monitor record whose lock indicator indicates that the object has been locked, a) incrementing that monitor'"'"'s reference count to indicate that the thread is waiting for the object; and
b) repeatedly rereading the synchronization information, and reading the monitor record'"'"'s lock indicator if the synchronization indicator still associates the same monitor record with the object, until;
(1) the synchronization indicator no longer associates the same monitor record with the object, in which case the thread recommences the lock operation, or;
(2) the lock indicator no longer indicates that the object is locked, in which case the thread locks the object by making the lock indicator indicate that the object is again locked; and
B) in response to electrical signals representing source code that calls for an execution thread to unlock the object, produces electrical signals representing object code that directs a processor to perform an unlock operation in which the thread;
i) reads the reference count in the monitor record associated with the object; and
ii) if the reference count indicates that no other thread is waiting for the object;
a) changes the object'"'"'s synchronization information to indicate that the object'"'"'s monitor is not inflated without confirming atomically with the synchronization-information change that the reference count still indicates that no further thread is waiting for the object;
b) re-reads the reference count in the monitor record associated with the object; and
c) if the reference count indicates that another thread is waiting for the object causing that other thread to recommence the lock operation.
1 Assignment
0 Petitions
Accused Products
Abstract
An object-oriented compiler/interpreter allocates monitor records for use in implementing synchronized operations on objects. When a synchronization operation is to be performed on an object, a thread that is to perform the operation “inflates” the object'"'"'s monitor by placing into its header a pointer to the monitor record as well as an indication of the monitor'"'"'s inflated status. When a thread is to release its lock on an object, it first consults a reference-count field in the monitor record to determine whether any other threads are synchronized on the object. It then dissociates the object from the monitor record. The dissociation is not atomic with the reference-count check, so the releasing thread checks the reference count again. If that count indicates that further objects had employed the monitor record to synchronize on the object in the interim, then the unlocking thread wakes all waiting threads.
-
Citations
45 Claims
-
1. A computer system configured by computer instructions to operate as a compiler/interpreter that:
-
A) in response to electrical signals representing source code that calls for an execution thread to lock an object for which there has been allocated an object structure that includes synchronization information that indicates whether the object'"'"'s monitor has been inflated, and, if so, identifies a monitor record, thereby associated with the object, that includes a reference count and a lock indicator that indicates whether the object is locked, produces electrical signals representing object code that directs a processor to perform a lock operation by;
i) reading the synchronization information in the object structure;
ii) if the synchronization information thereby read does not indicate that the object has been inflated, inflating the object'"'"'s monitor by so changing the synchronization information in the object structure as to make the synchronization information indicate that the object'"'"'s monitor is inflated and associate with that object a monitor record whose lock indicator indicates that the object is locked; and
iii) if the synchronization information does indicate that the object'"'"'s monitor has been inflated and identifies a monitor record whose lock indicator indicates that the object has been locked, a) incrementing that monitor'"'"'s reference count to indicate that the thread is waiting for the object; and
b) repeatedly rereading the synchronization information, and reading the monitor record'"'"'s lock indicator if the synchronization indicator still associates the same monitor record with the object, until;
(1) the synchronization indicator no longer associates the same monitor record with the object, in which case the thread recommences the lock operation, or;
(2) the lock indicator no longer indicates that the object is locked, in which case the thread locks the object by making the lock indicator indicate that the object is again locked; and
B) in response to electrical signals representing source code that calls for an execution thread to unlock the object, produces electrical signals representing object code that directs a processor to perform an unlock operation in which the thread;
i) reads the reference count in the monitor record associated with the object; and
ii) if the reference count indicates that no other thread is waiting for the object;
a) changes the object'"'"'s synchronization information to indicate that the object'"'"'s monitor is not inflated without confirming atomically with the synchronization-information change that the reference count still indicates that no further thread is waiting for the object;
b) re-reads the reference count in the monitor record associated with the object; and
c) if the reference count indicates that another thread is waiting for the object causing that other thread to recommence the lock operation. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
4. A computer system as defined in claim 1 wherein, in performing the operation of locking the object in response to finding that the monitor record'"'"'s lock indicator no longer indicates that that object is locked after the thread has incremented the monitor record'"'"'s reference count, the thread decrements the monitor record'"'"'s reference count.
-
5. A computer system as defined in claim 4 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
6. A computer system as defined in claim 4 wherein the reading of the synchronization information during the lock operation is performed atomically with the changing of the object'"'"'s synchronization information to inflate the object'"'"'s monitor when the object'"'"'s monitor is not inflated.
-
7. A computer system as defined in claim 6 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
8. A computer system as defined in claim 1 wherein:
-
A) the monitor record includes a nest-count indicator and an owner identifier; and
B) the lock operation includes incrementing the monitor record'"'"'s nest-count indicator when the object structure'"'"'s synchronization information indicates that the object'"'"'s monitor has already been inflated and the monitor record'"'"'s lock indicator and owner identifier indicate that the object is locked by the thread.
-
-
9. A computer system as defined in claim 1 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
10. A computer system as defined in claim 1 wherein the owner identifier is the lock indicator and indicates the absence of a lock when it identifies no thread.
-
11. A computer system as defined in claim 1 wherein, in response to electrical signals representing source code that calls for an execution thread to wait on the object for notification, produces electrical signals representing object code that directs a processor to increment the reference count in a monitor record associated with the object.
-
12. A method of generating object code comprising:
-
A) in response to electrical signals representing source code that calls for an execution thread to lock an object for which there has been allocated an object structure that includes synchronization information that indicates whether the object'"'"'s monitor has been inflated, and, if so, identifies a monitor record, thereby associated with the object, that includes a reference count and a lock indicator that indicates whether the object is locked, producing electrical signals representing object code that directs a processor to perform a lock operation by;
i) reading the synchronization information in the object structure;
ii) if the synchronization information thereby read does not indicate that the object has been inflated, inflating the object'"'"'s monitor by so changing the synchronization information in the object structure as to make the synchronization information indicate that the object'"'"'s monitor is inflated and associate with that object a monitor record whose lock indicator indicates that the object is locked; and
iii) if the synchronization information does indicate that the object'"'"'s monitor has been inflated and identifies a monitor record whose lock indicator indicates that the object has been locked, a) incrementing that monitor'"'"'s reference count to indicate that the thread is waiting for the object; and
b) repeatedly rereading the synchronization information, and reading the monitor record'"'"'s lock indicator if the synchronization indicator still associates the same monitor record with the object, until;
(1) the synchronization indicator no longer associates the same monitor record with the object, in which case the thread recommences the lock operation, or;
(2) the lock indicator no longer indicates that the object is locked, in which case the thread locks the object by making the lock indicator indicate that the object is again locked; and
B) in response to electrical signals representing source code that calls for an execution thread to unlock the object, producing electrical signals representing object code that directs a processor to perform an unlock operation in which the thread;
i) reads the reference count in the monitor record associated with the object; and
ii) if the reference count indicates that no other thread is waiting for the object;
a) changes the object'"'"'s synchronization information to indicate that the object'"'"'s monitor is not inflated without confirming atomically with the synchronization-information change that the reference count still indicates that no further thread is waiting for the object;
b) re-reads the reference count in the monitor record associated with the object; and
c) if the reference count indicates that another thread is waiting for the object, causing that other thread to recommence the lock operation. - View Dependent Claims (13, 14, 15, 16, 17, 18, 19, 20, 21, 22)
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
15. A method as defined in claim 12 wherein, in performing the operation of locking the object in response to finding that the monitor record'"'"'s lock indicator no longer indicates that that object is locked after the thread has incremented the monitor record'"'"'s reference count, the thread decrements the monitor record'"'"'s reference count.
-
16. A method as defined in claim 15 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
17. A method as defined in claim 15 wherein the reading of the synchronization information during the lock operation is performed atomically with the changing of the object'"'"'s synchronization information to inflate the object'"'"'s monitor when the object'"'"'s monitor is not inflated.
-
18. A method as defined in claim 17 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
19. A method as defined in claim 12 wherein:
-
A) the monitor record includes a nest-count indicator and an owner identifier; and
B) the lock operation includes incrementing the monitor record'"'"'s nest-count indicator when the object structure'"'"'s synchronization information indicates that the object'"'"'s monitor has already been inflated and the monitor record'"'"'s lock indicator and owner identifier indicate that the object is locked by the thread.
-
-
20. A method as defined in claim 12 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
21. A method as defined in claim 12 wherein the owner identifier is the lock indicator and indicates the absence of a lock when it identifies no thread.
-
22. A method as defined in claim 12 wherein, in response to electrical signals representing source code that calls for an execution thread to wait on the object for notification, produces electrical signals representing object code that directs a processor to increment the reference count in a monitor record associated with the object.
-
23. A storage medium containing instructions readable by a computer system to configure the computer system to operate as a compiler/interpreter that:
-
A) in response to electrical signals representing source code that calls for an execution thread to lock an object for which there has been allocated an object structure that includes synchronization information that indicates whether the object'"'"'s monitor has been inflated, and, if so, identifies a monitor record, thereby associated with the object, that includes a reference count and a lock indicator that indicates whether the object is locked, produces electrical signals representing object code that directs a processor to perform a lock operation by;
i) reading the synchronization information in the object structure;
ii) if the synchronization information thereby read does not indicate that the object has been inflated, inflating the object'"'"'s monitor by so changing the synchronization information in the object structure as to make the synchronization information indicate that the object'"'"'s monitor is inflated and associate with that object a monitor record whose lock indicator indicates that the object is locked; and
iii) if the synchronization information does indicate that the object'"'"'s monitor has been inflated and identifies a monitor record whose lock indicator indicates that the object has been locked, a) incrementing that monitor'"'"'s reference count to indicate that the thread is waiting for the object; and
b) repeatedly rereading the synchronization information, and reading the monitor record'"'"'s lock indicator if the synchronization indicator still associates the same monitor record with the object, until;
(1) the synchronization indicator no longer associates the same monitor record with the object, in which case the thread recommences the lock operation, or;
(2) the lock indicator no longer indicates that the object is locked, in which case the thread locks the object by making the lock indicator indicate that the object is again locked; and
B) in response to electrical signals representing source code that calls for an execution thread to unlock the object, produces electrical signals representing object code that directs a processor to perform an unlock operation in which the thread;
i) reads the reference count in the monitor record associated with the object; and
ii) if the reference count indicates that no other thread is waiting for the object;
a) changes the object'"'"'s synchronization information to indicate that the object'"'"'s monitor is not inflated without confirming atomically with the synchronization-information change that the reference count still indicates that no further thread is waiting for the object;
b) re-reads the reference count in the monitor record associated with the object; and
c) if the reference count indicates that another thread is waiting for the object, causing that other thread to recommence the lock operation. - View Dependent Claims (24, 25, 26, 27, 28, 29, 30, 31, 32, 33)
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
26. A storage medium as defined in claim 23 wherein, in performing the operation of locking the object in response to finding that the monitor record'"'"'s lock indicator no longer indicates that that object is locked after the thread has incremented the monitor record'"'"'s reference count, the thread decrements the monitor record'"'"'s reference count.
-
27. A storage medium as defined in claim 26 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
28. A storage medium as defined in claim 26 wherein the reading of the synchronization information during the lock operation is performed atomically with the changing of the object'"'"'s synchronization information to inflate the object'"'"'s monitor when the object'"'"'s monitor is not inflated.
-
29. A storage medium as defined in claim 28 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
30. A storage medium as defined in claim 23 wherein:
-
A) the monitor record includes a nest-count indicator and an owner identifier; and
B) the lock operation includes incrementing the monitor record'"'"'s nest-count indicator when the object structure'"'"'s synchronization information indicates that the object'"'"'s monitor has already been inflated and the monitor record'"'"'s lock indicator and owner identifier indicate that the object is locked by the thread.
-
-
31. A storage medium as defined in claim 23 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
32. A storage medium as defined in claim 23 wherein the owner identifier is the lock indicator and indicates the absence of a lock when it identifies no thread.
-
33. A storage medium as defined in claim 23 wherein, in response to electrical signals representing source code that calls for an execution thread to wait on the object for notification, produces electrical signals representing object code that directs a processor to increment the reference count in a monitor record associated with the object.
-
34. A computer signal representing a sequence of instructions that, when executed by a computer system, configures the computer system to operate as a compiler/interpreter that:
-
A) in response to electrical signals representing source code that calls for an execution thread to lock an object for which there has been allocated an object structure that includes synchronization information that indicates whether the object'"'"'s monitor has been inflated, and, if so, identifies a monitor record, thereby associated with the object, that includes a reference count and a lock indicator that indicates whether the object is locked, produces electrical signals representing object code that directs a processor to perform a lock operation by;
i) reading the synchronization information in the object structure;
ii) if the synchronization information thereby read does not indicate that the object has been inflated, inflating the object'"'"'s monitor by so changing the synchronization information in the object structure as to make the synchronization information indicate that the object'"'"'s monitor is inflated and associate with that object a monitor record whose lock indicator indicates that the object is locked; and
iii) if the synchronization information does indicate that the object'"'"'s monitor has been inflated and identifies a monitor record whose lock indicator indicates that the object has been locked, a) incrementing that monitor'"'"'s reference count to indicate that the thread is waiting for the object; and
b) repeatedly rereading the synchronization information, and reading the monitor record'"'"'s lock indicator if the synchronization indicator still associates the same monitor record with the object, until;
(1) the synchronization indicator no longer associates the same monitor record with the object, in which case the thread recommences the lock operation, or;
(2) the lock indicator no longer indicates that the object is locked, in which case the thread locks the object by making the lock indicator indicate that the object is again locked; and
B) in response to electrical signals representing source code that calls for an execution thread to unlock the object, produces electrical signals representing object code that directs a processor to perform an unlock operation in which the thread;
i) reads the reference count in the monitor record associated with the object; and
ii) if the reference count indicates that no other thread is waiting for the object;
a) changes the object'"'"'s synchronization information to indicate that the object'"'"'s monitor is not inflated without confirming atomically with the synchronization-information change that the reference count still indicates that no further thread is waiting for the object;
b) re-reads the reference count in the monitor record associated with the object; and
c) if the reference count indicates that another thread is waiting for the object, causing that other thread to recommence the lock operation. - View Dependent Claims (35, 36, 37, 38, 39, 40, 41, 42, 43, 44)
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
37. A computer signal as defined in claim 34 wherein, in performing the operation of locking the object in response to finding that the monitor record'"'"'s lock indicator no longer indicates that that object is locked after the thread has incremented the monitor record'"'"'s reference count, the thread decrements the monitor record'"'"'s reference count.
-
38. A computer signal as defined in claim 37 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution-interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
39. A computer signal as defined in claim 37 wherein the reading of the synchronization information during the lock operation is performed atomically with the changing of the object'"'"'s synchronization information to inflate the object'"'"'s monitor when the object'"'"'s monitor is not inflated.
-
40. A computer signal as defined in claim 39 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
41. A computer signal as defined in claim 34 wherein:
-
A) the monitor record includes a nest-count indicator and an owner identifier; and
B) the lock operation includes incrementing the monitor record'"'"'s nest-count indicator when the object structure'"'"'s synchronization information indicates that the object'"'"'s monitor has already been inflated and the monitor record'"'"'s lock indicator and owner identifier indicate that the object is locked by the thread.
-
-
42. A computer signal as defined in claim 34 wherein:
-
A) an execution thread is allocated execution time only if it is in a ready queue;
B) a thread performing the lock operation precedes its rereading of the synchronization information by having its execution interrupted without leaving itself in the ready queue; and
C) a thread performing the unlock operation places a thread thus interrupted on the ready queue if there is such a thread.
-
-
43. A computer signal as defined in claim 34 wherein the owner identifier is the lock indicator and indicates the absence of a lock when it identifies no thread.
-
44. A computer signal as defined in claim 34 wherein, in response to electrical signals representing source code that calls for an execution thread to wait on the object for notification, produces electrical signals representing object code that directs a processor to increment the reference count in a monitor record associated with the object.
-
45. A compiler/interpreter comprising:
-
A) means for, in response to electrical signals representing source code that calls for an execution thread to lock an object for which there has been allocated an object structure that includes synchronization information that indicates whether the object'"'"'s monitor has been inflated, and, if so, identifies a monitor record, thereby associated with the object, that includes a reference count and a lock indicator that indicates whether the object is locked, producing electrical signals representing object code that directs a processor to perform a lock operation by;
i) reading the synchronization information in the object structure;
ii) if the synchronization information thereby read does not indicate that the object has been inflated, inflating the object'"'"'s monitor by so changing the synchronization information in the object structure as to make the synchronization information indicate that the object'"'"'s monitor is inflated and associate with that object a monitor record whose lock indicator indicates that the object is locked; and
iii) if the synchronization information does indicate that the object'"'"'s monitor has been inflated and identifies a monitor record whose lock indicator indicates that the object has been locked, a) incrementing that monitor'"'"'s reference count to indicate that the thread is waiting for the object; and
b) repeatedly rereading the synchronization information, and reading the monitor record'"'"'s lock indicator if the synchronization indicator still associates the same monitor record with the object, until;
(1) the synchronization indicator no longer associates the same monitor record with the object, in which case the thread recommences the lock operation, or;
(2) the lock indicator no longer indicates that the object is locked, in which case the thread locks the object by making the lock indicator indicate that the object is again locked; and
B) means for, in response to electrical signals representing source code that calls for an execution thread to unlock the object, producing electrical signals representing object code that directs a processor to perform an unlock operation in which the thread;
i) reads the reference count in the monitor record associated with the object; and
ii) if the reference count indicates that no other thread is waiting for the object;
a) changes the object'"'"'s synchronization information to indicate that the object'"'"'s monitor is not inflated without confirming atomically with the synchronization-information change that the reference count still indicates that no further thread is waiting for the object;
b) re-reads the reference count in the monitor record associated with the object; and
c) if the reference count indicates that another thread is waiting for the object, causing that other thread to recommence the lock operation.
-
Specification