# distributed systems: distributed algorithms

Post on 08-Feb-2016

76 views

Category:

## Documents

Tags:

• #### mif x y

Embed Size (px)

DESCRIPTION

Distributed Systems: Distributed algorithms. Overview of chapters. Introduction Co-ordination models and languages General services Distributed algorithms Ch 10 Time and global states, 11.4-11.5 Ch 11 Coordination and agreement, 12.1-12.5 Shared data Building distributed services. - PowerPoint PPT Presentation

TRANSCRIPT

• Distributed Systems: Distributed algorithms

Distributed systems: distributed algorithms

• Overview of chaptersIntroductionCo-ordination models and languagesGeneral servicesDistributed algorithmsCh 10 Time and global states, 11.4-11.5Ch 11 Coordination and agreement, 12.1-12.5Shared dataBuilding distributed services

Distributed systems: distributed algorithms

• This chapter: overviewIntroductionLogical clocksGlobal statesFailure detectorsMutual exclusionElectionsMulticast communicationConsensus and related problems

Distributed systems: distributed algorithms

• Logical clocksProblem: ordering of eventsrequirement for many algorithmsphysical clocks cannot be useduse causality:within a single process: observationbetween different processes: sending of a message happens before receiving the same message

Distributed systems: distributed algorithms

• Logical clocks (cont.)Formalization: happens before relation

Rules: if x happens before y in any process p then x y for any message m: send (m) receive (m)if x y and y z then x z Implementation: logical clocksx y

Distributed systems: distributed algorithms

• Logical clocks (cont.)Logical clockcounter appropriately incrementedone counter per process

Physical clockcounts oscillations occurring in a crystal at a definitive frequency

Distributed systems: distributed algorithms

• Logical clocks (cont.)Rules for incrementing local logical clockfor each event (including send) in process p: Cp := Cp + 1when a process sends a message m, it piggybacks on m the value of Cpon receiving (m, t), a process qcomputes Cq := max (Cq, t)applies rule 1: Cq := Cq +1Cq is logical time for event receive(m)

Distributed systems: distributed algorithms

• Logical clocks (cont.)Logical timestamps: example

Distributed systems: distributed algorithms

• Logical clocks (cont.)C(x) logical clock value for event x

Correct usage: if x y then C(x) < C(y)

Incorrect usage: if C(x) < C(y) then x y Solution: Logical vector clocks

Distributed systems: distributed algorithms

• Logical clocks (cont.)Vector clocks for N processes:at process Pi: Vi[j] for j = 1, 2,,NProperties: if x y then V(x) < V(y)

if V(x) < V(y) then x y

Distributed systems: distributed algorithms

• Logical clocks (cont.)Rules for incrementing logical vector clockfor each event (including send) in process Pi: Vi[i] := Vi[i] + 1when a process Pi sends a message m, it piggybacks on m the value of Vion receiving (m, t), a process Piapply rule 1Vi[j] := max(Vi[j] , t[j]) for j = 1, 2,, N

Distributed systems: distributed algorithms

• Logical clocks (cont.)Logical vector clocks : example

Distributed systems: distributed algorithms

• This chapter: overviewIntroductionLogical clocksGlobal statesFailure detectorsMutual exclusionElectionsMulticast communicationConsensus and related problems

Distributed systems: distributed algorithms

• Global statesDetect global properties

Distributed systems: distributed algorithms

• Global states (cont.)Local states & eventsProcess Pi : eik events sik state, before event kHistory of Pi : hi = < ei0, ei1, ei2,> Finite prefix of history of Pi : hik = < ei0, ei1, ei2,, eik >

Distributed systems: distributed algorithms

• Global states (cont.)Global states & eventsGlobal history H = h1 h2 h3 hn Global state (when?) S = ( s1p, s2q, , snu) consistent?Cut of the systems execution C = h1c1 h1c2 h1cn

Distributed systems: distributed algorithms

• Global states (cont.)Example of cuts:

Distributed systems: distributed algorithms

• Global states (cont.)Finite prefix of history of Pi : hik = < ei0, ei1, ei2,, eik >Cut of the systems execution C = h1c1 h1c2 h1cn

Consistent cut C e C, f e f CConsistent global state corresponds to consistent cut

Distributed systems: distributed algorithms

• Global states (cont.)Model execution of a (distributed) system S0 S1 S2 S3 Series of transitions between consistent statesEach transition corresponds to one single eventInternal eventSending messageReceiving messageSimultaneous events order events

Distributed systems: distributed algorithms

• Global states (cont.)Definitions:Run = ordering of all events (in a global history) consistent with each local historys orderingLinearization = consistent run + consistent with S reachable from S linearization: S S

Distributed systems: distributed algorithms

• Global states (cont.)Kinds of global state predicates:Stable Safety

Liveness = true in SS, S S = true in S = undesirable propertyS0 = initial state of systemS, S0 S = false in S = desirable propertyS0 = initial state of systemS, S0 S = true in S

Distributed systems: distributed algorithms

• Global states (cont.)Snapshot algorithm of Chandy & LamportRecord consistent global stateAssumptions:Neither channels nor processes failChannels are unidirectional and provide FIFO-ordered message deliveryGraph of channels and processes is strongly connectedAny process may initiate a global snapshotProcess may continue their execution during the snapshot

Distributed systems: distributed algorithms

• Global states (cont.)Snapshot algorithm of Chandy & LamportElements of algorithmPlayers: processes Pi withIncoming channelsOutgoing channelsMarker messages2 rulesMarker receiving ruleMarker sending ruleStart of algorithmA process acts as it received a marker message

Distributed systems: distributed algorithms

• Global states (cont.)Marker receiving rule for process pi On pis receipt of a marker message over channel c:if (pi has not yet recorded its state) itrecords its process state now;records the state of c as the empty set;turns on recording of messages arriving over other incoming channels;else pi records the state of c as the set of messages it has received over c since it saved its state.end if

Marker sending rule for process piAfter pi has recorded its state, for each outgoing channel c: pi sends one marker message over c (before it sends any other message over c).

Distributed systems: distributed algorithms

• Global states (cont.)Example:

Distributed systems: distributed algorithms

• Global states (cont.)

(M = marker message)

Distributed systems: distributed algorithms

• Global states (cont.)

(M = marker message)

Distributed systems: distributed algorithms

• Global states (cont.)Observed stateCorresponds to consistent cutReachable!

Distributed systems: distributed algorithms

• This chapter: overviewIntroductionLogical clocksGlobal statesFailure detectorsMutual exclusionElectionsMulticast communicationConsensus and related problems

Distributed systems: distributed algorithms

• Failure detectorsPropertiesUnreliable failure detector: answers withSuspectedUnsuspectedReliable failure detector: answers withFailedUnsuspectedImplementationEvery T sec: multicast by P of P is hereMaximum on message transmission time:Asynchronous system: estimate ESynchronous system: absolute bound A

Distributed systems: distributed algorithms

• This chapter: overviewIntroductionLogical clocksGlobal statesFailure detectorsMutual exclusionElectionsMulticast communicationConsensus and related problems

Distributed systems: distributed algorithms

• Mutual exclusionProblem: how to give a single process temporarily a privilege?Privilege = the right to access a (shared) resourceresource = file, device, window,Assumptionsclients execute the mutual exclusion algorithmthe resource itself might be managed by a serverReliable communication

Distributed systems: distributed algorithms

• Mutual exclusion (cont.)Basic requirements:ME1: at most one process might execute in the shared resource at any time (Safety)ME2: a process requesting access to the shared resource is eventually granted it (Liveness)ME3: Access to the shared resource should be granted in happened-before order (Ordering or fairness)

Distributed systems: distributed algorithms

• Mutual exclusion (cont.)Solutions:central server algorithmdistributed algorithm using logical clocksring-based algorithmvoting algorithmEvaluationBandwidth (= #messages to enter and exit)Client delay (incurred by a process at enter and exit)Synchronization delay (delay between exit and enter)

Distributed systems: distributed algorithms

• Mutual exclusion (cont.) central server algorithmCentral server offering 2 operations:enter()if resource free then operation returns without delay else request is queued and return from operation is delayedexit()if request queue is empty then resource is marked free else return for a selected request is executed

Distributed systems: distributed algorithms

• Mutual exclusion (cont.) central server algorithmExample:

Distributed systems: distributed algorithms

• Mutual exclusion (cont.) central server algorithmExample: Server Queue: P1P2P3P4User3Enter()

Distributed systems: distributed algorithms

• Mutual exclusion (cont.) central server algorithmExample: Server Queue: P1P2P3P4User3

Distributed systems: distributed algorithms

• Mutual exclusion (cont.) central server algorithmExample: Server Queue: P1P2P3P4User3enter()

Distributed systems: distributed algorithms

• Mutual exclusion (cont.) central server