Title: Problems solvable in asynchronous systems by using readswrites
1Problems solvable in asynchronous systems by
using reads/writes
Multiprocessor synchronization algorithms
(20225241)
Lecturer Danny Hendler
Based on the book Distributed Computing, by
Hagit Attiya Jennifer Welch
2Problems solvable in a wait-free manner in
asynchronous systems
- Although consensus is not solvable in a
wait-free manner, there are some interesting
problems that are - approximate agreement
- set consensus
- renaming
- k-exclusion
3Approximate Agreement
- Wait-freedom Eventually, each nonfaulty process
decides. - ?-Agreement All decisions are within ? of each
other. - Validity All decisions are within the range of
the input values.
4Approximate Agreement Algorithmassuming input
range is known
- Assume processes know the range from which input
values are drawn - let D be the length of this range
- algorithm is structured as a series of
"asynchronous rounds" - exchange values via a snapshot object, one per
round - compute midpoint for next round
- continue until spread of values is within ?,
which requires about log2 D/? rounds
5Approximate Agreement Algorithm (contd)
Constant M max( ?log2 (D/?)? ,1) Shared
Snapshot ASOM initialized to emptyLocal int v
this is pis estimate, initialized with pis
input int r this is the asynchronous
round number valuesM array to store
snapshots taken in M rounds
6Correctness proof
- Lemma 1 Consider any round r lt M. There exists
a value, u, such that the values written to
ASOr1 are in this range
u
min(Ur)
max(Ur)
(min(Ur)u)/2
(max(Ur)u)/2
elements of Ur1 are in this range
7Handling Unknown Input Range
- Range might not be known.
- Actual range in an execution might be much
smaller than maximum possible range, so number of
rounds may be reduced.
8Handling Unknown Input Range
- Use just one atomic snapshot object
- Dynamically recalculate how many rounds are
needed as more inputs are revealed - Skip over rounds to try to catch up to maximum
observed round - Only consider values associated with maximum
observed round - Still use midpoint
9Approximate Agreement Algorithm (unknown inputs
range)
Shared Snapshot S, each entry is of the form
ltx,r,vgt, initially emptyLocal int v this is
pis estimate, initialized with pis input
int rmax this is maximal round number I saw
values a set of numbers
- Program for process i
- S.updatei(ltx,1,xgt) estimate in round 1 is my
value - repeat
- ltx0,r0,v0gt,,ltxn-1,rn-1,vn-1gt S.scan()
take a snapshot - maxRound max(log2(spread(x0,xn-1)/e), 1)
- rmax maxr0,,rn-1 maximal round number I
saw so far - values vj rj rmax, 0 j n-1 only
consider maximal round - S.updatei(ltx, rmax1, midpoint(ltvaluesgt))
skip to rmax1 round - until rmax maxRound until e -agreement is
guaranteed - return midpoint(values)
10- The algorithm is a correct wait-free
implementation of approximate-agreement
11Renaming
- Processes start with unique names from a large
domain - Processes should pick new names that are still
distinct but that are from a smaller domain - Motivation Suppose original names are serial
numbers (many digits), but we'd like the
processes to do some kind of time slicing based
on their ids
12Renaming Problem Definition
- Termination Eventually every nonfaulty proc pi
decides on a new name yi - Uniqueness If pi and pj are distinct nonfaulty
procs, then yi ? yj. - Anonymity Processes cannot directly use their
index, only their name.
13Performance of Renaming Algorithm
- New names should be drawn from 1,2,,M.
- We would like M to be as small as possible.
- Uniqueness implies M must be at least n.
- Due to the possibility of failures, M will
actually be larger than n.
14Renaming Results
- Algorithm for wait-free case (f n - 1) with M
n f 2n - 1. - Algorithm for general f with M n f.
- Lower bound that M must be at least n 1, for
the wait-free case. - Proof similar to impossibility of wait-free
consensus - Stronger lower bound that M must be at least n
f, if f is the number of possible failures - Proof uses algebraic topology and is related to
lower bound for set consensus
15Wait-free renaming algorithm
- Processes communicate via snapshot object
- Each process iteratively stores its original name
and (suggested) new name - If the name suggested by p is taken, it next
suggests the kth free name, where k is its
original rank
16Wait-free renaming algorithm (contd)
Shared Snapshot S, each entry is of the form
ltx,sgt, initially emptyLocal int oldName this
is pis original name int newName
this is pis suggested name, initially 1
- Program for process i
- newName 1 Maybe I can get the smallest name
- While true do While havent fixed my new name
- S.updatei(ltoldName,newNamegt) Announce new
suggestion - ltx0,s0gt,,ltxn-1,sn-1gt S.scan() take a
snapshot - if (newName sj for some j ? i) ouch,
theres a clash select the rth free
name, where r is my rank - let r be the rank of oldName in xj ? empty
0jn-1 - let newName be the rth integer not in sj
? empty 0jn-1 - else
- return newName
17- The algorithm is a correct wait-free
implementation of renaming that requires 2n-1
names
18Renaming a general algorithm
- A renaming algorithm resilient to f failures
- Requires nf new names
- new idea restrict the number of processes that
propose names at the same time.
19F-resilient algorithm
Shared Snapshot S, each entry is of the form
ltx,s, true/falsegt, initially emptyLocal int
oldName this is pis original name
int newName this is pis suggested name,
initially 1
- Program for process i
- newName empty
- While true do While havent fixed my new name
- S.updatei(ltoldName,newName, falsegt)
- ltx0,s0,d0gt,,ltxn-1,sn-1,d0-1gt S.scan()
take a snapshot - if (newName empty or sisj for some j ? i)
- let r be the rank of oldName in xj ? empty
dj false 0jn-1 - if (r f1)
- let newName be the rth integer not in
sj ? empty 0jn-1 - else
- S.updatei(ltoldName,newName, truegt)
- return newName
20- The algorithm is a correct wait-free
implementation of renaming that requires nf names
21K-exclusion
- A weakening of mutual-exclusion. The
- following requirements must be met.
- K-exclusion no more than k processes are
concurrently in the CS - K-lockout-avoidance If at most f lt k processes
are faulty, then any nonfaulty process wishing to
enter the CS eventually does so.
22k-exclusion algorithm
Shared Snapshot S, each entry initialized to 0
- Program for process i
- Ticket0, , ticketn-1S.scan()
- S.Updatei(max ticketj gt 0 j0, , n-1 1)
- Repeat
- ticket0, , ticketn-1 S.scan()
- Until ltticketj, jgt ltticketj, jgt lt ltticketi,
igt lt k - CS
- Updatei(0)