Methods and apparatus for locking objects in a multi-threaded environment
First Claim
Patent Images
1. For use in a multi-thread environment, a method of locking an object to permit a thread to exclusively execute at least a portion of a routine associated with the object, the method comprising:
- receiving a request to access the object from a first thread;
determining if the object is owned by the first thread;
if the object is owned by a second thread, locking the object and setting a lock owner field to identify the first thread via an atomic execution; and
if the object is owned by the first thread, locking the object and setting the lock owner field to identify the first thread without an atomic execution,wherein locking the object without an atomic execution comprises;
determining if a first flag field associated with the object has a first predetermined state;
if the first flag field has the first predetermined state, setting a second flag field associated with the object to a second predetermined state;
verifying that the first flag field still has the first predetermined state.
1 Assignment
0 Petitions
Accused Products
Abstract
Apparatus and methods for locking objects in a multi-threaded environment are provided. An example method permits a first thread to lock an object to exclusively execute at least a portion of a routine associated with the object. The method includes, if the object is owned by a second thread, locking the object via an atomic execution and assigning ownership of the object to the first thread. It also includes, if the object is owned by the first thread, locking the object without an atomic execution.
-
Citations
34 Claims
-
1. For use in a multi-thread environment, a method of locking an object to permit a thread to exclusively execute at least a portion of a routine associated with the object, the method comprising:
-
receiving a request to access the object from a first thread; determining if the object is owned by the first thread; if the object is owned by a second thread, locking the object and setting a lock owner field to identify the first thread via an atomic execution; and if the object is owned by the first thread, locking the object and setting the lock owner field to identify the first thread without an atomic execution, wherein locking the object without an atomic execution comprises; determining if a first flag field associated with the object has a first predetermined state; if the first flag field has the first predetermined state, setting a second flag field associated with the object to a second predetermined state; verifying that the first flag field still has the first predetermined state. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24)
-
-
25. A tangible medium storing software for locking an object to permit a thread to exclusively execute at least a portion of a routine associated with the object, the tangible medium comprising:
-
first software to determine an identity of a thread owning the object; second software to lock the object and to set a lock owner field to identify the first thread via an atomic execution if (1) no thread owns the object or (2) a thread other than the thread seeking to lock the object owns the object, and to lock the object and to set the lock owner field to identify the first thread without an atomic execution if the thread seeking to lock the object owns the object; and third software to examine a first flag field associated with the object and a second flag field associated with the object to determine a lock status of the object, wherein the third software sets the first flag field and the second flag field to indicate the lock status of the object. - View Dependent Claims (27)
-
-
26. A tangible medium as defined in claim wherein the lock status comprises at least one of:
- (a) the object has not yet been locked, (b) the object is locked by a thread that does not own the object, (c) the object is locked by a thread that owns the object, and (d) the object is available to be locked.
-
28. For use in a multi-thread environment, an apparatus for locking an object to permit a thread to exclusively execute at least a portion of a routine associated with the object, the apparatus comprising:
-
an object owner controller to determine an identity of a thread owning the object; a lock owner controller to lock the object and to set a lock owner field to identify the first thread via an atomic execution if (1) no thread owns the object or (2) a thread other than the thread seeking to lock the object owns the object, and to lock the object and to set the lock owner field to identify the first thread without an atomic execution if the thread seeking to lock the object owns the object; and a flag controller to examine a first flag field associated with the object and a second flag field associated with the object to determine a lock status of the object, wherein the flag controller sets the first flag field and the second flag field to indicate the lock status of the object. - View Dependent Claims (29, 30)
-
-
31. For use in a multi-thread environment, a method of locking an object to permit a thread to exclusively execute at least a portion of a routine associated with the object, the method comprising:
-
receiving a request to access the object from a first thread; determining if the object is owned by the first thread; if the object is owned by the first thread, locking the object and setting the lock owner field to identify the first thread without an atomic execution; and if the object is owned by a second thread, locking the object and setting a lock owner field to identify the first thread via an atomic execution, wherein locking the object via an atomic execution comprises; determining if a first flag field associated with the object has a first predetermined state, determining if a second flag field associated with the object has a second predetermined state, and if the first flag field has the first predetermined state and the second flag field has the second predetermined state, setting the first flag field to a third predetermined state.
-
-
32. For use in a multi-thread environment, a method of permitting a first thread to lock an object to exclusively execute at least a portion of a routine associated with the object, the method comprising:
-
if the object is owned by a second thread, locking the object via an atomic execution and assigning ownership of the object to the first thread; if the object is owned by the first thread, locking the object without an atomic execution; and if the object is not owned by any thread, locking the object via a second atomic execution and assigning ownership of the object to the first thread, wherein locking the object via a second atomic execution comprises; verifying that an object owner field associated with the object is empty; determining if a first flag field associated with the object has a first predetermined state; determining if a second flag field associated with the object has a second predetermined state; and if the first flag field has the first predetermined state and the second flag field has the second predetermined state, setting the first flag field to a third predetermined state and setting the object owner field to identify the first thread. - View Dependent Claims (33, 34)
-
Specification