Step contention

Computing with Reads and Writes in
the Absence of Step Contention
Hagit Attiya
Department of
Computer Science
Technion
© 2005 P. Kouznetsov
Rachid Guerraoui
Petr Kouznetsov
School of Computer and
Communication Sciences
EPFL
How to implement a concurrent system
using reads and writes



Traditional lock-based solutions are
inefficient (deadlocks)
Traditional lock-free solutions are expensive
(strong synchronization primitives, failure
detectors)
Exploiting the absence of step contention
Obstruction-free
Solo-fast
2
Outline

Background
Lock-free computing

Contribution
Step contention
Obstruction-free implementations
Solo-fast implementations

Perspectives
3
Lock-free distributed computing
Given a distributed shared memory system
with certain base objects, which objects
can be implemented lock-free ?
[Lamport, 1978]
4
Implementing an object
Devise a distributed algorithm that, using base
(hardware) objects, provides an illusion of
the object implemented in a hardware
ok
enq(1)
p1
enq(0)
p2
deq()
1
deq()
0
p3
5
Safety
Linearizability: every operation appears
instantaneously between its invocation and
response events
ok
enq(1)
p1
enq(0)
p2
deq()
1
deq()
0
p3
6
Liveness
Ideally, wait-freedom : any process
completes any operation, regardless of
the behavior of other processes
?
7
Register base objects
(usually available)
W
R
p1
p2
W
R
W
R
p3
8
Any object from registers?
Wait-free consensus from reads and
writes is impossible
[Fischer et al., 1985], [Dolev et al., 1987]
[Loui and Abu-Amara, 1987], [Herlihy, 1991]
Why consensus?
1. Universal
2. Indispensable
Why impossible?
Steps of concurrent
processes interleave
9
How to achieve wait-freedom
1.
Failure
detectors
2.
Complex
Expensive
Wait-freedom
& Linearizability
Registers
Powerful base
objects
Progress for
everyone?
10
Progress for lucky ones
Guarantee progress only when you run
alone, i.e., encounter no contention (the
most common case in practice)
[Herlihy et al., ICDCS 2003, DISC 2003]
11
Outline

Background
Lock-free computing using reads and
writes

Contribution
Step contention
Obstruction-free implementations
Solo-fast implementations

Perspectives
12
Step contention
The step contention of an execution fragment is the
number of processes that take steps in the
fragment’s interval
The interval contention counts the number of
operations
p1
i
SC(i,r)=2
IC(i,r)=3
SC(i’,r’)=1
IC(i’,r’)=2
r
p2
p3
i’
r’
13
Solo termination [Fich et al., 1998]
Every operation that eventually
encounters no step contention must
return
i
r
p1
p2
p3
14
Using interval contention?
[Luchangco et al., 2003]


When there is no interval contention:
terminate using only reads and writes
When there is interval contention terminate
using hardware C&S
Constant in time and space!
But not much different from lock-based 
15
When there is step contention
1.
2.
Keep trying
(obstruction-free)
Use “expensive” primitives
(solo-fast)
16
Outline

Background
Lock-free computing

Contribution
Step contention
Obstruction-free implementations
Solo-fast implementations

Concluding remarks
17
Obstruction-free interface
invocation
response
wait
Obstruction-free
object
fail
wait = might have taken effect
fail = did not take effect
18
Returning control in case of contention
Wait and try again later
i
wait
wait
r
p1
p2
p3
19
Returning control in case of contention
Abort the operation
i
wait
fail
p1
p2
p3
20
Only fail?
invocation
response
Obstruction-free
object
fail (no effect)
Transaction-like operations?
21
Only fail?
One “only-fail” consensus object C and one
registers R can be used to implement 2process wait-free consensus
Code for p1:
propose(v1)
x1 := C.propose(v1)
if x1=fail then
x1:=R
return x1
Code for p2:
propose(v2)
R := v2
repeat
x2=C.propose(v2)
until x2 <> fail
return x2
22
Obstruction-free objects do exist!
Registers

OF & linearizable
implecmentation
of any object
Time complexity
There is a step contention-free operation that takes Ω(n)
steps

Space complexity
Ω(n) of registers are used
And this is optimal! (reduction to [Jayanti et al., 2000])
23
Gracefull degradation?
Registers only
Ω + registers
WF consensus
OF consensus
Gracefully degrading consensus?
 WF if Ω «behaves well»
 OF otherwise
Not possible
(reduction to [LA87, DDS87, Her91])
24
Outline

Background
Lock-free computing

Contribution
Step contention
Obstruction-free algorithms
Solo-fast implementations

Perspectives
25
Solo-fast implementations
if no step contention detected then
use registers to terminate
else
use “expensive” primitives to terminate
Solo-fast implementation of any object: linear
in time and space (seems to be optimal)
26
Bottom line
Inefficient
Lock-based
solutions
Obstruction-free & solo-fast
implementations:
- For any object
- Linear in time and space
Expensive
Wait-free
solutions
Inherently
expensive?
27
Perspectives



Complexity of obstruction-free
consensus (at least nonconstant)
Complexity of solo-fast
implementations (using slightly
more powerful primitives on a
fast path)
Optimal contention management
28
Thank you!
29