On Helping and Stacks Vitaly Aksenov, INRIA Paris / ITMO University Petr Kuznetsov, Telecom ParisTech Anatoly Shalyto, ITMO University NETYS 2018 1 / 21
Takeaway ◮ Linearization-based helping [Censor-Hillel et al., 2015]: a process takes a step and fixes the order between two operations. ◮ Theorem: stack and queue do not have a wait-free help-free implementation using compare&swap and fetch&add. ◮ Proved for exact order types. ◮ Stack is not exact order type. ◮ We give a direct proof for stack. 2 / 21
Outline Helping Original proof. Refutation Correct proof Conclusion 3 / 21
Outline Helping Original proof. Refutation Correct proof Conclusion 4 / 21
What is helping? ◮ Intuitively: an operation performs some work on behalf of another. ◮ Often appears in wait-free and lock-free algorithms. ◮ Examples: ◮ Universal wait-free construction [Herlihy, 1991]; ◮ Lock-free binary search tree [Ellen et al., 2010]. ◮ How to define helping formally? ◮ Linearization-based helping. 5 / 21
Linearization function h f 6 / 21
Helping. Decided before Definition 1 We say that op 1 is decided before op 2 in h with respect to f , if there exists no extension s of h such that op 2 ≺ f ( s ) op 1 . op 1 h op 2 s 1 s 2 f f 7 / 21
Helping. Definition Definition 2 An implementation has helping if op 1 by p 1 is decided before op 2 by p 2 after a step of p 3 . op 1 op 2 op 3 f 8 / 21
Helping. Definition Definition 2 An implementation has helping if op 1 by p 1 is decided before op 2 by p 2 after a step of p 3 . op 1 op 2 op 3 f 8 / 21
Helping. Definition Definition 2 An implementation has helping if op 1 by p 1 is decided before op 2 by p 2 after a step of p 3 . op 1 op 2 op 3 f 8 / 21
Helping. Definition Definition 2 An implementation has helping if op 1 by p 1 is decided before op 2 by p 2 after a step of p 3 . op 1 op 2 op 3 f 8 / 21
Helping. Definition Definition 2 An implementation has helping if op 1 by p 1 is decided before op 2 by p 2 after a step of p 3 . op 1 op 2 op 3 f 8 / 21
Helping. Definition Definition 2 An implementation has helping if op 1 by p 1 is decided before op 2 by p 2 after a step of p 3 . op 1 op 2 op 3 f 8 / 21
Outline Helping Original proof. Refutation Correct proof Conclusion 9 / 21
Exact Order Type There exist an operation op , an infinite sequence W and a sequence R such that for any n there exists m ... x op W 1 W n W n + 1 R 1 R i R m . . . . . . . . . . . . . . . . . . . . . . . . op W n + 1 W 1 W n R 1 R i R m y 10 / 21
Exact Order Type. Queue ◮ op = enq ( 1 ) , W i = enq ( i + 1 ) and R i = deq () . ◮ Given n , we choose m = n + 1. 2 i + 1 n + 2 enq(2) enq( n + 1) enq( n + 2) deq() enq(1) deq() deq() op W 1 W n W n + 1 R 1 R i R n + 1 . . . . . . . . . . . . . . . . . . . . . . . . op W 1 W n R 1 R i W n + 1 R n + 1 enq(2) enq( n + 1) enq(1) deq() deq() enq( n + 2) deq() 2 i + 1 1 11 / 21
Exact Order Type Theorem 3 (Censor-Hillel et al., 2015) Any exact order type does not have a wait-free help-free implementation in systems with compare&swap and fetch&add primitives. Theorem 4 Stack is not exact order type. 12 / 21
Stack is not Exact Order Type n + 2 push(2) push( n + 1) push( n + 2) pop() push(1) pop() pop() op W 1 W n W n + 1 R 1 R i R n + 1 . . . . . . . . . . . . . . . . . . . . . . . . op W 1 W n R 1 R i W n + 1 R n + 1 push(2) push( n + 1) push(1) pop() pop() push( n + 2) pop() 1 13 / 21
Stack is not Exact Order Type 1 push(2) push( n + 1) push( n + 2) push(1) pop() pop() pop() op W 1 W n W n + 1 R 1 R i R n + 1 . . . . . . . . . . . . . . . . . . . . . op W n + 1 R n + 1 W 1 W n R 1 R i push(2) push( n + 1) push(1) pop() pop() push( n + 2) pop() 1 13 / 21
Stack is not Exact Order Type. Construction W ( n ) W ( n ) s ℓ s ℓ . . . . . . 14 / 21
Stack is not Exact Order Type. Construction push( a ) push ( b ) W ( n ) ◦ W n + 1 W ( n ) ◦ op a b s ℓ s ℓ . . . . . . 14 / 21
Stack is not Exact Order Type. Construction push ( b ) W ( n ) ◦ W n + 1 ◦ op W ( n ) ◦ op b a b s ℓ s ℓ . . . . . . 14 / 21
Stack is not Exact Order Type. Construction W ( n ) ◦ W n + 1 ◦ op ◦ R ( x ) W ( n ) ◦ op ◦ R ( x ) . . . b . . . a b s ℓ s ℓ . . . . . . 14 / 21
Stack is not Exact Order Type. Construction W ( n ) ◦ op ◦ R ( y − 1 ) W ( n ) ◦ W n + 1 ◦ op ◦ R ( y − 1 ) b a b s ℓ s ℓ . . . . . . 14 / 21
Stack is not Exact Order Type. Construction W ( n ) ◦ W n + 1 ◦ op ◦ R ( y ) W ( n ) ◦ op ◦ R ( y ) a s ℓ s ℓ . . . . . . 14 / 21
Stack is not Exact Order Type. Construction push ( a ) W ( n ) ◦ W n + 1 ◦ op ◦ R ( y ) W ( n ) ◦ op ◦ R ( y ) ◦ W n + 1 a a s ℓ s ℓ . . . . . . 14 / 21
Outline Helping Original proof. Refutation Correct proof Conclusion 15 / 21
Proof Theorem 5 Stack does not have a wait-free help-free implementation in a system with at least three processes and with compare&swap primitive. ◮ Programs: ◮ first process — push ( 1 ) ◮ second process — push ( 2 ) ◦ push ( 3 ) ◦ . . . ◮ third process — pop () ◦ pop () ◦ . . . ◮ We build a history in which the first process makes infinite number of steps, but never finishes. 16 / 21
Proof. History Construction 1 h ← ǫ 2 op 1 ← push(1) 3 id 2 ← 2 4 while true: op 2 ← push( id 2 ) 5 while true: 6 if op 1 is not decided before op 2 in h ◦ p 1 : 7 h ← h ◦ p 1 8 continue 9 if op 2 is not decided before op 1 in h ◦ p 2 : 10 h ← h ◦ p 2 11 continue 12 break 13 h ← h ◦ p 2 14 h ← h ◦ p 1 15 while op 2 is not completed: 16 h ← h ◦ p 2 17 id 2 ← id 2 + 1 18 17 / 21
Proof. History Construction push(1) 1 h ← ǫ p 1 2 op 1 ← push(1) 3 id 2 ← 2 p 2 . . . 4 while true: push(2) push(3) push( id 2 ) op 2 ← push( id 2 ) 5 while true: 6 if op 1 is not decided before op 2 in h ◦ p 1 : 7 h ← h ◦ p 1 8 continue 9 if op 2 is not decided before op 1 in h ◦ p 2 : 10 h ← h ◦ p 2 11 continue 12 break 13 h ← h ◦ p 2 14 h ← h ◦ p 1 15 while op 2 is not completed: 16 h ← h ◦ p 2 17 id 2 ← id 2 + 1 18 17 / 21
Proof. History Construction push(1) 1 h ← ǫ p 1 2 op 1 ← push(1) 3 id 2 ← 2 p 2 . . . 4 while true: push(2) push(3) push( id 2 ) op 2 ← push( id 2 ) 5 while true: 6 if op 1 is not decided before op 2 in h ◦ p 1 : 7 h ← h ◦ p 1 8 continue 9 if op 2 is not decided before op 1 in h ◦ p 2 : 10 h ← h ◦ p 2 11 continue 12 break 13 h ← h ◦ p 2 14 h ← h ◦ p 1 15 while op 2 is not completed: 16 h ← h ◦ p 2 17 id 2 ← id 2 + 1 18 17 / 21
Proof. History Construction push(1) 1 h ← ǫ p 1 2 op 1 ← push(1) 3 id 2 ← 2 p 2 . . . 4 while true: push(2) push(3) push( id 2 ) op 2 ← push( id 2 ) 5 while true: 6 if op 1 is not decided before op 2 in h ◦ p 1 : 7 h ← h ◦ p 1 8 continue 9 if op 2 is not decided before op 1 in h ◦ p 2 : 10 h ← h ◦ p 2 11 continue 12 break 13 h ← h ◦ p 2 14 h ← h ◦ p 1 15 while op 2 is not completed: 16 h ← h ◦ p 2 17 id 2 ← id 2 + 1 18 17 / 21
Proof. History Construction push(1) 1 h ← ǫ p 1 2 op 1 ← push(1) 3 id 2 ← 2 p 2 . . . 4 while true: push(2) push(3) push( id 2 ) op 2 ← push( id 2 ) 5 while true: 6 if op 1 is not decided before op 2 in h ◦ p 1 : 7 h ← h ◦ p 1 8 continue 9 if op 2 is not decided before op 1 in h ◦ p 2 : 10 h ← h ◦ p 2 11 continue 12 break 13 h ← h ◦ p 2 14 h ← h ◦ p 1 15 while op 2 is not completed: 16 h ← h ◦ p 2 17 id 2 ← id 2 + 1 18 17 / 21
Proof. History Construction push(1) 1 h ← ǫ p 1 2 op 1 ← push(1) 3 id 2 ← 2 p 2 . . . 4 while true: push(2) push(3) push( id 2 ) op 2 ← push( id 2 ) 5 while true: 6 if op 1 is not decided before op 2 in h ◦ p 1 : 7 h ← h ◦ p 1 8 continue 9 if op 2 is not decided before op 1 in h ◦ p 2 : 10 h ← h ◦ p 2 11 continue 12 break 13 h ← h ◦ p 2 14 h ← h ◦ p 1 15 while op 2 is not completed: 16 h ← h ◦ p 2 17 id 2 ← id 2 + 1 18 17 / 21
Proof. History Construction push(1) 1 h ← ǫ p 1 . . . 2 op 1 ← push(1) c&s 3 id 2 ← 2 p 2 . . . . . . 4 while true: push(2) push(3) push( id 2 ) op 2 ← push( id 2 ) 5 while true: 6 if op 1 is not decided before op 2 in h ◦ p 1 : 7 h ← h ◦ p 1 8 continue 9 if op 2 is not decided before op 1 in h ◦ p 2 : 10 h ← h ◦ p 2 11 continue 12 break 13 h ← h ◦ p 2 14 h ← h ◦ p 1 15 while op 2 is not completed: 16 h ← h ◦ p 2 17 id 2 ← id 2 + 1 18 17 / 21
Proof. History Construction push(1) 1 h ← ǫ p 1 . . . 2 op 1 ← push(1) 3 id 2 ← 2 p 2 . . . . . . 4 while true: c&s push(2) push(3) push( id 2 ) op 2 ← push( id 2 ) 5 while true: 6 if op 1 is not decided before op 2 in h ◦ p 1 : 7 h ← h ◦ p 1 8 continue 9 if op 2 is not decided before op 1 in h ◦ p 2 : 10 h ← h ◦ p 2 11 continue 12 break 13 h ← h ◦ p 2 14 h ← h ◦ p 1 15 while op 2 is not completed: 16 h ← h ◦ p 2 17 id 2 ← id 2 + 1 18 17 / 21
Recommend
More recommend