Download presentation
Presentation is loading. Please wait.
Published byCordelia Nelson Modified over 8 years ago
2
Lecture 10: Coordination and Agreement (Chap 12) Haibin Zhu, PhD. Assistant Professor Department of Computer Science Nipissing University © 2002
3
2 Contents Introduction Distributed mutual exclusion Elections Multicast communication
4
3 Introduction This chapter covers other types of coordination and agreement such as mutual exclusion, elections and consensus. Failure assumptions: –a network partition –Asymmetric –Intransitive: Failure detector: a service that processes query about a particular process has failed. –Unreliable: unsuspected or suspected –Reliable: unsuspected or failed
5
4 Figure 11.1 A network partition A collection of processes is split into several groups that cannot communicate.
6
5 Unreliable failure detector “p is here” to all others per Ts; D is the maximum time of message transmission. If q.detector does not receive a “p is here” within T+Ds, reports “p is suspected”
7
6 Distributed mutual exclusion Critical section: –Enter() –ResourceAccesses() –Exit() Mutual exclusion –ME1: (safety) At most one is executing in the critical section at a time. –ME2: ( liveness) Requests eventually succeed. –ME3: (-> ordering) Happened-before is granted at entries for requests. Evaluation: –Bandwidth –Client delay –Synchronization delay
8
7 Algorithms The Central Server Algorithm –Send a request to a server to get a token. A ring-based algorithm –A token is created somewhere. An algorithm using multicast and logical clocks –(Ricart and Agrawala’s algorithm) –Multicast a request –When all others reply, it can enter.
9
8 The Central Server Algorithm ME1:OK ME2:OK ME3: No Send a request to a server to get a token. If the token is available, the request is granted. Else the request is queued.
10
9 A ring of processes transferring a mutual exclusion token ME1:OK ME2:OK ME3: No A token is created somewhere. The token is turn around in a logical ring. If the process need to access the shared resource, take it and use it. Else turn it in to the next process.
11
10 Ricart and Agrawala’s algorithm On initialization state := RELEASED; To enter the section state := WANTED; Multicast request to all processes;request processing deferred here T := request’s timestamp; Wait until (number of replies received = (N – 1)); state := HELD; On receipt of a request at p j (i ≠ j) if (state = HELD or (state = WANTED and (T, p j ) < (T i, p i ))) then queue request from p i without replying; else reply immediately to p i ; end if To exit the critical section state := RELEASED; reply to any queued requests;
12
11 Figure 11.5 Multicast synchronization p 3 34 Reply 34 41 34 p 1 p 2 Reply ME1:OK ME2:OK ME3: OK
13
12 Elections Choosing a unique process to play a particular role. –Is called an election Requirements (┴ means not yet defined) –E1: (safety) A particular process p i has elected i = ┴ or elected i =P, where P is chosen as the non-crashed process at the end of the run with the largest identifier. –E2: (liveness) Every process p i participates and eventually sets elected i ≠┴ or crash.
14
13 Algorithms A ring-based election algorithm –Send a election message –If get a message, compare the ID, if greater, forward; if less, substitute the ID and forward; –If the ID is the same, send a “coordinator” message.
15
14 A ring-based election in progress Note: The election was started by process 17. The highest process identifier encountered so far is 24. Participant processes are shown darkened E1: OK E2: OK Tolerates no failure
16
15 The bully algorithm Synchronous, the upper bound for message response is T = 2T trans +T process Pi knows which are higher; Messages: –Election –Answer –Coordinator Send a election message, If timeout (>T), sends another coordinator message; The process elects itself if it is the highest, sends the coordinator message The process getting a election message sends an answer and other election messages.
17
16 Figure 11.8 The bully algorithm The election of coordinator p 2, after the failure of p 4 and then p 3 E1: OK? No if a crashed process is replaced. There are might be two coordinator messages. E2: OK
18
17 Revision of IP multicast (section 4.5.1 page154) IP multicast – an implementation of group communication –built on top of IP (note IP packets are addressed to computers) –allows the sender to transmit a single IP packet to a set of computers that form a multicast group (a class D internet address with first 4 bits 1110) –Dynamic membership of groups. Can send to a group with or without joining it –To multicast, send a UDP datagram with a multicast address –To join, make a socket join a group (s.joinGroup(group) - Fig 4.17) enabling it to receive messages to the group Multicast routers –Local messages use local multicast capability. Routers make it efficient by choosing other routers on the way. Failure model –Omission failures some but not all members may receive a message. e.g. a recipient may drop message, or a multicast router may fail –IP packets may not arrive in sender order, group members can receive messages in different orders
19
18 Introduction to multicast Multicast communication requires coordination and agreement. The aim is for members of a group to receive copies of messages sent to the group Many different delivery guarantees are possible –e.g. agree on the set of messages received or on delivery ordering A process can multicast by the use of a single operation instead of a send to each member –For example in IP multicast aSocket.send(aMessage) –The single operation allows for: efficiency I.e. send once on each link, using hardware multicast when available, e.g. multicast from a computer in Toronto to two in Beijing delivery guarantees e.g. can’t make a guarantee if multicast is implemented as multiple sends and the sender fails. Ordering is also a problem.
20
19 System model The system consists of a collection of processes which can communicate reliably over 1-1 channels Processes fail only by crashing (no arbitrary failures) Processes are members of groups - which are the destinations of multicast messages In general, process p can belong to more than one group Operations –multicast(g, m) sends message m to all members of process group g –deliver (m) is called to get a multicast message delivered. It is different from receive as it may be delayed to allow for ordering or reliability. Multicast message m carries the id of the sending process sender(m) and the id of the destination group(m) We assume there is no falsification of the origin and destination of messages
21
20 Open and closed groups Closed groups –only members can send to group, a member delivers to itself –they are useful for coordination of groups of cooperating servers Open –they are useful for notification of events to groups of interested processes Figure 11.9 Does IP multicast support open and closed groups?
22
21 Reliability of one-to-one communication(Ch.2 page 57) The term reliable 1-1 communication is defined in terms of validity and integrity as follows: validity : –any message in the outgoing message buffer is eventually delivered to the incoming message buffer; integrity : –the message received is identical to one sent, and no messages are delivered twice. How do we achieve validity? integrity by use checksums, reject duplicates (e.g. due to retries). If allowing for malicious users, use security techniques How do we achieve integrity? validity - by use of acknowledgements and retries
23
22 11.4.1 Basic multicast A correct process will eventually deliver the message provided the multicaster does not crash –note that IP multicast does not give this guarantee The primitives are called B-multicast and B-deliver A straightforward but ineffective method of implementation: –use a reliable 1-1 send (i.e. with integrity and validity as above) To B-multicast(g,m): for each process p g, send(p, m); On receive (m) at p: B-deliver (m) at p Problem –if the number of processes is large, the protocol will suffer from ack-implosion A practical implementation of Basic Multicast may be achieved over IP multicast.
24
23 11.4.2 Reliable multicast The protocol is correct even if the multicaster crashes it satisfies criteria for validity, integrity and agreement it provides operations R-multicast and R-deliver Integrity - a correct process, p delivers m at most once. Also p group(m) and m was supplied to a multicast operation by sender(m) Validity - if a correct process multicasts m, it will eventually deliver m Agreement - if a correct process delivers m then all correct processes in group(m) will eventually deliver m integrity as for 1-1 communication validity - simplify by choosing sender as the one process agreement - all or nothing - atomicity, even if multicaster crashes
25
24 Reliable multicast algorithm over basic multicast processes can belong to several closed groups Figure 11.10 primitives R-multicast and R-deliver to R-multicast a message, a process B-multicasts it to processes in the group including itself when a message is B-delivered, the recipient B-multicasts it to the group, then R-delivers it. Duplicates are detected. Validity - a correct process will B-deliver to itself Integrity - because the reliable 1-1 channels used for B-multicast guarantee integrity Agreement - every correct process B-multicasts the message to the others. If p does not R-deliver then this is because it didn’t B-deliver - because no others did either.
26
25 Summary Mutual exclusion –Central server –Ring-based –Using multicast Elections –Ring-based –Bully Multicast communication can specify requirements for reliability and ordering, in terms of integrity, validity and agreement
27
26 Summary B-multicast –a correct process will eventually deliver a message provided the multicaster does not crash reliable multicast –in which the correct processes agree on the set of messages to be delivered; –we showed two implementations: over B-multicast and IP multicast
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.