Method and apparatus for concurrent thread synchronization
First Claim
1. A computer-implemented method for obtaining a header value of an object using a first thread, the object including an object header, the first thread having an associated execution stack and having a first thread execution priority, the method comprising:
- (a) replacing contents of the object header with a sentinel which identifies the stack;
(b) determining whether the contents include a header value of the object;
(c) when it is determined that the contents do not include the header value of the object, determining when the object is being studied by a second thread;
(d) adding the first thread to a list associated with the stack, the list being arranged to indicate that the first thread is awaiting access to the object; and
(e) returning the contents to the object header.
0 Assignments
0 Petitions
Accused Products
Abstract
Methods and apparatus for locking and unlocking objects using synchronized threads are disclosed. According to one aspect of the present invention, a computer-implemented method for using a first thread to obtain a header value of an object includes replacing contents of a header of the object with a sentinel which identifies an execution stack associated with the first thread. Once the object contents are replaced with the sentinel, a determination is made regarding whether the object contents include a header value of the object, and when it is determined that the object contents do not include the header value of the object, a determination is made as to when the object is in the process of being studied by a second thread. In one embodiment, when it is determined that the object is not in the process of being studied by the second thread, the method involves adding the first thread to a list associated with the stack.
-
Citations
20 Claims
-
1. A computer-implemented method for obtaining a header value of an object using a first thread, the object including an object header, the first thread having an associated execution stack and having a first thread execution priority, the method comprising:
-
(a) replacing contents of the object header with a sentinel which identifies the stack;
(b) determining whether the contents include a header value of the object;
(c) when it is determined that the contents do not include the header value of the object, determining when the object is being studied by a second thread;
(d) adding the first thread to a list associated with the stack, the list being arranged to indicate that the first thread is awaiting access to the object; and
(e) returning the contents to the object header. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
receiving a notification for the first thread to access the object.
-
-
3. A computer-implemented method as recited in claim 1 wherein, the method further includes:
resolving the contents to identify the second thread.
-
4. A computer-implemented method as recited in claim 1 wherein, the method further includes:
determining whether a second thread execution priority associated with the second thread is less than the first thread execution priority.
-
5. A computer-implemented method as recited in claim 4 wherein when it is determined that the second thread execution priority is less than the first thread execution priority, the method further includes boosting the second thread execution priority to the first thread execution priority.
-
6. A computer-implemented method as recited in claim 5 further including:
-
incrementing a counter associated with the second thread to indicate that the second thread execution priority has been boosted; and
adding the second thread and the counter to a queue of boosted threads, the queue of boosted threads being associated with the first thread.
-
-
7. A computer-implemented method as recited in claim 1 wherein when it is determined that the contents include the header value, the method further includes:
-
storing the contents on the stack in a particular location; and
storing a pointer in the object header, wherein the pointer is arranged to identify the particular location.
-
-
8. A computer-implemented method as recited in claim 7 further including unboosting a second thread execution priority of the second thread, wherein the second thread execution priority was boosted to the first thread execution priority.
-
9. A computer-implemented method as recited in claim 8 wherein unboosting the second thread execution priority of the second thread involves unboosting the second thread execution priority to an assigned execution priority of the second thread.
-
10. A computer-implemented method as recited in claim 9 further including Constructing the sentinel.
-
11. A computer implemented method for returning a header value of an object to the object, the header value being stored on an execution stack associated with a first thread, the object including an object header, the first thread having a first thread execution priority, the method comprising:
-
(a) exchanging contents of the object header for a sentinel arranged to identify the execution stack; and
(b) using the contents to determine if the object is being studied by a second thread;
(c) when it is determined that the object is not being studied by the second thread, replacing the sentinel with the header value;
(d) resolving the contents to identify the second thread when it is determined that the object is being studied by the second thread; and
(e) determining whether a second thread execution priority associated with the second thread is less than the first thread execution priority when it is determined that the object is being studied by the second thread. - View Dependent Claims (12, 13, 14)
incrementing a counter associated with the second thread to indicate that the second thread execution priority has been boosted.
-
-
14. A computer-implemented method as recited in claim 11 further including:
adding the second thread and the counter to a queue of boosted threads, the queue of boosted threads being associated with the first thread.
-
15. A computer program product for associating an object with a first thread, the object including an object header, the first thread having an associated stack allocated in a memory associated with a computer system, the computer program product comprising:
-
(a) computer code that obtains contents of the object header; and
(b) computer code that stores the contents of the object header at a first location within the stack;
(c) computer code that stores a reference indicator in the object header, the reference indicator being arranged to identify the stack;
(d) computer code that determines when the contents of the object header do not include a header value;
(e) computer code that determines when the object is in the process of being studied by a second thread when the contents of the object header do not include the header value;
(f) a computer readable medium that stores the computer codes; and
(g) computer code that updates a status indicator associated with the object to indicate that the reference indicator is stored in the object header. - View Dependent Claims (16, 17, 18, 19, 20)
computer code that stores a forwarding pointer in the object header when it is determined that the contents of the object header are the header value, the forwarding pointer being arranged to identify the first location within the stack.
-
-
18. A computer program product according to claim 17 further including:
-
computer code that returns the contents of the object header to the object header when it is determined that the contents of the object header are not the header value; and
computer code that updates a status indicator associated with the object to indicate that the contents of the object header are in the object header when it is determined that the contents of the object header are not the header value.
-
-
19. A computer program product according to claim 18 further including computer code that determines whether the contents of the object header identify a second location within the stack when it is determined that the contents of the object header are not a header value.
-
20. A computer program product according to claim 19 further including:
-
computer code that returns the contents of the object header to the object header when the contents of the object header identify a second location within the stack; and
computer code that stores an indicator value in the first location within the stack when the contents of the object header identify a second location within the stack, the indicator value being arranged to indicate that the header value is stored in the second location within the stack.
-
Specification