Synchronization. Why we need synchronization? It is important that multiple processes do not access shared resources simultaneously. Synchronization in.

Slides:



Advertisements
Similar presentations
Global States.
Advertisements

Last Class: Clock Synchronization
Synchronization.
Logical Clocks.
Time and Global States Part 3 ECEN5053 Software Engineering of Distributed Systems University of Colorado, Boulder.
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
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED.
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.
Centralized Architectures
Synchronization in Distributed Systems. Mutual Exclusion To read or update shared data, a process should enter a critical region to ensure 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.
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.
EEC-681/781 Distributed Computing Systems Lecture 10 Wenbing Zhao Cleveland State University.
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.
1 Synchronization Part 1 REK’s adaptation of Claypool’s adaptation of Tanenbaum’s Distributed Systems Chapter 5.
Synchronization Chapter 6 Part I Clock Synchronization & Logical clocks Part II Mutual Exclusion Part III Election Algorithms Part IV Transactions.
Synchronization.
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.
Naming CSCI 4780/6780. Attribute-based Naming Flat and structured names provide location transparency Structured names are also human-friendly Increasingly,
Logical Clocks n event ordering, happened-before relation (review) n logical clocks conditions n scalar clocks condition implementation limitation n vector.
Computer Science Lecture 10, page 1 CS677: Distributed OS Last Class: Naming Name distribution: use hierarchies DNS X.500 and LDAP.
Page 1 Logical Clocks Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation is.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
Lamport’s Logical Clocks & Totally Ordered Multicasting.
Chapter 5 Synchronization Clocks and Synchronization Algorithms Lamport Timestamps and Vector Clocks Distributed Snapshots Termination Detection Election.
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.
Communication & Synchronization Why do processes communicate in DS? –To exchange messages –To synchronize processes Why do processes synchronize in DS?
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.
Distributed Coordination. Turing Award r The Turing Award is recognized as the Nobel Prize of computing r Earlier this term the 2013 Turing Award went.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
Logical Clocks. Topics Logical clocks Totally-Ordered Multicasting Vector timestamps.
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.
Logical Clocks. Topics r Logical clocks r Totally-Ordered Multicasting.
Event Ordering. CS 5204 – Operating Systems2 Time and Ordering The two critical differences between centralized and distributed systems are: absence of.
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.
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.
6.2 Logical Clocks Kranthi Koya09/23/2015. Overview Introduction Lamport’s Logical Clocks Vector Clocks Research Areas Conclusion.
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
Lecture on Synchronization Submitted by
Synchronization in Distributed Systems In a single CPU system, critical regions, mutual exclusion and other synchronization problems are generally solved.
Logical Clocks event ordering, happened-before relation (review) logical clocks conditions scalar clocks  condition  implementation  limitation vector.
Logical time Causality between events is fundamental to the design of parallel and distributed systems. In distributed systems, it is not possible to have.
Prof. Leonardo Mostarda University of Camerino
CSC 8320 Advanced Operating Systems Spring 2006
CSC 8320 Advanced Operating System
SYNCHORNIZATION Logical Clocks.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Time And Global Clocks CMPT 431.
Chapter 5 Synchronization
Distributed Systems CS
Chapter 5 (through section 5.4)
Last Class: Naming Name distribution: use hierarchies DNS
Outline Theoretical Foundations
Presentation transcript:

Synchronization

Why we need synchronization? It is important that multiple processes do not access shared resources simultaneously. Synchronization in a distributed system is difficult since each processes may be using its own clock time. In Distributed system there must be a global agreement on time.

Clock synchronization As an example consider UNIX make program. Normally in Unix, large programs are split up into multiple source files,so to change one source file only require one file to be recompiled not all files. Consider a program which consist of 100 files.When the programmer has finished changing all source files, he runs the make which examines the time at which all source and object files were last modified.

If the source file input.c has time 2151and the corresponding object file input. o has time 2150, make knows that input.c has been changed since input. o was created and thus input.c must be recompiled. If input.c has time 2144 and output.c has time 2145, no compilation is needed.

Thus make goes through all the source files to find out which one need to be recompiled and calls the compiler to recompile them.

What could happen in a distributed system in which there is no global agreement on time?

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.

Therefore make will not call the compiler and the resulting binary program will contain a mixture of object file from the old source and new source program and pgm may crash.

Physical clocks A computer timer is precisely machined quartz crystal. Associated with each crystal are two registers counter, holding register. It is possible to program a timer to generate an interrupt 60 times a second, or at any other desired frequency. Each interrupt is called one clock tick.

Physical clocks A computer timer is precisely machined quartz crystal. Associated with each crystal are two registers counter, holding register. It is possible to program a timer to generate an interrupt 60 times a second, or at any other desired frequency. Each interrupt is called one clock tick.

When a system has n computers, all n crystals will run at slightly different rates, causing the clocks gradually to get out of synchronization and give different values when read out. This difference in time values is called clock skew.

The berkeley algorithm

Figure 6-7. (a) The time daemon asks all the other machines for their clock values.

Figure 6-7. (b) The machines answer.

Figure 6-7. (c) The time daemon tells everyone how to adjust their clock.

Logical clocks

Lamport’s Logical clock In 1978 Lamport pointed out that processes must agree on the order in which events occur also must be synchronized. He developed an algorithm for that.

Lamport’s Logical clock For synchronization Lamport defined a relation called happens-before. The expression a -> b a happens before b means that all processes agree that first event a occurs then event b occurs.

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

Figure 6-9. (a) Three processes, each with its own clock. The clocks run at different rates.

Figure 6-9. (b) Lamport’s algorithm corrects the clocks.

Lamport’s Logical Clocks (4) Figure The positioning of Lamport’s logical clocks in distributed systems.

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.

Example: Totally Ordered Multicasting Figure Updating a replicated database and leaving it in an inconsistent state.

Vector clock

Vector clocks is an algorithm for generating a partial ordering of events in a distributed system and detecting causality violations.

Casuality If I send you a message, and you then send one to someone else, your message is causally related to mine because its possible that whatever was in my message influenced the message you sent. However, if I send my message to a third party, it no longer causally precedes yours because you couldn't have reacted to what I sent.

Just as in Lamport timestamps, interprocess messages contain the state of the sending process's logical clock. A vector clock of a system of N processes is an array of N logical clocks, one per process, a local copy of which is kept in each process with the following rules for clock updates:

Rules for clock updates Initially all clocks are zero. Each time a process experiences an internal event, it increments its own logical clock in the vector by one. Each time a process prepares to send a message, it increments its own logical clock in the vector by one and then sends its entire vector along with the message being sent.

Rules for clock updates Each time a process receives a message, it increments its own logical clock in the vector by one and updates each element in its vector by taking the maximum of the value in its own vector clock and the value in the vector in the received message (for every element)

Vector Clocks Figure Concurrent message transmission using logical clocks.

Vector Clocks Vector clocks are constructed by letting each process P i maintain a vector VC i with the following two properties: 1.VC i [ i ] is the number of events that have occurred so far at P i. In other words, VC i [ i ] is the local logical clock at process P i. 2.If VC i [ j ] = k then P i knows that k events have occurred at P j. It is thus P i ’s knowledge of the local time at P j.

Vector Clocks Steps carried out to accomplish property 2 of previous slide: 1.Before executing an event P i executes VC i [ i ] ← VC i [i ] When process P i sends a message m to P j, it sets m’s (vector) timestamp ts (m) equal to VC i after having executed the previous step. 3.Upon the receipt of a message m, process P j adjusts its own vector by setting VC j [k ] ← max{VC j [k ], ts (m)[k ]} for each k, after which it executes the first step and delivers the message to the application.