Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 1 DISTRIBUTED.

Slides:



Advertisements
Similar presentations
Dr. Kalpakis CMSC621 Advanced Operating Systems Synchronization.
Advertisements

Synchronization Chapter clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed.
Distributed Computing
Time and Clock Primary standard = rotation of earth De facto primary standard = atomic clock (1 atomic second = 9,192,631,770 orbital transitions of Cesium.
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.
Centralized Architectures
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.
Clock Synchronization and algorithm
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
EEC-681/781 Distributed Computing Systems Lecture 10 Wenbing Zhao Cleveland State University.
Lecture 12 Synchronization. EECE 411: Design of Distributed Software Applications Summary so far … A distributed system is: a collection of independent.
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.
1 Synchronization Part 1 REK’s adaptation of Claypool’s adaptation of Tanenbaum’s Distributed Systems Chapter 5.
Election Algorithms. Topics r Issues r Detecting Failures r Bully algorithm r Ring algorithm.
Synchronization.
Lecture 2-1 CS 425/ECE 428 Distributed Systems Lecture 2 Time & Synchronization Reading: Klara Nahrstedt.
ALGORITHMS FOR ISNE DR. KENNETH COSH WEEK 13.
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.
Synchronization Chapter 6
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Chapter 6 Synchronization.
OS2- Sem , R. Jalili Synchronization Chapter 5.
Mutual exclusion Concurrent access of processes to a shared resource or data is executed in mutually exclusive manner Distributed mutual exclusion can.
Lecture 5: Sun: 1/5/ Distributed Algorithms - Distributed Databases Lecturer/ Kawther Abas CS- 492 : Distributed system &
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Vector timestamps Global state –Distributed Snapshot Election algorithms –Bully algorithm.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
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.
Synchronization. Why we need synchronization? It is important that multiple processes do not access shared resources simultaneously. Synchronization in.
Synchronization Chapter 5. Outline 1.Clock synchronization 2.Logical clocks 3.Global state 4.Election algorithms 5.Mutual exclusion 6.Distributed transactions.
Synchronization Chapter 5.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Distributed Systems Principles and Paradigms Chapter 05 Synchronization.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Lecture 10 – Mutual Exclusion Distributed Systems.
Real-Time & MultiMedia Lab Synchronization Distributed System Jin-Seung,KIM.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
Distributed Process Coordination Presentation 1 - Sept. 14th 2002 CSE Spring 02 Group A4:Chris Sun, Min Fang, Bryan Maden.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
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.
Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.
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.
6 SYNCHRONIZATION. introduction processes synchronize –exclusive access. –agree on the ordering of events much more difficult compared to synchronization.
Synchronization. Clock Synchronization In a centralized system time is unambiguous. In a distributed system agreement on time is not obvious. When each.
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
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.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Mutual Exclusion Algorithms. Topics r Defining mutual exclusion r A centralized approach r A distributed approach r An approach assuming an organization.
Lecture on Synchronization Submitted by
Prof. Leonardo Mostarda University of Camerino
Chapter 6.3 Mutual Exclusion
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Prof. Leonardo Mostarda University of Camerino
Last Class: Naming Name distribution: use hierarchies DNS
Outline Theoretical Foundations
Presentation transcript:

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S. TANENBAUM MAARTEN VAN STEEN Chapter 6 Synchronization

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Clock Synchronization Figure 6-1. When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Physical Clocks (1) Some Basic definitions: Transit of the Sun: –Sun rises from east –Rises to its max height in the sky (noon) –Sun sets in west Solar Day: Interval between 2 consecutive transits of the sun (noon-to-noon) Solar Day varies due: –Core activities of earth –Rise & Tide of oceans –Gravity –Orbit around the sun, not a perfect circle

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Physical Clocks (2) Some Basic definitions – cont’d: Before 1948: Solar day was used to measure time 1 day = 24hr x 60min x 60s = 86,400 sec) After 1948: Measure time by counting the transitions in the Cesium 133 atom (i.e. the Second defined to be the time it takes to do 9,192,631,770 transitions). This is called TAI (International Atomic Time, measured in Paris by “Bureau International De I’Heure”, BIH)

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Physical Clocks (3) Problem: 1 Day measured in TAI (i.e. 86, 400 TAI sec) is 3 msec shorter than a solar day, hence the need for a leap second Leap Second: When discrepancy between solar and TAI second is 800 msec This correction (i.e. addition of a leap second, yield to a Universal Coordinated Time, UTC)

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Physical Clocks (4) Figure 6-2. Computation of the mean solar day.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Physical Clocks (5) Figure 6-3. TAI seconds are of constant length, unlike solar seconds. Leap seconds are introduced when necessary to keep in phase with the sun.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Global Positioning System (1) Used to locate a physical point on earth A satellite-based distributed system launch in 1978 Originally for military purposes GPS currently uses 29 satellites orbiting the earth at a height of approximately 2000 Km each having clocks and broadcasting its position Need at least 3 satellites to measure: Longitude, Latitude, and Altitude (height)

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Global Positioning System (2) Figure 6-4. Computing a position in a two-dimensional space.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Global Positioning System (3) Real world facts that complicate GPS 1.It takes a while before data on a satellite’s position reaches the receiver. 2.The receiver’s clock is generally not in synch with that of a satellite.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Clock Synchronization Algorithms Figure 6-5. The relation between clock time and UTC when clocks tick at different rates.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Network Time Protocol (NTP) Figure 6-6. Getting the current time from a time server.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved The Berkeley Algorithm (1) Figure 6-7. (a) The time daemon asks all the other machines for their clock values.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved The Berkeley Algorithm (2) Figure 6-7. (b) The machines answer.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved The Berkeley Algorithm (3) Figure 6-7. (c) The time daemon tells everyone how to adjust their clock.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Clock Synchronization in Wireless Networks (1) Figure 6-8. (a) The usual critical path in determining network delays. NIC: Network Interface Channel (wireless packet flows)

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Clock Synchronization in Wireless Networks (2) RBS (Reference Broadcast Synchronization) is a clock synchronization protocol where a sender broadcasts a reference message that will allow its receivers to adjust their clocks. RBS is also referred to as a “Point of Reference Message”

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Clock Synchronization in Wireless Networks (3) Figure 6-8. (b) The critical path in the case of RBS.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Lamport’s Logical Clocks (1) The "happens-before" relation → can be observed directly in two situations: If a and b are events in the same process, and a occurs before b, then a → b is true. If a is the event of a message being sent by one process, and b is the event of the message being received by another process, then a → b

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Lamport’s Logical Clocks (2) Figure 6-9. (a) Three processes, each with its own clock. The clocks run at different rates.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Lamport’s Logical Clocks (3) Figure 6-9. (b) Lamport’s algorithm corrects the clocks.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Lamport’s Logical Clocks (4) Figure The positioning of Lamport’s logical clocks in distributed systems.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Lamport’s Logical Clocks (5) Updating counter C i for process P i 1.Before executing an event P i executes C i ← C i When process P i sends a message m to P j, it sets m’s timestamp ts (m) equal to C i after having executed the previous step. 3.Upon the receipt of a message m, process P j adjusts its own local counter as C j ← max{C j, ts (m)}, after which it then executes the first step and delivers the message to the application.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Example: Totally Ordered Multicasting (using Lamport’s logical clock) Figure Updating a replicated database and leaving it in an inconsistent state.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Mutual Exclusion A Centralized Algorithm (1) Figure (a) Process 1 asks the coordinator for permission to access a hared resource. Permission is granted.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Mutual Exclusion A Centralized Algorithm (2) Figure (b) Process 2 then asks permission to access the same resource. The coordinator does not reply.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Mutual Exclusion A Centralized Algorithm (3) Figure (c) When process 1 releases the resource, it tells the coordinator, which then replies to 2.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved A Distributed Algorithm (1) Mutual Exclusion in access of shared resources in distributed systems When a process wants to access a shared resource, it builds a messages containing: –Name of the resource –Its process number –Current time Then, sends the message to all other processes, even to itself

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved A Distributed Algorithm (2) Three different cases: 1.If the receiver (of a message) is not accessing the resource and does not want to access it, it sends back an OK message to the sender. 2.If the receiver already has access to the resource, it simply does not reply. Instead, it queues the request. 3.If the receiver wants to access the resource as well but has not yet done so, it compares the timestamp of the incoming message with the one contained in the message that it has sent everyone. The lowest one wins.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved A Distributed Algorithm (3) Figure (a) Two processes want to access a shared resource at the same moment.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved A Distributed Algorithm (4) Figure (b) Process 0 has the lowest timestamp, so it wins.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved A Distributed Algorithm (5) Figure (c) When process 0 is done, it sends an OK also, so 2 can now go ahead.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved A Token Ring Algorithm (1) Figure (a) An unordered group of processes on a network. (b) A logical ring constructed in software.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved A Token Ring Algorithm (2) When a ring is initialized, process 0 is given a token. Token is passed from k to k+1 (modulo the ring size) in a point-to- point message. When a process acquires the token from its neighbor, it checks to see if needs to access the shared resource. Each process only needs to know who is next inline Ordering is logical usually based on the process number or other means

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Election Algorithms Purpose of an Election algorithm: Elect who the next coordinating process is. Examples of Election Algorithms: 1.The Bully Algorithm 2.The Ring Algorithm 3.Election algorithm in Wireless network

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved The Bully Algorithm (1) Assume every process knows the process number of other processes Processes know each others process no., however do not know which ones are currently dead or alive When any process, P, notices the coordinator is no longer responding to requests, it initiates an election.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved The Bully Algorithm (2) 1.P sends an ELECTION message to all processes with higher numbers. 2.If no one responds, P wins the election and becomes coordinator. 3.If one of the higher-ups answers, it takes over. P’s job is done.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved The Bully Algorithm (3) Figure The bully election algorithm. (a) Process 4 holds an election. (b) Processes 5 and 6 respond, telling 4 to stop. (c) Now 5 and 6 each hold an election.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved The Bully Algorithm (4) Figure The bully election algorithm. (d) Process 6 tells 5 to stop. (e) Process 6 wins and tells everyone.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved A Ring Algorithm (1) Figure Election algorithm using a ring.

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved A Ring Algorithm (2) No Token is used Both process 2 and 5, realize that the coordinator, 7, is dead They send an election message across the ring to the next node, if node is dead, send to the one after Either 2 or 5 becomes the new coordinator depending who sees his number come back to it first

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Elections in Wireless Environments (1) Bully or Ring algorithms are not realistic in wireless environments since they assume message passing is reliable which is not true in wireless environments Purpose is to select the best node as coordinator not just any node (e.g. best capacity based on remaining battery) Leader, called Source, can initiate an election by sending a message to its immediate neighbors

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Elections in Wireless Environments (2) Figure Election algorithm in a wireless network, with node a as the source. (a) Initial network. (b)–(e) The build-tree phase

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Elections in Wireless Environments (3) Figure Election algorithm in a wireless network, with node a as the source. (a) Initial network. (b)–(e) The build-tree phase

Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved Elections in Wireless Environments (4) Figure (e) The build-tree phase. (f) Reporting of best node to source.