Lecture 11: Coordination and Agreement Central server for mutual exclusion Election – getting a number of processes to agree which is “in charge” CDK4:

Slides:



Advertisements
Similar presentations
CS542 Topics in Distributed Systems Diganta Goswami.
Advertisements

CS 542: Topics in Distributed Systems Diganta Goswami.
CS425 /CSE424/ECE428 – Distributed Systems – Fall 2011 Material derived from slides by I. Gupta, M. Harandi, J. Hou, S. Mitra, K. Nahrstedt, N. Vaidya.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Leader Election Steve Ko Computer Sciences and Engineering University at Buffalo.
Token-Dased DMX Algorithms n LeLann’s token ring n Suzuki-Kasami’s broadcast n Raymond’s tree.
Synchronization Chapter clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed.
Page 1 Mutual Exclusion* Distributed Systems *referred to slides by Prof. Paul Krzyzanowski at Rutgers University and Prof. Mary Ellen Weisskopf at University.
CMPT 401 Summer 2007 Dr. Alexandra Fedorova Lecture IX: Coordination And Agreement.
Distributed Systems Spring 2009
CS 582 / CMPE 481 Distributed Systems
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Distributed Snapshots –Termination detection Election algorithms –Bully –Ring.
1. Explain why synchronization is so important in distributed systems by giving an appropriate example When each machine has its own clock, an event that.
Distributed Systems Fall 2009 Coordination and agreement, Multicast, and Message ordering.
Synchronization Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
Computer Science Lecture 11, page 1 CS677: Distributed OS Last Class: Clock Synchronization Logical clocks Vector clocks Global state.
CS603 Process Synchronization February 11, Synchronization: Basics Problem: Shared Resources –Generally data –But could be others Approaches: –Model.
Synchronization in Distributed Systems. Mutual Exclusion To read or update shared data, a process should enter a critical region to ensure mutual exclusion.
SynchronizationCS-4513, D-Term Synchronization in Distributed Systems CS-4513 D-Term 2007 (Slides include materials from Operating System Concepts,
Synchronization in Distributed Systems CS-4513 D-term Synchronization in Distributed Systems CS-4513 Distributed Computing Systems (Slides include.
Coordination in Distributed Systems Lecture # 8. Coordination Anecdotes  Decentralized, no coordination  Aloha ~ 18%  Some coordinating Master  Slotted.
EEC-681/781 Distributed Computing Systems Lecture 11 Wenbing Zhao Cleveland State University.
Clock Synchronization and algorithm
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms.
Election Algorithms and Distributed Processing Section 6.5.
Election Algorithms. Topics r Issues r Detecting Failures r Bully algorithm r Ring algorithm.
Distributed Mutex EE324 Lecture 11.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Chapter 6 Synchronization.
4.5 DISTRIBUTED MUTUAL EXCLUSION MOSES RENTAPALLI.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Mutual Exclusion Steve Ko Computer Sciences and Engineering University at Buffalo.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms –Bully algorithm.
CS425 /CSE424/ECE428 – Distributed Systems – Fall 2011 Material derived from slides by I. Gupta, M. Harandi, J. Hou, S. Mitra, K. Nahrstedt, N. Vaidya.
Coordination and Agreement. Topics Distributed Mutual Exclusion Leader Election.
CS 425/ECE 428/CSE424 Distributed Systems (Fall 2009) Lecture 8 Leader Election Section 12.3 Klara Nahrstedt.
Synchronization CSCI 4780/6780. Mutual Exclusion Concurrency and collaboration are fundamental to distributed systems Simultaneous access to resources.
Presenter: Long Ma Advisor: Dr. Zhang 4.5 DISTRIBUTED MUTUAL EXCLUSION.
Lecture 11-1 Computer Science 425 Distributed Systems CS 425 / CSE 424 / ECE 428 Fall 2010 Indranil Gupta (Indy) September 28, 2010 Lecture 11 Leader Election.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Mutual Exclusion & Leader Election Steve Ko Computer Sciences and Engineering University.
Exercises for Chapter 15: COORDINATION AND AGREEMENT From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3, © Addison-Wesley.
1.Mutual Exclusion in Distributed Systems 2.Non-Token-Based Algorithms 3.Token-Based Algorithms 4.Distributed Election 5.The Bully and the Ring-Based Algorithms.
Lecture 10: Coordination and Agreement (Chap 12) Haibin Zhu, PhD. Assistant Professor Department of Computer Science Nipissing University © 2002.
Election Distributed Systems. Algorithms to Find Global States Why? To check a particular property exist or not in distributed system –(Distributed) garbage.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Page 1 Mutual Exclusion & Election Algorithms Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content.
Lecture 12-1 Computer Science 425 Distributed Systems CS 425 / CSE 424 / ECE 428 Fall 2012 Indranil Gupta (Indy) October 4, 2012 Lecture 12 Mutual Exclusion.
Lecture 7- 1 CS 425/ECE 428/CSE424 Distributed Systems (Fall 2009) Lecture 7 Distributed Mutual Exclusion Section 12.2 Klara Nahrstedt.
From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design Edition 5, © Addison-Wesley 2012 Slides for Chapter 15: Coordination.
COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 6: Synchronyzation 3/5/20161 Distributed Systems - COMP 655.
Distributed Mutual Exclusion Synchronization in Distributed Systems Synchronization in distributed systems are often more difficult compared to synchronization.
Mutual Exclusion Algorithms. Topics r Defining mutual exclusion r A centralized approach r A distributed approach r An approach assuming an organization.
CSE 486/586 CSE 486/586 Distributed Systems Leader Election Steve Ko Computer Sciences and Engineering University at Buffalo.
CS3771 Today: Distributed Coordination  Previous class: Distributed File Systems Issues: Naming Strategies: Absolute Names, Mount Points (logical connection.
Distributed Systems 14. Coordination in Distributed Systems Simon Razniewski Faculty of Computer Science Free University of Bozen-Bolzano A.Y. 2014/2015.
Distributed Systems Lecture 9 Leader election 1. Previous lecture Middleware RPC and RMI – Marshalling 2.
Revisiting Logical Clocks: Mutual Exclusion Problem statement: Given a set of n processes, and a shared resource, it is required that: –Mutual exclusion.
Distributed Systems 31. Theoretical Foundations of Distributed Systems - Coordination Simon Razniewski Faculty of Computer Science Free University of Bozen-Bolzano.
Slides for Chapter 11: Coordination and Agreement From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3, © Addison-Wesley.
Exercises for Chapter 11: COORDINATION AND AGREEMENT
Coordination and Agreement
CSE 486/586 Distributed Systems Leader Election
Simon Razniewski Faculty of Computer Science
Distributed Mutex EE324 Lecture 11.
Chapter 6.3 Mutual Exclusion
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Outline Distributed Mutual Exclusion Introduction Performance measures
CSE 486/586 Distributed Systems Leader Election
Lecture 10: Coordination and Agreement
Synchronization (2) – Mutual Exclusion
Prof. Leonardo Mostarda University of Camerino
Lecture 11: Coordination and Agreement
CSE 486/586 Distributed Systems Leader Election
Presentation transcript:

Lecture 11: Coordination and Agreement Central server for mutual exclusion Election – getting a number of processes to agree which is “in charge” CDK4: Chapter 12 (esp. Section 12.3) CDK5: Chapter 15 (esp. Section 15.3) TVS: Chapter 6 (esp. Section 6.5)

23-Jun-16COMP28112 Lecture 112 (Distributed) Mutual exclusion In a single machine, you could use semaphores to implement mutual exclusion How to implement semaphores? –Inhibit interrupts –Use clever instructions (e.g. test-and-set) On a multiprocessor shared memory machine, only the latter works On machines which don’t even share memory, need something different The simplest solution is a central server Client requests token on entry, and releases it on exit Server queues requests when it has no token

23-Jun-16COMP28112 Lecture 113 Server managing a mutual exclusion token for processes (CDK Fig 12.2) Server 1. Request token Queue of requests 2. Release token 3. Grant token 4 2 p 4 p 3 p 2 p 1

23-Jun-16COMP28112 Lecture 114 Alternatives …? The server is a single point of failure Also possibly a bottleneck for the system However many very clever, more distributed algorithms are generally worse in terms of number of messages, and have other problems!

23-Jun-16COMP28112 Lecture 115 Election – why? Need a distinguished process: To implement locking/mutual exclusion Or to coordinate distributed transactions Election is also a good introduction to what is involved in getting processes in a distributed system to cooperate.

23-Jun-16COMP28112 Lecture 116 Two Algorithms A ring-based election algorithm The bully algorithm Same scenario: A fixed set of processes: p1 … pn Want to elect the process with the largest identifier – where identifiers are totally ordered, e.g.

23-Jun-16COMP28112 Lecture 117 Requirements Want all processes to agree who is elected i.e. they need to learn the result of the election Any process can initiate an election – so there may be more than one happening at any one time ….

23-Jun-16COMP28112 Lecture 118 Ring-based algorithm Arrange the processes in a logical ring – so each knows which is next in order Assume no failures and system is asynchronous Initially every process is a non-participant Initiating process changes itself to be a participant and sends its identifier in an election message to its neighbour

23-Jun-16COMP28112 Lecture 119 Action on receiving election message Receiver compares its own identifier with that in the message If the identifier in the message is larger it forwards the election message unchanged Otherwise if receiver is already a participant, it discards the message Otherwise it forwards the message, but with its own identifier It is now a participant

23-Jun-16COMP28112 Lecture 1110 A ring-based election in progress (CDK Fig. 12.7) Note: The election was started by process 17. The highest process identifier encountered so far is 24. Participant processes are shown darkened

23-Jun-16COMP28112 Lecture 1111 Until … If the identifier in the received election message is that of the receiver, that process has just been elected! It now sends an elected message round the ring – to tell everyone Now each receiver notes the result, passes it on, and resets to non-participating

23-Jun-16COMP28112 Lecture 1112 Evaluation How many messages are sent? Worst case is when process elected is just before one which initiated election Then there are 3n–1 messages Toleration of failures: very limited – in principle can rebuild ring, but …. Difficult to add new processes to ring too

23-Jun-16COMP28112 Lecture 1113 TVS, Figure 6.21 – two processes initiate election

23-Jun-16COMP28112 Lecture 1114 Bully algorithm (Garcia-Molina 1982) Designed for slightly different situation Processes may crash (though messages are assumed reliable) A process knows about the identifiers of other processes and can communicate with them System is synchronous – it uses timeouts to detect process failure

23-Jun-16COMP28112 Lecture 1115 Three types of message An election message – sent to initiate an election An answer message – sent in response to an election message A coordinator message – sent to announce the identity of the winner of the election

23-Jun-16COMP28112 Lecture 1116 Two timeouts If no reply is received in time T, assume that the reply sender has crashed If the initiator of an election doesn’t learn who won in time T + T’ it should begin another election – a process must have crashed in such a way as to mess up this one

23-Jun-16COMP28112 Lecture 1117 Initiating election Process sends an election message to all processes with higher identifiers than itself Those that have not crashed will respond with an answer message (within the timeout period) – and the initiating process can then sit back and wait for a coordinator message

23-Jun-16COMP28112 Lecture 1118 Receiving an election message Any process receiving an election message should send an answer back to the sender It should then initiate its own election – by sending an election message to each process with a larger identifier than itself Unless it has recently done that, and had neither a coordination reply nor a timeout (T’). A process with no answering process above it should consider itself elected It should then send a coordinator message to all lower processes ….

23-Jun-16COMP28112 Lecture 1119 TVS, Figure 6.20

23-Jun-16COMP28112 Lecture 1120 The bully algorithm (CDK Fig. 12.8) The election of coordinator p 2, after the failure of p 4 and then p 3

23-Jun-16COMP28112 Lecture 1121 Evaluation Need timeouts to be realistic Problem if process restarts and elects itself …. No of messages depends on which process initiates – the higher the process the smaller the number of messages! If the lowest process initiates, O(n^2) …. Exercise: 2015 exam, question 3d Next: Dealing with failures…