Chapter 5 (through section 5.4)

Slides:



Advertisements
Similar presentations
Time and Global States Part 3 ECEN5053 Software Engineering of Distributed Systems University of Colorado, Boulder.
Advertisements

Synchronization Chapter clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed.
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.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Logical Clocks and Global State.
Distributed Systems Spring 2009
CMPT 431 Dr. Alexandra Fedorova Lecture VIII: Time And Global Clocks.
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.
Lecture 13 Synchronization (cont). EECE 411: Design of Distributed Software Applications Logistics Last quiz Max: 69 / Median: 52 / Min: 24 In a box outside.
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
EEC-681/781 Distributed Computing Systems Lecture 10 Wenbing Zhao Cleveland State University.
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.
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Clock Synchronization Physical clocks Clock synchronization algorithms –Cristian’s.
Time, Clocks, and the Ordering of Events in a Distributed System Leslie Lamport (1978) Presented by: Yoav Kantor.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Fall 2003 URL: Logical Clocks and Global State.
Synchronization.
Logical Clocks (2). Topics r Logical clocks r Totally-Ordered Multicasting r Vector timestamps.
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.
Chapter 5.
© Oxford University Press 2011 DISTRIBUTED COMPUTING Sunita Mahajan Sunita Mahajan, Principal, Institute of Computer Science, MET League of Colleges, Mumbai.
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
Synchronization. Why we need synchronization? It is important that multiple processes do not access shared resources simultaneously. Synchronization in.
“Virtual Time and Global States of Distributed Systems”
Synchronization Chapter 5.
Communication & Synchronization Why do processes communicate in DS? –To exchange messages –To synchronize processes Why do processes synchronize in DS?
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.
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 SYSTEMS Principles and Paradigms Second Edition ANDREW S
Feb 15, 2001CSCI {4,6}900: Ubiquitous Computing1 Announcements.
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.
Event Ordering. CS 5204 – Operating Systems2 Time and Ordering The two critical differences between centralized and distributed systems are: absence of.
Synchronization. Clock Synchronization In a centralized system time is unambiguous. In a distributed system agreement on time is not obvious. When each.
Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau.
COMP 655: Distributed/Operating Systems Summer 2011 Dr. Chunbo Chu Week 6: Synchronyzation 3/5/20161 Distributed Systems - COMP 655.
11-Jun-16CSE 542: Operating Systems1 Distributed systems Time, clocks, and the ordering of events in a distributed system Leslie Lamport. Communications.
Ordering of Events in Distributed Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 739 Distributed Systems Andrea C. Arpaci-Dusseau.
Chapter 10 Time and Global States
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
Prof. Leonardo Mostarda University of Camerino
Distributed Computing
CSE 486/586 Distributed Systems Global States
Overview of Ordering and Logical Time
Time and Clock.
Distributed Systems CS
Time and Clock.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
湖南大学-信息科学与工程学院-计算机与科学系
Logical Clocks and Casual Ordering
Time And Global Clocks CMPT 431.
Event Ordering.
Outline Theoretical Foundations
Chapter 5 Synchronization
Distributed Systems CS
Physical clock synchronization
Distributed Systems CS
Chap 5 Distributed Coordination
CSE 486/586 Distributed Systems Global States
Jenhui Chen Office number:
CSE 542: Operating Systems
Last Class: Naming Name distribution: use hierarchies DNS
Outline Theoretical Foundations
Presentation transcript:

Chapter 5 (through section 5.4) Synchronization (1) – Clocks, Distributed Snapshots, and Simple Elections Chapter 5 (through section 5.4) Synchronization (1)

Clock Synchronization Physical clocks Try to keep the “right” time. Logical clocks Trying to keep consistent (yet different) time. Vector clocks Establishing “causality.” CS 2510, cs.pitt.edu Synchronization (1)

Physical Clocks Problem: Suppose we have a distributed system with a UTC-receiver somewhere in it we still have to distribute its time to each machine. UTC is Universal Coordinated Time, based on some atomic element (Cs) Basic principle: Every machine has a timer that generates an interrupt H times per second. There is a clock in machine p that ticks on each timer interrupt. Denote the value of that clock by Cp{t}, where t is UTC time. Ideally, we have that for each machine p, Cp{t} = t, or, in other words, dC/dt =1 CS 2510, cs.pitt.edu Synchronization (1)

Clock Synchronization Algorithms In practice: 1 – r <= dC/dt <= 1 + r, for some small constant drift r Goal: Never let two clocks in any system differ by more than d time units  synchronize at least every d/(2r) seconds CS 2510, cs.pitt.edu Synchronization (1)

Clock Synchronization Idea 1: Every machine asks a time server for the accurate time at least once every d/(2r) seconds. Good solution, but need an accurate measure of round trip delay including interrupt handling and processing incoming messages. Idea 2: Let the time server scan all machines periodically, calculate an average, and inform each machine how it should adjust its time relative to its present time. Another good solution, you’ll probably get every machine in sync. Fundamental problem: You’ll have to take into account that setting the time back is never allowed  smooth adjustments. Note: you don’t even need to propagate UTC time. Why not? CS 2510, cs.pitt.edu Synchronization (1)

The Berkeley Algorithm The time daemon asks all the other machines for their clock values The machines answer The time daemon tells everyone how to adjust their clock CS 2510, cs.pitt.edu Synchronization (1)

The Happened-Before Relationship Problem: We first need to introduce a notion of ordering before we can order anything. The happened-before relation on the set of events in a distributed system is the smallest relation satisfying: If a and b are two events in the same process, and a comes before b, then a  b. If a is the sending of a message, and b is the receipt of that message, then a  b. If a  b and b  c, then a  c. Is this a partial or total ordering of events in a system with concurrently operating processes? CS 2510, cs.pitt.edu Synchronization (1)

Logical Clocks Problem: How do we maintain a global view on the system’s behavior that is consistent with the happened-before relation? Solution: attach a timestamp C(e) to each event e, satisfying the following properties: P1: If a and b are two events in the same process, and a  b, then we demand that C(a) < C(b). P2: If a corresponds to sending a message m, and b corresponds to receiving that message, then also C(a) < C(b). Problem: How to attach a timestamp to an event when there’s no global clock  maintain a consistent set of logical clocks, one per process. CS 2510, cs.pitt.edu Synchronization (1)

Logical Clocks Each process Pi maintains a local counter Ci and adjusts this counter according to the following rules: For any two successive events that take place within Pi , Ci is incremented by 1. Each time a message m is sent by process Pi, the message receives a timestamp Tm = Ci Whenever a message m is received by a process Pj, Pj, adjusts its local counter Cj: Cj <= max {Cj + 1, Tm + 1}. Property P1 is satisfied by (1); Property P2 by (2) and (3). CS 2510, cs.pitt.edu Synchronization (1)

Vector Timestamps Observation: Lamport timestamps do not guarantee that if C(a) < C(b) then a indeed happened before b. Why? We need vector timestamps for that. Each process Pi has an array Vi [1..n], where Vi [j] denotes the number of events that process Pi knows have taken place at process Pj. When Pi sends a message m, it adds 1 to Vi [i], and sends Vi along with m as vector timestamp vt(m). Result: upon arrival, the other process knows Pi’s timestamp, and the other time-stamps that Pi is aware of. Question: What does Vi[j] = k mean in terms of messages sent and received? CS 2510, cs.pitt.edu Synchronization (1)

Is the book correct? Is there something wrong? Vector Timestamps When a process Pj receives a message m from Pi with vector timestamp vt(m), it (1) updates each Vj [k] to max {Vj [k], V(m)[k]}, and (2) increments Vj [j] by 1 Is the book correct? Is there something wrong? To support causal delivery of messages, assume you increment your own component only when sending a message. Then, Pj postpones delivery of m until: Vt (m)[i] = Vj [i] + 1 Vt (m)[k] <= Vj [k] for k != i Example: Take V3 = [0,2,2], vt (m) = [1,3,0]. What information does P3 have, and what will it do when receiving m (from P1)? CS 2510, cs.pitt.edu Synchronization (1)

Global State (1) Basic Idea: Sometimes you want to collect the current state of a distributed computation, called a distributed snapshot. It consists of all local states and messages in transit. Important: A distributed snapshot should reflect a consistent state: CS 2510, cs.pitt.edu Synchronization (1)

Global State Note: any process P can initiate taking a distributed snapshot P starts by recording its own local state P subsequently sends a marker along each of its outgoing channels When Q receives a marker through channel C, its action depends on whether it has already recorded its local state: Not yet recorded: it records its local state, and sends the marker along each of its outgoing channels Already recorded: the marker on C indicates that the channel’s state should be recorded: all messages received before this marker and the time Q recorded its own state. Q is finished when it has received a marker along each of its incoming channels. CS 2510, cs.pitt.edu Synchronization (1)

Global State (2) Organization of a process and channels for a distributed snapshot CS 2510, cs.pitt.edu Synchronization (1)

Global State (3) Process Q receives a marker for the first time and records its local state Q records all incoming message Q receives a marker for its incoming channel and finishes recording the state of the incoming channel CS 2510, cs.pitt.edu Synchronization (1)

Election Algorithms Principle: An algorithm requires that some process acts as a coordinator. The question is how to select this special process dynamically. Note: In many systems the coordinator is chosen by hand (e.g. file servers). This leads to centralized solution  single point of failure. Question: If a coordinator is chosen dynamically, to what extent can we speak about a centralized or distributed solution? Question: Is a fully distributed solution, i.e., one without a coordinator, always more robust than any centralized/coordinated solution? CS 2510, cs.pitt.edu Synchronization (1)

Election by Bullying Principle: Each process has an associated priority (weight). The process with the highest priority should always be elected as the coordinator. Issue: How do we find the heaviest process? Any process can just start an election by sending an election message to all other processes (assuming you don’t know the weights of the others). If a process Pheavy receives an election message from a lighter process Plight, it sends a take-over message to Plight. Plight is out of the race. If a process doesn’t get a take-over message back, it wins, and sends a victory message to all other processes. CS 2510, cs.pitt.edu Synchronization (1)

The Bully Algorithm (1) The bully election algorithm Process 4 holds an election Process 5 and 6 respond, telling 4 to stop Now 5 and 6 each hold an election CS 2510, cs.pitt.edu Synchronization (1)

The Bully Algorithm (2) Process 6 tells 5 to stop Process 6 wins and tells everyone CS 2510, cs.pitt.edu Synchronization (1)

A Ring Algorithm Election algorithm using a ring. Synchronization (1) CS 2510, cs.pitt.edu Synchronization (1)