an space bound for obstruction-free leader election
DESCRIPTION
An Space Bound for Obstruction-Free Leader Election. George Giakkoupis , Maryam Helmi , Lisa Higham and Philipp Woelfel DISC 2013. Leader Election. Shared memory with n processors. Atomic multi writer snapshot object. Each process has to decide on one value, win or lose. - PowerPoint PPT PresentationTRANSCRIPT
An Space Bound for Obstruction-Free Leader Election
George Giakkoupis, Maryam Helmi, Lisa Higham and Philipp Woelfel
DISC 2013
Leader Election
• Shared memory with n processors.• Atomic multi writer snapshot object. • Each process has to decide on one value, win or
lose.• Exactly one process (the leader) wins:– At least one process wins– At most one process wins
• Wait free leader election cannot be solved using only read write registers
Obstruction-Freedom
• A deterministic algorithm is obstruction-free, if it guarantees that any process will finish if it performs enough steps alone.
• Obstruction free step complexity- the maximum number of steps until a process taking steps alone finishes.
Obstruction Free Leader Election
• Shared array of registers. • The algorithms proceeds in phases, in each
phase a process writes to • Each registers in contains a pair of process id
and phase number, initialized to zero.
(0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)𝑅Process id Phase #
Obstruction Free Leader Election
(0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)
𝜙=1𝜙=2
(p,1) (p,1)(p,2) (p,2) (p,2)
Phase # Double collect until
equal
Code for process
1While m do r[0..m] = R.scan() if
lose else if (#entries with ( and #entries )
lose else if r[0…] = [(p,),…,(p,)]
else Let be the smallest : r[i](p,)R[i](p,)
EndWin
Not Wait Free
(0,0)
If 2 processes alternate in executing the while loop they never finish the 1st phase
(0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)(1,1)(2,1)(1,1)(2,1)
1While m do r[0..m] = R.scan() if
lose else if (#entries with ( and #entries )
lose else if r[0…] = [(p,),…,(p,)]
else Let be the smallest : r[i](p,)R[i](p,)
EndWin
Obstruction Free Leader Election
Obstruction Free Step Complexity: For each phase at most scan operations, each
scan with step complexity .
1While m do r[0..m] = R.scan() if
lose else if (#entries with ( and #entries )
lose else if r[0…] = [(p,),…,(p,)]
else Let be the smallest : r[i](p,)R[i](p,)
EndWin
Not All Processes Lose• Lemma 1: Not all processes lose.• If all processes lose, let be the last phase.
Last scan of phase , by
lost thus, the orange or purple condition must hold after the
scan
Contradiction to .
The last scan of that caused to
lose
lost thus, the purple condition must hold
after the scan
#entries of Contradiction to
the scan of
(q,) (---,---) (q,) (p,) (---,---) (---,---)
Obstruction Free Leader Election 1While m do r[0..m] = R.scan() if
lose else if (#entries with ( and #entries )
lose else if r[0…] = [(p,),…,(p,)]
else Let be the smallest : r[i](p,)R[i](p,)
EndWin
Observation 1: Only processes in phase write to
Observation 2: If two processes got to phase ( got to phase first), than entries of where written by different processes before the next scan of
Only one wins𝑁 0
𝑁 √𝑛 𝑛√𝑛≅ √𝑛
𝑁 2√𝑛
• the set of processes that participate in phase
Only one wins𝑁 0
𝑁 √𝑛
𝑁 2√𝑛
Lemma 3:
Lemma 2:
Lemma 2:
All entries equal
Each process write to at most once before the scan of , at most processes can write to
At least 2 entries remain equal to , and any process
that scan must lose
() () () () ()() (---,---)()
𝑅 [𝜙 ,…,𝜙+𝑛𝜙 ]
Let be the first process that got to phase
Lemma 3:
• Easy warm up case: • Suppose: 𝑛0−𝑛𝑘=(𝑛0−𝑛1 )+(𝑛1−𝑛2 )…(𝑛𝑘− 1−𝑛𝑘)
𝑘∈𝑂 (√𝑛)
𝑡𝑖 𝑡𝑖′
Lemma 3:
processes entered phase The first extra
process entered phase
The th extra process entered phase
The th extra process entered phase
The last processes entered phase
Lemma 3:
The th extra process entered phase
The th extra process entered phase
equal
At most one entry with before the scan by
() () () () ()() (0,0)()
𝑅 [0 ,…, 𝑖]
Only processes in phase
processes from smaller phases write to
These processes will lose after the write
𝑡𝑖 𝑡𝑖′
Lemma 3:
processes entered phase The first extra
process entered phase
The th extra process entered phase
The th extra process entered phase
The last processes entered phase
-1 processes at phase<lost
-2 processes at phase<lost…
At least processes will lose in the time interval
Time intervals of different phases do not overlapThe total number of processes that will lose is at least
At least processes will lose in the time interval
Lemma 3:
𝑛≥ ∑0≤𝑖 ≤𝜅
𝑑𝑖 (𝑑𝑖−1)2
Lemma 3:
𝑛= ∑0≤𝑖<𝜅
(𝑛𝑖−𝑛𝑖+ 1)+𝑛𝜅≥ ∑0≤𝑖<𝜅
(𝑛𝑖−𝑛𝑖+1)
≥ ∑0≤ 𝑖<𝜅
(𝑖−𝑑𝑖 )= ∑0≤𝑖<𝜅
𝑖− ∑0≤𝑖 ≤𝜅
𝑑𝑖=𝜅(𝜅−1)
2− ∑0≤𝑖 ≤𝜅
𝑑𝑖
Lemma 3:
Lemma 3:
𝑛≥ ∑0≤𝑖 ≤𝜅
𝑑𝑖 (𝑑𝑖−1)2
𝜅∈𝑂 (√𝑛)
.
.
.
Lemma 3:
Wrap Up: Only one wins𝑁 0
𝑁 √𝑛 𝑛√𝑛≅ √𝑛
𝑁 2√𝑛
Lemma 2:
Optimization: Early Termination
• exits the while loop if:– The green condition is satisfied– did not see any other process during phases and .
• Applying this condition, a process finishes after solo steps.
Deterministic to Randomized
Deterministic obstruction-free
algorithm
Randomized wait-free algorithm
• Preserve space complexity
Randomized Model
• Processes can use local coin-flips to make random decisions.
• The scheduling and process crashes are controlled by an oblivious adversary, which determines the entire (infinite) schedule ahead of time.
Randomized Wait-free
• A deterministic algorithm is wait-free if every process finishes in an finite number of its own steps.
• A randomized algorithm is randomized wait-free if every process finishes in an expected finite number of steps.
Deterministic to Randomized
Deterministic obstruction-free
algorithm
Randomized wait-free algorithm
(oblivious adversary)
• Preserve space complexity
Any process finishes after
executing at most b steps without interference
Any process finishes w.h.p.
after O(b(n+b)logn)
steps
Transformation Technique
• Flip a coin in the beginning and after every b steps.
• Each coin flip returns heads with probability , independently.
Execute thenext b steps of the given deterministic algorithm
Execute b dummy steps
Rough Transformation Analysis• Fix the schedule • Order the processes by the order in which
they take their real step. • Look at process , and define disjoint blocks:
real steps of , steps of other process, number of coin flips in the block
Heads
Rough Transformation Analysis
• number of coin flips in the block • At most coin flip outside the block effect the block• Unobstructed block contains real steps only by • The probability of a block to be unobstructed is
≈ (1− 1𝑛 )𝑚𝑏 +(𝑛−1 )
To Sum Up
• We saw a deterministic obstruction-free implementation of leader election using registers.
• We saw a technique to transform any deterministic obstruction free algorithm into a randomized wait free algorithm for the oblivious adversary.