Download presentation
Presentation is loading. Please wait.
Published byDale Banks Modified over 9 years ago
1
1 Lock-Free Linked Lists Using Compare-and-Swap by John Valois Speaker’s Name: Talk Title: Larry Bush
2
2 Concurrent Object P1P1 P2P2 PnPn Shared Memory
3
3 Lock-Free No Mutual Exclusion Appear Atomic Lamport Massalin and Pu
4
4 Lock-Free Linked Lists?
5
5 bool Compare&Swap ( Type * x, Type old, Type new) { // BEGIN ATOMIC if *x != old { *x = new; return TRUE; } else { return FALSE } // END ATOMIC } Compare&Swap Synchronization Primitive
6
6 Why is this important ? Avoids Mutual Exclusion Problems Convoying Deadlock Priority Inversion Busy Waiting Blocking
7
7 Universal methods are not efficient (Herlihy). Massalin and Pu’s method required the uncommon double word Compare&Swap. Limitations of current implementations
8
8 As quick as spin locks Without blocking or busy waiting (wait free) Benefits of new implementations
9
9 Part 2 Concurrent Linked List Cursor
10
10 Traversal ( no problem ) Cursor
11
11 Insert ( small problem ) s p q
12
12 Insert ( small problem ) s p q
13
13 Insert ( small problem ) s p q swing pointer
14
14 Delete bad
15
15 Delete bad
16
16 Delete ( big problem ) Cursor ad c b
17
17 Delete ( big problem ) Cursor ad c b
18
18 Delete ( big problem ) Cursor ad c b
19
19 Delete ( big problem ) ad c b Cursor
20
20 Auxiliary nodes ad cb
21
21 Delete ( with auxiliary nodes ) ad c b
22
22 Delete ( with auxiliary nodes ) ad c b
23
23 Delete ( with auxiliary nodes ) ad c b
24
24 Delete ( with auxiliary nodes ) ad c b
25
25 Conclusion Allows concurrent operations Good for: parallel processing distributed memory Should be used everywhere
26
26 Questions/Facts
27
27 ABA problem s p q swing pointer
28
28 ABA Solutions Double Compare&Swap No Cell Reuse Memory Management
29
29 Aux Nodes Insertion of new cells takes place between an auxiliary node and an existing regular cell. Chains of auxilary nodes are allowed. An auxilary node is not required to have a real cell node before and after it.
30
30 Related Work Lamport Herlihy Massalin and Pu
31
31 Lock-Free Structures & Memory Management Techniques for linked list, dictionary and tree. Contributions
32
32 Why do you say this is lock-free if it uses a mutual exclusion primitive? Limited to atomic actions provided by the hardware. Only when swinging pointers. Allows simultaneous traversal, insertion and deletion. Lamport (made the distinction) Massalin and Pu (coined the term)
33
33 ptr = find ptr of interest repeat old = Read( ptr ); new = compute new pointer value r = Compare&Swap(ptr, old, new) until ( r = TRUE ) } Swinging the Pointer
34
34 q = new cell Repeat r = SafeRead ( p -> next ) Write ( q -> next, r ) until Compare&Swap( p -> next, r, q ) Insert ( p, x )
35
35 node * target;// -> data node * pre_aux; // -> preceding auxiliary node node * pre_cell; // -> previous cell struct Cursor { };
36
36 // Updates pointers in the cursor so that it becomes valid. // removes double aux_node. Update(cursor c) { };
37
37 c.pre_cell = next // deletes cell back_link = c->pre_cell delete pre_aux Concurrent deletions may stall process and create chains of aux nodes. The last deletion follows the back_links of the deleted cells. After all deletions the list will have no extra aux_nodes Try_delete(cursor c) { };
38
38 Universal Algorithm (a.k.a. Universal Method) An algorithm that provides lock-free functionality for ANY generic ADT is called universal. Universal meaning “for any.” This requires a powerful synchronization primitive. This is an application that defines a primitives strength. Universal Primitive A universal primitive can be used to provide lock-free functionality for any generic Data Type. A universal primitive can also solve the consensus problem. Analogous Problems Generic Lock-Free ADT is analogous to the consensus problem. If a primitive is powerful enough to solve one it can also solve the other. Universal
39
39 Can be implemented using Compare&Swap Test&Set Sets new value to TRUE. Fetch&Add Adds an arbitrary value to shared variable. Test&Set Fetch&Add
40
40 Created algorithms and data structures that directly implement a non-blocking singly-linked list. Allows multiple processes to traverse, insert and delete. Using only commonly available Compare&Swap. Single word version Commonly available on most systems Valois
41
41 An implementation is wait-free if every process finishes in a bounded number of steps, regardless of interleaving. Wait-Free
42
42 Discovered that mutual exclusion problems can be avoided using lock-free methods. Gave the first lock-free algorithm for the single writer/ multiple reader shared variable. Led to more research on the topic. 27 years Lamport
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.