Operating Systems. Mutual Exclusion in Distributed Systems. Lecturer: William Fornaciari

Similar documents
Mutual Exclusion in DS

Event Ordering Silberschatz, Galvin and Gagne. Operating System Concepts

Distributed Systems - I

Chapter 16: Distributed Synchronization

11/7/2018. Event Ordering. Module 18: Distributed Coordination. Distributed Mutual Exclusion (DME) Implementation of. DME: Centralized Approach

Chapter 18: Distributed

Distributed Systems - II

Silberschatz and Galvin Chapter 18

Mutual Exclusion. A Centralized Algorithm

Distributed Coordination! Distr. Systems: Fundamental Characteristics!

Concurrency: Mutual Exclusion and Synchronization

Distributed Synchronization. EECS 591 Farnam Jahanian University of Michigan

CS455: Introduction to Distributed Systems [Spring 2018] Dept. Of Computer Science, Colorado State University

Coordination and Agreement

PROCESS SYNCHRONIZATION

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [DISTRIBUTED MUTUAL EXCLUSION] Frequently asked questions from the previous class survey

Algorithms and protocols for distributed systems

Frequently asked questions from the previous class survey

CS455: Introduction to Distributed Systems [Spring 2018] Dept. Of Computer Science, Colorado State University

Distributed Systems. coordination Johan Montelius ID2201. Distributed Systems ID2201

Process Synchroniztion Mutual Exclusion & Election Algorithms

Clock Synchronization. Synchronization. Clock Synchronization Algorithms. Physical Clock Synchronization. Tanenbaum Chapter 6 plus additional papers

Coordination 1. To do. Mutual exclusion Election algorithms Next time: Global state. q q q

Last Time. 19: Distributed Coordination. Distributed Coordination. Recall. Event Ordering. Happens-before

Last Class: Clock Synchronization. Today: More Canonical Problems

DISTRIBUTED MUTEX. EE324 Lecture 11

CSE 5306 Distributed Systems. Synchronization

Synchronization. Clock Synchronization

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

CSE 5306 Distributed Systems

Concurrency: Mutual Exclusion and

OUTLINE. Introduction Clock synchronization Logical clocks Global state Mutual exclusion Election algorithms Deadlocks in distributed systems

Distributed Systems (5DV147)

殷亚凤. Synchronization. Distributed Systems [6]

Synchronization. Distributed Systems IT332

How Bitcoin achieves Decentralization. How Bitcoin achieves Decentralization

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

Chapter 6 Synchronization (2)

Advanced Topics in Distributed Systems. Dr. Ayman A. Abdel-Hamid. Computer Science Department Virginia Tech

Distributed Mutual Exclusion Algorithms

CSE 486/586 Distributed Systems

Distributed Operating Systems. Distributed Synchronization

Synchronization Part 2. REK s adaptation of Claypool s adaptation oftanenbaum s Distributed Systems Chapter 5 and Silberschatz Chapter 17

Chapter 6 Synchronization

Distributed Mutual Exclusion

Synchronization Part II. CS403/534 Distributed Systems Erkay Savas Sabanci University

Module 6: Process Synchronization. Operating System Concepts with Java 8 th Edition

Operating Systems. Deadlock. Lecturer: William Fornaciari Politecnico di Milano Homel.deib.polimi.

Distributed Systems Coordination and Agreement

Several of these problems are motivated by trying to use solutiions used in `centralized computing to distributed computing

Process groups and message ordering

Synchronization. Chapter 5

CS370 Operating Systems

(Pessimistic) Timestamp Ordering. Rules for read and write Operations. Read Operations and Timestamps. Write Operations and Timestamps

Chapter 6: Process Synchronization. Module 6: Process Synchronization

2. The system of... generally ran one job at a time. These were called single stream batch processing.


Coordination Principles

Distributed Database Management System UNIT-2. Concurrency Control. Transaction ACID rules. MCA 325, Distributed DBMS And Object Oriented Databases

Basic Protocols and Error Control Mechanisms

Concurrency: Mutual Exclusion and Synchronization. Concurrency

Mobile and Heterogeneous databases Distributed Database System Transaction Management. A.R. Hurson Computer Science Missouri Science & Technology

Chapter 6: Process Synchronization. Operating System Concepts 8 th Edition,

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5

CSE 380 Computer Operating Systems

Concurrency: Principles of Deadlock. Processes and resources. Concurrency and deadlocks. Operating Systems Fall Processes need resources to run

A Two-Layer Hybrid Algorithm for Achieving Mutual Exclusion in Distributed Systems

CS Reading Packet: "Transaction management, part 2"

Solved MCQs on Operating System Principles. Set-1

A Modification to the Chandy-Misra Dining Philosophers Algorithm to Support Dynamic Resource Conflict Graphs

Verteilte Systeme (Distributed Systems)

Checkpoints. Logs keep growing. After every failure, we d have to go back and replay the log. This can be time consuming. Checkpoint frequently

(Pessimistic) Timestamp Ordering

Arranging lunch value of preserving the causal order. a: how about lunch? meet at 12? a: <receives b then c>: which is ok?

Lecture Topics. Announcements. Today: Concurrency: Mutual Exclusion (Stallings, chapter , 5.7)

Chapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles

Last Class: Synchronization Problems!

Last Class: Monitors. Real-world Examples

A DAG-BASED ALGORITHM FOR DISTRIBUTED MUTUAL EXCLUSION ATHESIS MASTER OF SCIENCE

Chapter 5 Concurrency: Mutual Exclusion and Synchronization

Chapters 5 and 6 Concurrency

Module 6: Process Synchronization

Concurrency Control in Distributed Systems. ECE 677 University of Arizona

PESIT Bangalore South Campus

Coordination and Agreement

SIR C.R.REDDY COLLEGE OF ENGINEERING, ELURU DEPARTMENT OF INFORMATION TECHNOLOGY LESSON PLAN

Principles of Operating Systems CS 446/646

Last Class: Naming. Today: Classical Problems in Distributed Systems. Naming. Time ordering and clock synchronization (today)

SYNCHRONIZATION. DISTRIBUTED SYSTEMS Principles and Paradigms. Second Edition. Chapter 6 ANDREW S. TANENBAUM MAARTEN VAN STEEN

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - X Deadlocks - II. Louisiana State University. Deadlocks

Chapter 6: Synchronization. Operating System Concepts 8 th Edition,

Distributed Systems. 13. Distributed Deadlock. Paul Krzyzanowski. Rutgers University. Fall 2017

Concurrency Control. Data Base Management Systems. Inherently Concurrent Systems: The requirements

Coordination and Agreement

Transaction Management

CMPSCI 677 Operating Systems Spring Lecture 14: March 9

OPERATING SYSTEMS. Prescribed Text Book. Operating System Principles, Seventh Edition. Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

Distributed Systems. Before We Begin. Advantages. What is a Distributed System? CSE 120: Principles of Operating Systems. Lecture 13.

Event Ordering. Greg Bilodeau CS 5204 November 3, 2009

Chapter 6 Concurrency: Deadlock and Starvation

Transcription:

Politecnico di Milano Operating Systems Mutual Exclusion in Distributed Systems Lecturer: William Fornaciari Politecnico di Milano fornacia@elet.polimi.it www.elet.polimi.it/~fornacia William Fornaciari

DISTRIBUTED MUTUAL EXCLUSION (DME) Assumptions The system consists of n processes; each process P i resides at a different processor Each process has a critical section that requires mutual exclusion Basic Requirement If P i is executing in its critical section, then no other process P j is executing in its critical section The presented algorithms ensure the mutual exclusion execution of processes in their critical sections Mutual Exclusion in Distributed Systems - 2 -

DME: GENERAL REQUIREMENTS Mutual exclusion must be enforced: only one process at a time is allowed in its critical section A process that hales in its noncritical section must do so without interfering with other processes It must not be possible for a process requiring access to a critical section to be delayed indefinitely: No deadlock or starvation When no process is in a critical section, any process that request to entry in its critical section have to do that without delay No assumptions are made about relative process speeds or number of processors A process remains inside its critical section for a finite time only Mutual Exclusion in Distributed Systems - 3 -

THE MODEL FOR DME Mutual Exclusion in Distributed Systems - 4 -

DME : CENTRALIZED APPROACH (1) One of the processes in the system is chosen to coordinate the entry to the critical section (control access to shared objects) A process that wants to enter its critical section sends a request message to the coordinator The coordinator decides which process can enter the critical section next, and its sends that process a reply message When the process receives a reply message from the coordinator, it enters its critical section After exiting its critical section, the process sends a release message to the coordinator and proceeds with its execution Mutual Exclusion in Distributed Systems - 5 -

DME : CENTRALIZED APPROACH(2) This scheme requires three messages per criticalsection entry: Request, reply, release Limits of the Centralized approach if the coordinator process crashes, the system becomes useless the several messages towards the coordinator process can create a bottleneck Benefits of the Centralized approach Ensure mutual esclusion Ordering of the access requests No starvation Use of only three messages Mutual Exclusion in Distributed Systems - 6 -

GENERAL REQUIREMENTS OF DISTRIBUTED ALGORITHMS All nodes have equal amount of information, on average Each node has only a partial picture of the total system and must make decisions based on this information All nodes bear equal responsibility for the final decision All nodes expend equal effort, on average, in effecting a final decision Failure of a node, in general, does not result in a total system collapse There exits no systemwide common clock with which to regulate the time of events Mutual Exclusion in Distributed Systems - 7 -

DME : TIME STAMPING (1) Since in a distributed system the clocks are not synchronized, we have to be able to order events Implementation of happened-before relation Associate a timestamp with each system event. Require that for every pair of events A and B, if A is happened before B, then the timestamp of A is less than the timestamp of B Within each process P i a logical clock, LC i is associated. The logical clock can be implemented as a simple counter that is incremented between any two successive events executed within a process. Mutual Exclusion in Distributed Systems - 8 -

DME : TIME STAMPING (2) A process advances its logical clock when it receives a message whose timestamp is greater than the current value of its logical clock (when a message is received, the receiving system sets its counter to one more than the maximum of its current value and the incoming time-stamp (counter)) If the timestamps of two events A and B are the same, then the events are concurrent. We may use the process identity numbers to break ties and to create a total ordering Mutual Exclusion in Distributed Systems - 9 -

DME : TIME STAMPING (3) For this method to work, each message is sent from one process to all other processes ensures all sites have same ordering of messages for mutual exclusion and deadlock all processes must be aware of the situation Mutual Exclusion in Distributed Systems - 10 -

DME : FULLY DISTRIBUTED (1) 1 When process P i wants to enter its critical section, it generates a new timestamp, TS, and sends the message request (P i, TS) to all other processes in the system 2 When process P j receives a request message, it may reply immediately or it may defer sending a reply back 3 When process P i receives a reply message from all other processes in the system, it can enter its critical section 4 After exiting its critical section, the process sends reply messages to all its deferred requests Mutual Exclusion in Distributed Systems - 11 -

DME : FULLY DISTRIBUTED (2) The decision whether process P j replies immediately to a request(p i, TS) message or defers its reply is based on three factors: If P j is in its critical section, then it defers its reply to P i If P j does not want to enter its critical section, then it sends a reply immediately to P i If P j wants to enter its critical section but has not yet entered it, then it compares its own request timestamp with the timestamp TS If its own request timestamp is greater than TS, then it sends a reply immediately to P i (P i asked first) Otherwise, the reply is deferred Mutual Exclusion in Distributed Systems - 12 -

DME : FULLY DISTRIBUTED (3) Freedom from Deadlock is ensured Freedom from starvation is ensured, since entry to the critical section is scheduled according to the timestamp ordering. The timestamp ordering ensures that processes are served in a first-come, first served order The number of messages per critical-section entry is 2 x (n 1) (n - 1) requests and (n- 1) replies. This is the number of required messages per criticalsection entry when processes act independently and concurrently Mutual Exclusion in Distributed Systems - 13 -

STATES OF THE FULLY DISTRIBUTED APPROACH Mutual exclusion request Asking for mutual exclusion Sending of a request to the other processes Choice Waiting Receiving of all the replies Critical Section To send reply messages to all the deferred request To activate the others Exiting its critical section Mutual Exclusion in Distributed Systems - 14 -

THREE UNDESIRABLE CONSEQUENCES The processes need to know the identity of all other processes in the system, which makes the dynamic addition and removal of processes more complex If one of the processes fails, then the entire scheme collapses. This can be dealt with by continuously monitoring the state of all the processes in the system Processes that have not entered their critical section must pause frequently to assure other processes that they intend to enter the critical section. This protocol is therefore suited for small, stable sets of cooperating processes Mutual Exclusion in Distributed Systems - 15 -

TOKEN-PASSING APPROACH (1) It exists a logical ring where each process has an assigned position and know who is next The token is an entity that at any time is held by one process The process holding the token may enter its critical section without asking permission. Only this which has got the token can enter its critical section When a process leaves its critical section, it passes the token to another process When a process wants enter its critical section and it hasn't got the token, it sends request messages to all the other processes, waiting since the arrival of the token Mutual Exclusion in Distributed Systems - 16 -

TOKEN-PASSING ALGORITHM (1) How to manage the use of the critical section if not token_present then begin clock := clock + 1; broadcast(request, clock I); wait(access, token); token_present := True; end endif; token_held := True: <critical section> token(i) := clock; token_held := False; for j := i + 1 to n, 1 to i - 1 do if (request(j) > token(j)) [Symbol]^token_present then begin token_present := False; send(access, token(j)) end endif; Mutual Exclusion in Distributed Systems - 17 -

TOKEN-PASSING ALGORITHM (2) How to do when a process receives a request when received (Request, k, j) do request(j) := max(request(j), k); if token_present[symbol] ^not token_held then token(i) := clock; token_held := False; for j := i + 1 to n, 1 to i - 1 do if (request(j) > token(j)) [Symbol]^token_present then begin token_present := False; send(access, token(j)) end endif; endif enddo; Notation : send(j, access, token) send message of type access, with token, by process j broadcast(request, clock, i) send message from process i of type request, with timestamp clock, to all other processes received(request, t, j) receive message from process j of type request,with timestamp t Mutual Exclusion in Distributed Systems - 18 -

TOKEN-PASSING APPROACH (2) Troubles Difficult detection/regeneration of lost token Process crash Difficult detection Easy recover: if required ack from process when the token is received, dead processes are detected by neighbor which can skip it over (need to know the entire ring configuration) Benefits Mutual esclusion No starvation At worst a process have to wait for every other process to enter and leave one critical region Mutual Exclusion in Distributed Systems - 19 -

DME: COMPARISON Algorithm Messages per entry/exit Delay before entry (in msg times) Centralized 3 2 Distributed 2 (n-1) 2 (n-1) Token ring 1 to 0 to (n-1) Problems Coordinator crash Crash of any process Lost token, process crash None is robust to system crashes Mutual Exclusion in Distributed Systems - 20 -

REFERENCES Stallings W. Sistemi Operativi Jackson Libri Silberschatz A. Sistemi Operativi Addison-Wesley Tanenbaum A. I Moderni Sistemi Operativi Jackson Libri Web Material (see links) Mutual Exclusion in Distributed Systems - 21 -