Page 1 Mutual Exclusion & Election Algorithms Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content.

Slides:



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

CS425 /CSE424/ECE428 – Distributed Systems – Fall 2011 Material derived from slides by I. Gupta, M. Harandi, J. Hou, S. Mitra, K. Nahrstedt, N. Vaidya.
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.
Synchronization in Distributed Systems
Page 1 Lecturer: Roohollah Abdipour Acknowledgment: Many of the slides are based on slides by Prof. Paul Krzyzanowski at Rutgers University,
Distributed Systems Spring 2009
CS 582 / CMPE 481 Distributed Systems
What we will cover…  Distributed Coordination 1-1.
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.
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.
EEC-681/781 Distributed Computing Systems Lecture 11 Wenbing Zhao Cleveland State University.
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.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
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.
Mutual exclusion Concurrent access of processes to a shared resource or data is executed in mutually exclusive manner Distributed mutual exclusion can.
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.
Page 1 Distributed Systems Election Algorithms* *referred to slides by Prof. Hugh C. Lauer at Worcester Polytechnic Institute.
Synchronization CSCI 4780/6780. Mutual Exclusion Concurrency and collaboration are fundamental to distributed systems Simultaneous access to resources.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 15/01/2008.
Presenter: Long Ma Advisor: Dr. Zhang 4.5 DISTRIBUTED MUTUAL EXCLUSION.
Vector Clock Each process maintains an array of clocks –vc.j.k denotes the knowledge that j has about the clock of k –vc.j.j, thus, denotes the clock of.
Synchronization Chapter 5.
Lecture 10 – Mutual Exclusion Distributed Systems.
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Mutual Exclusion & Leader Election Steve Ko Computer Sciences and Engineering University.
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.
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.
Synchronization in Distributed Systems Chapter 6.3.
COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 6: Synchronyzation 3/5/20161 Distributed Systems - COMP 655.
CIS 825 Review session. P1: Assume that processes are arranged in a ring topology. Consider the following modification of the Lamport’s mutual exclusion.
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.
CSC 8420 Advanced Operating Systems Georgia State University Yi Pan Transactions are communications with ACID property: Atomicity: all or nothing Consistency:
Revisiting Logical Clocks: Mutual Exclusion Problem statement: Given a set of n processes, and a shared resource, it is required that: –Mutual exclusion.
Lecture 11: Coordination and Agreement Central server for mutual exclusion Election – getting a number of processes to agree which is “in charge” CDK4:
CS 425 / ECE 428 Distributed Systems Fall 2015 Indranil Gupta (Indy) Oct 1, 2015 Lecture 12: Mutual Exclusion All slides © IG.
Mutual Exclusion A condition in which there is a set of processes, only one of which is able to access a given resource or perform a given function at.
CSE 486/586 Distributed Systems Leader Election
Distributed Mutex EE324 Lecture 11.
Distributed 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
Distributed Systems and Concurrency: Synchronization in Distributed Systems Majeed Kassis.
Distributed Mutual eXclusion
CSE 486/586 Distributed Systems Leader Election
Presentation transcript:

Page 1 Mutual Exclusion & Election Algorithms Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.

Page 2 Process Synchronization Techniques to coordinate execution among processes –One process may have to wait for another –Shared resource (e.g. critical section) may require exclusive access

Page 3 Centralized Systems Mutual exclusion via: –Test & set in hardware –Semaphores –Messages –Condition variables

Page 4 Distributed Mutual Exclusion Assume there is agreement on how a resource is identified –Pass identifier with requests Create an algorithm to allow a process to obtain exclusive access to a resource.

Page 5 Centralized algorithm Mimic single processor system One process elected as coordinator P C request(R) grant(R) 1. Request resource 2. Wait for response 3. Receive grant 4. access resource 5. Release resource release(R)

Page 6 Centralized algorithm If another process claimed resource: –Coordinator does not reply until release –Maintain queue Service requests in FIFO order P0P0 C request(R) grant(R) release(R) P1P1 P2P2 request(R) Queue P1P1 request(R) P2P2 grant(R)

Page 7 Centralized algorithm Benefits Fair –All requests processed in order Easy to implement, understand, verify Problems Process cannot distinguish being blocked from a dead coordinator Centralized server can be a bottleneck

Page 8 Token Ring algorithm Assume known group of processes –Some ordering can be imposed on group –Construct logical ring in software –Process communicates with neighbor P0P0 P1P1 P2P2 P3P3 P4P4 P5P5

Page 9 Token Ring algorithm Initialization –Process 0 gets token for resource R Token circulates around ring –From P i to P (i+1) mod N When process acquires token –Checks to see if it needs to enter critical section –If no, send ring to neighbor –If yes, access resource Hold token until done P0P0 P1P1 P2P2 P3P3 P4P4 P5P5 token(R)

Page 10 Token Ring algorithm Only one process at a time has token –Mutual exclusion guaranteed Order well-defined –Starvation cannot occur If token is lost (e.g. process died) –It will have to be regenerated Does not guarantee FIFO order –sometimes this is undesirable

Page 11 Ricart & Agrawala algorithm Distributed algorithm using reliable multicast and logical clocks Process wants to enter critical section: –Compose message containing: Identifier (machine ID, process ID) Name of resource Timestamp (totally-ordered Lamport) –Send request to all processes in group –Wait until everyone gives permission –Enter critical section / use resource

Page 12 Ricart & Agrawala algorithm When process receives request: –If receiver not interested: Send OK to sender –If receiver is in critical section Do not reply; add request to queue –If receiver just sent a request as well: Compare timestamps: received & sent messages Earliest wins If receiver is loser, send OK If receiver is winner, do not reply, queue When done with critical section –Send OK to all queued requests

Page 13 Ricart & Agrawala algorithm N points of failure A lot of messaging traffic Demonstrates that a fully distributed algorithm is possible

Page 14 Lamport’s Mutual Exclusion Each process maintains request queue –Contains mutual exclusion requests Requesting critical section: –Process P i sends request(i, T i ) to all nodes –Places request on its own queue –When a process P j receives a request, it returns a timestamped ack Lamport time

Page 15 Lamport’s Mutual Exclusion Entering critical section (accessing resource) : –P i received a message (ack or release) from every other process with a timestamp larger than T i –P i ’s request has the earliest timestamp in its queue Difference from Ricart-Agrawala: –Everyone responds … always - no hold-back –Process decides to go based on whether its request is the earliest in its queue

Page 16 Lamport’s Mutual Exclusion Releasing critical section: –Remove request from its own queue –Send a timestamped release message –When a process receives a release message Removes request for that process from its queue This may cause its own entry have the earliest timestamp in the queue, enabling it to access the critical section

Page 17 Election algorithms

Page 18 Elections Need one process to act as coordinator Processes have no distinguishing characteristics Each process can obtain a unique ID

Page 19 Bully algorithm Select process with largest ID as coordinator When process P detects dead coordinator: –Send election message to all processes with higher IDs. If nobody responds, P wins and takes over. If any process responds, P’s job is done. –Optional: Let all nodes with lower IDs know an election is taking place. If process receives an election message –Send OK message back –Hold election (unless it is already holding one)

Page 20 Bully algorithm A process announces victory by sending all processes a message telling them that it is the new coordinator If a dead process recovers, it holds an election to find the coordinator.

Page 21 Ring algorithm Ring arrangement of processes If any process detects failure of coordinator –Construct election message with process ID and send to next process –If successor is down, skip over –Repeat until a running process is located Upon receiving an election message –Process forwards the message, adding its process ID to the body

Page 22 Ring algorithm Eventually message returns to originator –Process sees its ID on list –Circulates (or multicasts) a coordinator message announcing coordinator E.g. lowest numbered process

Page 23 Problems with elections Network segmentation –Split brain Rely on alternate communication mechanism –Redundant network, shared disk, serial line, SCSI

Page 24 The end.