90 likes | 101 Views
Distributed Algorithms (22903). Approximate agreement. Lecturer: Danny Hendler. This presentation is based on the book “Distributed Computing” by Hagit attiya & Jennifer Welch. Approximate Agreement. Wait-freedom : Eventually, each nonfaulty process decides.
E N D
DistributedAlgorithms (22903) Approximate agreement Lecturer: Danny Hendler This presentation is based on the book “Distributed Computing” by Hagit attiya & Jennifer Welch.
Approximate 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.
Approximate Agreement Algorithm:assuming 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 log2D/rounds
Program for process i • For r = 1 to to M • updatei(ASO[r], v) ;update v’s entry in the r’th snapshot object • values[r] := scan(ASO[r]) ;take the r’th snapshot • v := midpoint(values[r]) ;adjust estimate • return v Approximate Agreement Algorithm (cont’d) Constant: M= max( log2 (D/) ,1) Shared:Snapshot ASO[M] initialized to emptyLocal:int v;this is pi's estimate, initialized with pi’s input int r ;this is the asynchronous round number values[M];array to store snapshots taken in M rounds
Correctness proof Lemma 1: Consider any round r < M. There exists a value, u, such that the values written to ASO[r+1] are in this range: u min(Ur) (min(Ur)+u)/2 (max(Ur)+u)/2 max(Ur) elements of Ur+1 are in this range
Handling 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.
Handling 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
Approximate Agreement Algorithm (unknown inputs range) Shared:Snapshot S, each entry is of the form <x,r,v>, initially emptyLocal:int v ;this is pi’s estimate, initialized with pi’s input int rmax;this is maximal round number I saw values ;a set of numbers • Program for process i • S.updatei(<x,1,x>) ;estimate in round 1 is my value • repeat • <x0,r0,v0>,…,<xn-1,rn-1,vn-1> := S.scan() ;take a snapshot • maxRound := max(log2(spread(x0,…xn-1)/ε), 1) • rmax:= max{r0,…,rn-1} ;maximal round number I saw so far • values := {vj | rj = rmax, 0 ≤j ≤n-1} ;only consider maximal round • S.updatei(<x, rmax+1, midpoint(<values>)) ;skip to rmax+1 round • until rmax ≥ maxRound ;until ε -agreement is guaranteed • return midpoint(values)
The algorithm is a correct wait-free implementation of approximate-agreement