词条 | Non-blocking linked list |
释义 |
A non-blocking linked list is an example of non-blocking data structures designed to implement a linked list in shared memory using synchronization primitives:
Several strategies for implementing non-blocking lists have been suggested. Review: linked lists(Singly) linked lists are fundamental data structures that are widely used as is, or to build other data structures. They consist of "nodes", or "links", that are put in some order indicated by a "next" pointer on each node. The last node in the list (the "tail") has a {{mono|nil}} next pointer. The first node (the "head") is a sentinel: it stores no interesting information and is only used for its {{mono|next}} pointer. The operations that must be supported on lists are as follows.
Both operations must support concurrent use: two or more threads of execution must be able to perform insertions and deletions without interfering with each other's work (see diagram). Harris's solutionIn a 2001 paper, Harris gives a solution to concurrent linked list maintenance that is non-blocking, using a compare-and-swap ({{mono|cas}}) primitive.{{r|harris}} Insertion of {{mono|n}} after {{mono|p}} is simple:
Deletion of {{mono|p.next}} is more involved. The naive solution of resetting this pointer with a single CAS runs the risk of losing data when another thread is simultaneously inserting (see diagram). Instead, two invocations of {{mono|cas}} are needed for a correct algorithm. The first marks the pointer {{mono|p.next}} as deleted, changing its value but in such a way that the original pointer can still be reconstructed. The second actually deletes the node by resetting {{mono|p.next}}. Operations on lock-free linked listsInsertBasic idea
DeleteBasic idea
ContainsBasic idea
ProblemsConcurrent insert and delete
Solutions
Concurrent deletions
SolutionsValois [3]
Further reading
References1. ^{{Citation | last1 = Harris| first1 = T. | title = A Pragmatic Implementation of Non-Blocking Linked Lists | series = DISC '01 Proceedings of the 15th International Conference on Distributed Computing | place = Springer-Verlag London, UK | pages = 300–314 | year = 2001 | url = http://dl.acm.org/citation.cfm?id=676105 }} 2. ^{{Citation | last1 = Zhang| first1 = K. | last2 = Zhao| first2 = Y. | last3 = Yang| first3 = Y. | last4 = Liu| first4 = Y. | last5 = Spear| first5 = M. | title = Practical Non-Blocking Unordered Lists | series = DISC '13 Proceedings of the 27th International Conference on Distributed Computing | place = Jerusalem, Israel | year = 2013 | url = http://dblp.uni-trier.de/db/conf/wdag/disc2013.html#ZhangZYLS13 }} 3. ^{{Citation | last1 = Valois| first1 = J. | title = Lock-Free Linked Lists Using Compare-and-Swap | series = PODC '95 Proceedings of the fourteenth annual ACM symposium on Principles of distributed computing | place = New York, NY, USA | pages = 214–222 | year = 1995 | url = http://dl.acm.org/citation.cfm?id=224988}} 1 : Linked lists |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。