Lock-Free and Practical Doubly Linked List-Based Deques using Single-Word Compare-And-Swap
Håkan Sundell Philippas Tsigas
OPODIS 2004: The 8th International Conference on Principles of Distributed Systems
Lock-Free and Practical Doubly Linked List-Based Deques using - - PowerPoint PPT Presentation
Lock-Free and Practical Doubly Linked List-Based Deques using Single-Word Compare-And-Swap Hkan Sundell Philippas Tsigas OPODIS 2004: The 8th International Conference on Principles of Distributed Systems Sundell Jr. 2 Outline
OPODIS 2004: The 8th International Conference on Principles of Distributed Systems
2
3
4
Shared data structures needs
Synchronization using Locks Mutually exclusive access to whole or parts
P1 P2 P3 P1 P2 P3
5
6
1. The operation is prepared to later take effect (unless interfered) using hardware atomic primitives 2. Possible interference is detected via the atomic primitives, and causes a retry
7
8
Fundamental data structure Can be used to implement various abstract data
Unordered List, i.e. the nodes are ordered only
Supports Traversals Supports Inserts/Deletes at arbitrary positions H T
9
Errata: S. Doherty et al. “DCAS is not a silver
10
11
Treat the doubly linked list as a singly linked
Singly Linked Lists
H T
12
13
14
15
16
17
General Doubly Linked List Structure Treated as singly linked lists with extra info Uses CAS atomic primitive Lock-Free memory management IBM Freelists Reference counting (Valois+Michael&Scott) Avoids cyclic garbage Helping scheme All together proved to be linearizable
18
Experiment with 1-28 threads performed on
Each thread performs 1000 operations,
Compare with implementation by Michael
For Martin et al. DCAS implemented by
Averaged execution time of 50 experiments.
19
1 10 100 1000 5 10 15 20 25 30 Execution Time (ms) Threads Deque with High Contention - Linux, 2 Processors NEW ALGORITHM MICHAEL HAT-TRICK MUTEX HAT-TRICK CASN
20
1 10 100 1000 10000 100000 5 10 15 20 25 30 Execution Time (ms) Threads Deque with High Contention - SGI Mips, 29 Processors NEW ALGORITHM MICHAEL HAT-TRICK MUTEX HAT-TRICK CASN
21
A first lock-free Deque using single word CAS. The new algorithm is more scalable than
Also implements a general doubly linked list,
Our lock-free algorithm is suitable for both
Will be available as part of NOBLE software
See Håkan Sundell’s PhD Thesis for an
22
Contact Information: Address:
Email:
Web:
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Head Mem 1 Mem 2 Mem n
Used 1
Reclaim Allocate
45
46
Solution: (Valois et al) Add reference
1 1 ? ? ? 1
CAS Failes!
47
Need to remove marked-to-be-deleted
Finds previous node, finish deletion and
48
For pre-emptive systems, helping is
For really concurrent systems, overlapping
Solution: For every failed CAS attempt,
49
50
51
Define precise sequential semantics Define abstract state and its interpretation Show that state is atomically updated Define linearizability points Show that operations take effect atomically
Creates a total order using the linearizability
The algorithm is linearizable
52