Dr. Kalpakis CMSC621 Advanced Operating Systems Synchronization.

Slides:



Advertisements
Similar presentations
PSSA Preparation.
Advertisements

Synchronization.
Synchronization Chapter clock synchronization * 5.2 logical clocks * 5.3 global state * 5.4 election algorithm * 5.5 mutual exclusion * 5.6 distributed.
1 Chapter 3. Synchronization. STEMPusan National University STEM-PNU 2 Synchronization in Distributed Systems Synchronization in a single machine Same.
Distributed Computing
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED.
Distributed Systems Spring 2009
Chapter 5  Synchronization 1 Synchronization Chapter 5.
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.
Synchronization Part 2 REK’s adaptation of Claypool’s adaptation ofTanenbaum’s Distributed Systems Chapter 5 and Silberschatz Chapter 17.
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.
1 Synchronization  Clock Synchronization  and algorithm.
Clock Synchronization and algorithm
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
CS4513 Distributed Computer Systems Synchronization (Ch 5)
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.
Synchronization.
1 Physical Clocks need for time in distributed systems physical clocks and their problems synchronizing physical clocks u coordinated universal time (UTC)
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,
Synchronization Chapter 6
1 Synchronization. 2 Why Synchronize?  Often important to control access to a single, shared resource.  Also often important to agree on the ordering.
OS2- Sem , R. Jalili Synchronization Chapter 5.
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.
Real-Time & MultiMedia Lab Synchronization Chapter 5.
1 Mutual Exclusion: A Centralized Algorithm a)Process 1 asks the coordinator for permission to enter a critical region. Permission is granted b)Process.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
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.
Distributed Systems Principles and Paradigms Chapter 05 Synchronization.
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.
Real-Time & MultiMedia Lab Synchronization Distributed System Jin-Seung,KIM.
Synchronization Chapter Contents qClock Synchronization qLogical Clocks qGlobal State qElection Algorithms qMutual Exclusion qDistributed Transactions.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
Synchronization Chapter 5. Table of Contents Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
3. Synchronization in Distributed Systems
Chapter 5 Synchronization Presenter: Maria Riaz. Distributed Systems – Fall 2004 – Prof. SY Lee2 Sequence of Presentation Synchronization Clock Synchronization.
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.
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.
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.
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
Distributed Computing
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Prof. Leonardo Mostarda University of Camerino
Chap 5 Distributed Coordination
Last Class: Naming Name distribution: use hierarchies DNS
Presentation transcript:

Dr. Kalpakis CMSC621 Advanced Operating Systems Synchronization

CMSC Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.

CMSC Physical Clocks Implemented via timers Counter + holding register with value H Clock tick = the interrupt generated every H oscillations of a quartz crystal Clock skew = difference in the time readings of different clocks

CMSC Solar Time Transit of the sun = the event of the sun reaching the highest point in the horizon every day Solar day = time duration between two consecutive transits of the sun Solar second = 1/86400 th of the solar day the period of earths rotation is not constant Solar seconds get longer over time!

CMSC Atomic Time Atomic clocks 1 second = the time it takes for the Cesium 133 atom to make 9,192,631,770 transitions Bureau International de LHeure averages the readings fo several atomic clocks to produce the International Atomic Time (TAI) TAI= #seconds since Jan 1, Since solar days get longer over time, keeping time more accurately with atomic clocks leads to problems Over time, noon will be occurring in the early morning hours!

CMSC Atomic Time and leap seconds TAI seconds are of constant length, unlike solar seconds TAI and Solar time can get out of synch over time Leap seconds are introduced when necessary to keep in phase with the sun. Introduced whenever the difference between atomic time and solar time reaches 800 msecs Universal Coordinated Time (UTC) = TAI with leap seconds Total leap seconds in UTC is about 30

CMSC UTC Servers Could also utilize the frequency of AC in power lines for keeping track of time NIST operates the WWV short-wave radio station that broadcasts a pulse at the beginning of each UTC second WWV has is accurate within 1 msec

CMSC Measuring time with the Global Positioning System GPS uses 29 satellites with atomic clocks in an orbit of height about 20,000Km Each satellite broadcasts its location and its local atomic time Receivers can estimate their clock skew Ts since Distance from satellite I = speed of light x (T – Ti) Delay in getting msg from satellite I = (T-Ti) + Tdrift Using 4 satellites, receiver can find its location (x,y,z) and Tdrift by solving a system of 4 eqs. With 4 unknowns

CMSC Physical Clock Synchronization Cp(t) = the local time at p when UTC is t Clock skew = Cp(t) -1 Clock offset wrt t = Cp(t) – t

CMSC Network Time Protocol Estimating As clock offset relative to Bs clock A sends request to B and receives response from B Request and response are timestamped by the local clocks of A and B T1 = time req. is send by A T2 = time req. is received by B T3 = time response is send by B T4 = time response is received by A Assuming the propagation delays are symmetric (ie (T2-T1 = T4-T3), the offset of A relative to B is use the offset corresponding to the least delay among 8 such measurements between A and B If As clock is fast/slow, A slowdowns/fasten gradually over time

CMSC Network Time Protocol Problem: possible that node with morew accurate clock adapts to a less accurate clock! Stratify the nodes Server with reference clock is at stratum 1 A node A adjuststs clock only when it has an offset from a node B with lower stratum, in which case stratum(A) becomes stratum(B)+1

CMSC The Berkeley Algorithm a) The time daemon asks all the other machines for their clock values b) The machines answer c) The time daemon tells everyone how to adjust their clock

CMSC Clock synchronization in wireless networks Reference Broadcasting Synchronization (RBS) Server queries nodes for their times to compute an offset for them Servers clock is left out of the synchronization Assumes no multihop routing Sender sends message Propagation delay is same for all receivers Nodes estimate their offsets from each other T(p,m) = time p receives m Relative offset of node p wrt to node q is Can also estimate relative offset via a linear regression

CMSC Lamport Timestamps a) Three processes, each with its own clock. The clocks run at different rates. b) Lamport's algorithm corrects the clocks.

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

CMSC Global State (1) a) A consistent cut b) An inconsistent cut

CMSC Global State (2) a) Organization of a process and channels for a distributed snapshot

CMSC Global State (3) b) Process Q receives a marker for the first time and records its local state c) Q records all incoming message d) Q receives a marker for its incoming channel and finishes recording the state of the incoming channel

CMSC 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

CMSC Global State (3) d) Process 6 tells 5 to stop e) Process 6 wins and tells everyone

CMSC A Ring Algorithm Election algorithm using a ring.

CMSC 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, when then replies to 2

CMSC A Distributed Algorithm a) Two processes want to enter the same critical region at the same moment. b) Process 0 has the lowest timestamp, so it wins. c) When process 0 is done, it sends an OK also, so 2 can now enter the critical region.

CMSC A Toke Ring Algorithm a) An unordered group of processes on a network. b) A logical ring constructed in software.

CMSC Comparison A comparison of three mutual exclusion algorithms. Algorithm Messages per entry/exit Delay before entry (in message times) Problems Centralized32Coordinator crash Distributed2 ( n – 1 ) Crash of any process Token ring1 to 0 to n – 1 Lost token, process crash

CMSC The Transaction Model (1) Updating a master tape is fault tolerant.

CMSC The Transaction Model (2) Examples of primitives for transactions. PrimitiveDescription BEGIN_TRANSACTIONMake the start of a transaction END_TRANSACTIONTerminate the transaction and try to commit ABORT_TRANSACTIONKill the transaction and restore the old values READRead data from a file, a table, or otherwise WRITEWrite data to a file, a table, or otherwise

CMSC The Transaction Model (3) a) Transaction to reserve three flights commits b) Transaction aborts when third flight is unavailable BEGIN_TRANSACTION reserve WP -> JFK; reserve JFK -> Nairobi; reserve Nairobi -> Malindi; END_TRANSACTION (a) BEGIN_TRANSACTION reserve WP -> JFK; reserve JFK -> Nairobi; reserve Nairobi -> Malindi full => ABORT_TRANSACTION (b)

CMSC Distributed Transactions a) A nested transaction b) A distributed transaction

CMSC Private Workspace a) The file index and disk blocks for a three-block file b) The situation after a transaction has modified block 0 and appended block 3 c) After committing

CMSC Writeahead Log a) A transaction b) – d) The log before each statement is executed x = 0; y = 0; BEGIN_TRANSACTION; x = x + 1; y = y + 2 x = y * y; END_TRANSACTION; (a) Log [x = 0 / 1] (b) Log [x = 0 / 1] [y = 0/2] (c) Log [x = 0 / 1] [y = 0/2] [x = 1/4] (d)

CMSC Concurrency Control (1) General organization of managers for handling transactions.

CMSC Concurrency Control (2) General organization of managers for handling distributed transactions.

CMSC Serializability a) – c) Three transactions T 1, T 2, and T 3 d) Possible schedules BEGIN_TRANSACTION x = 0; x = x + 1; END_TRANSACTION (a) BEGIN_TRANSACTION x = 0; x = x + 2; END_TRANSACTION (b) BEGIN_TRANSACTION x = 0; x = x + 3; END_TRANSACTION (c) Schedule 1x = 0; x = x + 1; x = 0; x = x + 2; x = 0; x = x + 3Legal Schedule 2x = 0; x = 0; x = x + 1; x = x + 2; x = 0; x = x + 3;Legal Schedule 3x = 0; x = 0; x = x + 1; x = 0; x = x + 2; x = x + 3;Illegal (d)

CMSC Two-Phase Locking (1) Two-phase locking.

CMSC Two-Phase Locking (2) Strict two-phase locking.

CMSC Pessimistic Timestamp Ordering Concurrency control using timestamps.