Using data in elements of a singly linked list without a lock in a multithreaded environment
First Claim
1. A computer-implemented method for validating a scan of an unused element chain in a multithreaded computing environment, said method comprising:
- executing, by a computing system, a first thread and a second thread in said multithreaded computing environment;
atomically copying, by a computing system, using said first thread, and from a header of said unused element chain (chain), a modification counter into a first variable and an anchor address into a second variable, wherein said atomically copying includes initially setting a browse counter in said first variable to said modification counter, and wherein said chain is a singly linked list data structure;
setting, by said computing system, using said first thread and subsequent to said atomically copying, said second variable to a next address stored in a current element of said chain, wherein said next address references a next element of said chain, wherein said current element is initially a first element of said chain, and wherein said first element is referenced by said anchor address;
incrementing, by said computing system, using said first thread and subsequent to said atomically copying, said browse counter stored in said first variable to indicate an advance of said scan;
determining, by said computing system and subsequent to said setting and said incrementing, that said browse counter is greater than a current value of said modification counter, wherein said current value of said modification counter indicates any modification made to said chain by said second thread;
determining, by said computing system and in response to said determining that said browse counter is greater than said current value of said modification counter, that said scan of said chain is valid up to said current element of said chain;
concluding, by said computing system, said scan of said chain; and
storing, by said computing system and in response to said concluding said scan, an indication of a result of said scan, wherein said indication of said result is selected from the group consisting of an indication that said scan is valid and an indication that said next address is an invalid address, and wherein said storing said indication of said result includes storing said indication of said result in a first computer data storage unit coupled to said computing system or in a second computer data storage unit coupled to another computing system.
1 Assignment
0 Petitions
Accused Products
Abstract
A method and system for validating a scan of a chain in a multithreaded environment. A modification counter and an anchor address are atomically copied from the chain'"'"'s header into a first variable (browse counter) and second variable, respectively. The second variable is set to a next address stored in a current element of the chain. The next address references a next element of the chain. The browse counter is incremented. If the browse counter is greater than a current value of the modification counter (M.Counter) and if the second variable includes a valid address, then the scan is valid up to the current element, the scan continues with the next element as the current element, and the process repeats starting with setting the second variable to the next address. Otherwise, if the browse counter is less than or equal to M.Counter, then the scan is invalid.
-
Citations
19 Claims
-
1. A computer-implemented method for validating a scan of an unused element chain in a multithreaded computing environment, said method comprising:
-
executing, by a computing system, a first thread and a second thread in said multithreaded computing environment; atomically copying, by a computing system, using said first thread, and from a header of said unused element chain (chain), a modification counter into a first variable and an anchor address into a second variable, wherein said atomically copying includes initially setting a browse counter in said first variable to said modification counter, and wherein said chain is a singly linked list data structure; setting, by said computing system, using said first thread and subsequent to said atomically copying, said second variable to a next address stored in a current element of said chain, wherein said next address references a next element of said chain, wherein said current element is initially a first element of said chain, and wherein said first element is referenced by said anchor address; incrementing, by said computing system, using said first thread and subsequent to said atomically copying, said browse counter stored in said first variable to indicate an advance of said scan; determining, by said computing system and subsequent to said setting and said incrementing, that said browse counter is greater than a current value of said modification counter, wherein said current value of said modification counter indicates any modification made to said chain by said second thread; determining, by said computing system and in response to said determining that said browse counter is greater than said current value of said modification counter, that said scan of said chain is valid up to said current element of said chain; concluding, by said computing system, said scan of said chain; and storing, by said computing system and in response to said concluding said scan, an indication of a result of said scan, wherein said indication of said result is selected from the group consisting of an indication that said scan is valid and an indication that said next address is an invalid address, and wherein said storing said indication of said result includes storing said indication of said result in a first computer data storage unit coupled to said computing system or in a second computer data storage unit coupled to another computing system. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9)
-
-
10. A computer program product, comprising:
a tangible, computer-readable storage device having a computer-readable program code stored therein, said computer-readable program code containing instructions that when executed by a processor of a computing system implement a method of validating a scan of an unused element chain in a multithreaded computing environment, said method comprising; executing a first thread and a second thread in said multithreaded computing environment; atomically copying, using said first thread and from a header of said unused element chain (chain), a modification counter into a first variable and an anchor address into a second variable, wherein a result of said atomically copying is initially setting a browse counter in said first variable to said modification counter, and wherein said chain is a singly linked list data structure; setting, using said first thread and subsequent to said atomically copying, said second variable to a next address stored in a current element of said chain, wherein said next address references a next element of said chain, wherein said current element is initially a first element of said chain, and wherein said first element is referenced by said anchor address; incrementing, using said first thread and subsequent to said atomically copying, said browse counter stored in said first variable to indicate an advance of said scan to said next element of said chain; determining, subsequent to said setting and said incrementing, that said browse counter is greater than a current value of said modification counter, wherein said current value of said modification counter indicates any modification made to said chain by said second thread; determining, in response to said determining that said browse counter is greater than said current value of said modification counter, that said scan of said chain is valid up to said next element of said chain; concluding said scan of said chain; and storing, in response to said concluding said scan, an indication of a result of said scan, wherein said indication of said result is selected from the group consisting of an indication that said scan is valid and an indication that said next address is an invalid address, and wherein said storing said indication of said result includes storing said indication of said result in a first computer data storage unit coupled to said computing system or in a second computer data storage unit coupled to another computing system. - View Dependent Claims (11, 12, 13, 14)
-
15. A computer-implemented method for detecting an invalid scan of an unused element chain in a multithreaded computing environment, said method comprising:
-
executing, by a computing system, a first thread and a second thread in said multithreaded computing environment; atomically copying, by a computing system, using said first thread, and from a header of said unused element chain (chain), a modification counter into a first variable and an anchor address into a second variable, wherein said atomically copying includes initially setting a browse counter in said first variable to said modification counter, wherein said anchor address references a first element of a plurality of elements included in said chain, and wherein said chain is a singly linked list data structure; initially setting a current element of said chain as said first element; determining, by said computing system, using said first thread, and subsequent to said atomically copying, that said anchor address in said second variable is valid based on a predefined criterion; setting, by said computing system, using said first thread, and subsequent to said determining that said anchor address is valid, said second variable to a next address included in said current element of said chain, wherein said next address references a next element of said chain; incrementing, by said computing system, using said first thread, and subsequent to said determining that said anchor address is valid, said browse counter stored in said first variable; comparing, by said computing system and subsequent to said incrementing, said browse counter stored in said first variable to a current value of said modification counter, wherein said current value of said modification counter indicates any modification made to said chain by said second thread; updating said current element to be said next element; updating, subsequent to said updating said current element, said next element to be an element of said plurality of elements that is referenced by an address included in said current element; repeating said setting, said incrementing, said comparing, said updating said current element, and said updating said next element until a result of said comparing is that said browse counter is less than or equal to said current value of said modification counter; determining, by said computing system and in response to said comparing, that said browse counter is less than or equal to said current value of said modification counter; determining, by said computing system and in response to said determining that said browse counter is less than or equal to said current value of said modification counter, that said scan of said chain is invalid; and storing, in response to said determining that said scan is invalid, an indication that said scan is invalid, wherein said storing is performed in a first computer data storage unit coupled to said computing system or in a second computer data storage unit coupled to another computing system. - View Dependent Claims (16, 17, 18, 19)
-
Specification