Mutual Exclusion Algorithms. Topics r Defining mutual exclusion r A centralized approach r A distributed approach r An approach assuming an organization.

Slides:



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

Synchronization Chapter clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed.
1 Algorithms and protocols for distributed systems We have defined process groups as having peer or hierarchical structure and have seen that a coordinator.
Page 1 Mutual Exclusion* Distributed Systems *referred to slides by Prof. Paul Krzyzanowski at Rutgers University and Prof. Mary Ellen Weisskopf at University.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED.
Synchronization in Distributed Systems
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.
Synchronization Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
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.
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.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
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.
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.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Mutual Exclusion Steve Ko Computer Sciences and Engineering University at Buffalo.
4.5 DISTRIBUTED MUTUAL EXCLUSION MOSES RENTAPALLI.
4.5 Distributed Mutual Exclusion Ranjitha Shivarudraiah.
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.
1 Mutual Exclusion: A Centralized Algorithm a)Process 1 asks the coordinator for permission to enter a critical region. Permission is granted b)Process.
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.
Global State (1) a)A consistent cut b)An inconsistent cut.
Synchronization CSCI 4780/6780. Mutual Exclusion Concurrency and collaboration are fundamental to distributed systems Simultaneous access to resources.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
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.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.
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.
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.
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
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:
Lecture on Synchronization Submitted by
Process Synchronization Presentation 2 Group A4: Sean Hudson, Syeda Taib, Manasi Kapadia.
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.
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
Lecture 10: Coordination and Agreement
Synchronization (2) – Mutual Exclusion
Prof. Leonardo Mostarda University of Camerino
Lecture 11: Coordination and Agreement
Presentation transcript:

Mutual Exclusion Algorithms

Topics r Defining mutual exclusion r A centralized approach r A distributed approach r An approach assuming an organization of processes as a ring

Readings r Van Steen and Tanenbaum: 5.5 r Coulouris: 11.2

Mutual Exclusion r If a collection of processes share a resource or collection of resources, then often mutual exclusion is required to prevent interference and ensure consistency when accessing the resources. r You first saw this concept in CS 305 m Concurrent processes (or threads) often need to share data (maintained in either shared memory or files) or resources. m With no synchronization results may not be reproducible or deterministic.

Mutual Exclusion r Example: Consider users updating a file. m To ensure update are consistent, allow users to access it only one at a time by requiring the editor to lock the file before updates can be made. m UNIX systems provide a separate file-locking service, implemented by the daemon lockd to handle locking requests from clients. Example: Peer access to a shared resource m Ethernet and IEEE wireless networks r Example: Access to Printer

Requirements r Safety: At most one process in critical section at any time. r Freedom from deadlock: two or more processes stuck indefinitely while attempting to enter or exit the critical section r Freedom from starvation: If some process requests to use the critical section then eventually it will be able to.

Mutual Exclusion: A Centralized Algorithm a) Process 1 asks the coordinator for permission to enter a critical region. Permission is granted b) Process 2 then asks permission to enter the same critical region. The coordinator does not reply. c) When process 1 exits the critical region, it tells the coordinator, which then replies to 2

Mutual Exclusion: A Centralized Algorithm r Shortcomings m The coordinator is a single point of failure, so if it crashes, the entire system may go down. Wait; why not just elect another coordinator? You can. The only concern is figuring out who has access to the critical section. How do you tell the difference between a dead coordinator and “permission denied”? m In a large system a single coordinator may become a performance bottleneck.

Mutual Exclusion: A Centralized Algorithm r Number of message needed m 3 messages to enter and leave a critical region: A request A grant to enter A release to exit.

Mutual Exclusion: A Distributed Algorithm r Process requests that it wants to enter a critical region by creating a message with this info: m Name of the critical region it wants to enter m Its process number m The current time (as determined by Lamport’s clocks). r Message is sent to all other processes including itself. r Assume messages are delivered reliably.

Mutual Exclusion: A Distributed Algorithm r Upon receipt of a message, a process needs to distinguish these three cases: 1. If the receiver is not in the critical region and does not want to enter it, it sends back an OK message to the sender. 2. If the receiver is already in the critical region, it does not reply. Instead, it queues the request. 3. If the receiver wants to enter the critical region but has not done so, it compares the timestamp (generated using Lamport’s clocks (extended for total order)) in the incoming message with the one contained in the message that it has sent everyone. The lowest wins. If the incoming message is lower, the receiver sends back an OK message else it queues the incoming request and sends nothing.

Mutual Exclusion: A Distributed Algorithm r After sending out requests asking permission to enter a critical region, a process sits back and waits until everyone else has given permission. r After all the permissions are in, it may enter the critical region. r When it exits the critical region it sends OK messages to all processes on its queue.

Mutual Exclusion: A Distributed Algorithm Events a,e are requests for critical region access For P1, event b is P2’s request; For P2, event f is P1’s request For P3, event j is P1’s request and event k is P2’s request P1P2 P3 b e f k j a

Mutual Exclusion: A Distributed Algorithm Event l in P3 is associated with P3 sending OK to P2 and P1 b P1 c P2 e f g P3 k j l a

Mutual Exclusion: A Distributed Algorithm b P1 c d P2 e f g h P3 k j l a Event h is P2 sending an OK to P1 since P1 has a lower identifier; Event d in P1 is the receipt of the OK from P2. P1 can now enter the critical section.

Mutual Exclusion: A Distributed Algorithm b P1 c d P2 e f g h P3 k j l a Event i in P1 sends an OK to P2 when it finishes with the critical section. i j

Mutual Exclusion: A Distributed Algorithm r The algorithm presented is the simplest case. r You may want to multicast OKs to all processes.

Mutual Exclusion: A Distributed Algorithm r The single point of failure has been replaced by n points of failure. r If any process crashes, it will fail to respond to requests. What is the difference between a denial and a dead process?

Mutual Exclusion: A Distributed Algorithm r How to deal with this? m When a request comes in, the receiver always sends a reply, either granting or denying permission. m Whenever a request or a reply is lost, the sender times out and keeps trying until either a reply comes back or the sender concludes that the destination is dead. m After a request is denied, the sender should block waiting for a subsequent OK message. Who is going to send it? m Not easy to deal with this!

Mutual Exclusion: A Distributed Algorithm r Number of messages needed m Entering a critical section n-1 request messages n-1 grant messages Total: 2(n-1)

Mutual Exclusion: A Token Ring Algorithm a) An unordered group of processes on a network. b) A logical ring constructed in software.

Mutual Exclusion: A Token Ring Algorithm r When the ring is initialized, process 0 is given a token. r The token circulates around the ring. r It is passed from process k to process k+1. r When a process acquires the token from its neighbor it checks to see if it is attempting to enter a critical region. r If so, the process enters the region, does all the work it needs to and leaves the region. r Token is passed to the next process in the ring.

Mutual Exclusion: A Token Ring Algorithm r Shortcomings m If the token is lost, it must be regenerated. m Very difficult to determine if a token is lost since a process may be in a critical section for a long time. m If there is a crash, recovery is easier than in other cases. If we require a process receiving the token to acknowledge receipt, a dead process will be detected when its neighbor tries to give it the token and fails. The token is passed to the successor of the dead process. This requires that each process knows the ring configuration.

Mutual Exclusion: A Token Ring Algorithm r Number of messages needed m Variable number of messages needed m If every process constantly wants to enter a critical region, then each token pass will result in one entry and one exit. m The token may circulate for hours without anyone being interested in it. In this case, the number of messages per entry into a critical region is unbounded. m We note that there is delay in from the moment a process needs to enter a critical region until its actual entry. If the token just left, it needs to wait until the token has gone through the n-1 nodes. If the token just arrived, there is no wait.

Summary r All three algorithms suffer badly in event of crashes. r Special measures and additional complexity must be introduced to avoid having a crash bring down the entire system.