Deallocation of computer data in a multithreaded computer
First Claim
1. A method of deleting a partition from a logically-partitioned computer of the type including a plurality of logical partitions managed by a partition manager, the logically-partitioned computer further including a plurality of threads executing thereon, and the partition manager having access to a partition control block associated with the partition being deleted, the method comprising:
- incrementing a sequence number associated with a first thread among the plurality of threads to one of an odd and an even value whenever the first thread enters program code for the partition manager;
incrementing the sequence number from the other of an odd and an even value whenever the first thread exits the program code; and
deallocating the partition control block by;
setting a shared pointer to the partition control block to a null value to indicate that the partition control block is not available;
capturing a value of the sequence number;
waiting until each of the plurality of threads is no longer using the shared pointer by monitoring each thread to determine whether said each thread is executing program code that uses the shared pointer, including determining that said each thread is no longer using the shared pointer in response to meeting at least one of a plurality of conditions that includes a first condition where said each thread is inactive, a second condition where said thread is executing in an idle loop in the partition manager, a third condition where said each thread is currently executing program code other than program code for the partition manager, and a fourth condition where the sequence number has changed from the captured value; and
deallocating the partition control block after setting the shared pointer to the null value and waiting until each of the plurality of threads is no longer using the shared pointer.
3 Assignments
0 Petitions
Accused Products
Abstract
An apparatus, program product and method support the deallocation of a data structure in a multithreaded computer without requiring the use of computationally expensive semaphores or spin locks. Specifically, access to a data structure is governed by a shared pointer that, when a request is received to deallocate the data structure, is initially set to a value that indicates to any thread that later accesses the pointer that the data structure is not available. In addition, to address any thread that already holds a copy of the shared pointer, and thus is capable of accessing the data structure via the shared pointer after the initiation of the request, all such threads are monitored to determine whether any thread is still using the shared pointer by determining whether any thread is executing program code that is capable of using the shared pointer to access the data structure. Once this condition is met, it is ensured that no thread can potentially access the data structure via the shared pointer, and as such, the data structure may then be deallocated.
-
Citations
14 Claims
-
1. A method of deleting a partition from a logically-partitioned computer of the type including a plurality of logical partitions managed by a partition manager, the logically-partitioned computer further including a plurality of threads executing thereon, and the partition manager having access to a partition control block associated with the partition being deleted, the method comprising:
-
incrementing a sequence number associated with a first thread among the plurality of threads to one of an odd and an even value whenever the first thread enters program code for the partition manager; incrementing the sequence number from the other of an odd and an even value whenever the first thread exits the program code; and deallocating the partition control block by; setting a shared pointer to the partition control block to a null value to indicate that the partition control block is not available;
capturing a value of the sequence number;
waiting until each of the plurality of threads is no longer using the shared pointer by monitoring each thread to determine whether said each thread is executing program code that uses the shared pointer, including determining that said each thread is no longer using the shared pointer in response to meeting at least one of a plurality of conditions that includes a first condition where said each thread is inactive, a second condition where said thread is executing in an idle loop in the partition manager, a third condition where said each thread is currently executing program code other than program code for the partition manager, and a fourth condition where the sequence number has changed from the captured value; anddeallocating the partition control block after setting the shared pointer to the null value and waiting until each of the plurality of threads is no longer using the shared pointer.
-
-
2. A method of deallocating a data structure accessible by a plurality of threads executing in a computer, the method comprising, in response to a request to deallocate the data structure:
-
setting a shared pointer to the data structure to a predetermined value that indicates to a thread thereafter attempting to use the pointer that the data structure is not available; waiting until each of the plurality of threads is no longer using the shared pointer by monitoring said each thread to determine whether said each thread is executing program code that is capable of using the shared pointer to access the data structure; and deallocating the data structure after setting the shared pointer to the predetermined value and waiting until said each of the plurality of threads is no longer using the shared pointer; wherein determining whether said each thread is executing program code that is capable of using the shared pointer to access the data structure includes determining that said each thread among the plurality of threads is no longer using the shared pointer in response to meeting at least one of a plurality of conditions that includes a first condition where said each thread is inactive, a second condition where said each thread is executing in an idle loop, a third condition where said each thread is currently executing program code other than that which is capable of using the shared pointer, and a fourth condition where the first thread has exited the program code that is capable of using the shared pointer. - View Dependent Claims (3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
-
Specification