CS 5523 Operating Systems: Synchronization in Distributed Systems

Similar documents
CS 5523: Operating Systems

CS 5523 Operating Systems: Intro to Distributed Systems

CS 5523: Operating Systems

Last Time. Bit banged SPI I2C LIN Ethernet. u Embedded networks. Ø Characteristics Ø Requirements Ø Simple embedded LANs

Cyber-Physical Systems Scheduling

Dependability in Distributed Systems

Cyber-Physical Systems Feedback Control

Processes. Criteria for Comparing Scheduling Algorithms

Real-Time Scheduling Single Processor. Chenyang Lu

Downloaded from: justpaste.it/vlxf

Adaptive QoS Control for Real-Time Systems

A logic for making hard decisions

A Calculus for End-to-end Statistical Service Guarantees

Key Considerations for Implementing Bodies and Oversight Actors

The Issue Of Internet Polling

Statement on Security & Auditability

Batch binary Edwards. D. J. Bernstein University of Illinois at Chicago NSF ITR

General Framework of Electronic Voting and Implementation thereof at National Elections in Estonia

TERMS OF USE FOR PUBLIC LAW CORPORATION PERSONAL CERTIFICATES FOR AUTHENTICATION

Awodele, 0.,1 Ajayi, 0.B.,2 and Ajayi, LA. 3

SMS based Voting System

Servilla: Service Provisioning in Wireless Sensor Networks. Chenyang Lu

File Systems: Fundamentals

HASHGRAPH CONSENSUS: DETAILED EXAMPLES

Final Review. Chenyang Lu. CSE 467S Embedded Compu5ng Systems

ISSUES AND PROPOSED SOLUTIONS

Fall Detection for Older Adults with Wearables. Chenyang Lu

UNCITRAL E-SIGN UETA COMPARISON 1

Key Considerations for Oversight Actors

In The District Court of County, Kansas

Economic and Social Council

Why Biometrics? Why Biometrics? Biometric Technologies: Security and Privacy 2/25/2014. Dr. Rigoberto Chinchilla School of Technology

CPSC 467b: Cryptography and Computer Security

GENERAL ASSEMBLY OF NORTH CAROLINA SESSION 1999 S 1 SENATE BILL 1266

Internet of Things Wireless Sensor Networks. Chenyang Lu

State Election Commission Maharashtra (EMP)

Federal Spending Transparency: Unlocking the Power of Abstraction

IC Chapter 15. Ballot Card and Electronic Voting Systems; Additional Standards and Procedures for Approving System Changes

Estonian National Electoral Committee. E-Voting System. General Overview

Practical Application of Precision Time Protocol: Campus path measurement, Smart SFP reflectors, IEEE1588 grandmaster clocks, and stuff.

M-Vote (Online Voting System)

Concurrent Programing: Why you should care, deeply. Don Porter Portions courtesy Emmett Witchel

Contributary Platform User Terms of Service

CHE 572: Modelling Process Dynamics

CS 2461: Computer Architecture I

L14. Electronic Voting

Congressional Forecast. Brian Clifton, Michael Milazzo. The problem we are addressing is how the American public is not properly informed about

Union Elections. Online Voting. for Credit. Helping increase voter turnout & provide accessible, efficient and secure election processes.

Your jargon buster for your litigation case.

Secure and Fault-Tolerant Voting in Distributed Systems

THE PROPOSAL OF GIVING TWO RECEIPTS FOR VOTERS TO INCREASE THE SECURITY OF ELECTRONIC VOTING

CASE TRANSLATION: GREECE

As Introduced. 132nd General Assembly Regular Session S. B. No

MARYLAND Maryland MVA Real ID Act - Impact Analysis

INTESI GROUP S.p.A. Via Torino, Milano, Italia - Tel: P.IVA e C.F

CANADIAN ANTI-SPAM LAW [FEDERAL]

HOUSE OF REPRESENTATIVES AS REVISED BY THE COMMITTEE ON BUSINESS DEVELOPMENT AND INTERNATIONAL TRADE FINAL BILL RESEARCH & ECONOMIC IMPACT STATEMENT

Dear friend, Sincerely yours, Founders of the SPARTA cryptocurrency!

The purchase of new voting equipment

COMP 635: WIRELESS & MOBILE COMMUNICATIONS COURSE INTRODUCTION. Jasleen Kaur. Fall 2017

IN-POLL TABULATOR PROCEDURES

Opportunities in Communication

SECURITY, ACCURACY, AND RELIABILITY OF TARRANT COUNTY S VOTING SYSTEM

Midterm Review. EECS 2011 Prof. J. Elder - 1 -

ADAMS ISP SERVICES AGREEMENT and NETWORK MANAGEMENT POLICY

WEBSITE TERMS OF USE AGREEMENT

MSC TRUSTGATE.COM RELYING PARTY AGREEMENT

16 March Purpose & Introduction

TELECOMMUNICATIONS ORDINANCE (Chapter 106) WIRELESS INTERNET OF THINGS LICENCE. [Company Name]... [Address]

Testimony before Senate Budget Subcommittee 4 on Implementation of the Federal Real ID Act of 2005

CHAPTER 2 LITERATURE REVIEW

Strengthen Stewardship With Electronic Giving

Ranked Voting and Election Integrity

ForeScout Extended Module for McAfee epolicy Orchestrator

Allegheny Chapter. VotePA-Allegheny Report on Irregularities in the May 16 th Primary Election. Revision 1.1 of June 5 th, 2006

CSE 520S Real-Time Systems

Etherparty Terms of Use. Last Updated: April 2, 2018

Philips Lifeline. Ø Chenyang Lu 1

YOOCHOOSE GmbH Terms and Conditions Subject Matter

This Addendum Number 1 to the above referenced IFB responds to a clarification question asked with the MST response.

Computational Social Choice: Spring 2007

Case Study. MegaMatcher Accelerator

VLSI Design I; A. Milenkovic 1

Liveness: The Readers / Writers Problem

Real-Time Wireless Control Networks for Cyber-Physical Systems

L9. Electronic Voting

Amendment to the Infinite Campus END USER LICENSE AGREEMENT

1 ELECTRONIC COMMUNICATIONS IN CONTRACTUAL TRANSACTIONS 2 DRAFT TABLE OF CONTENTS 3 PART 1 4 GENERAL PROVISIONS

An Application of time stamped proxy blind signature in e-voting

27 July 2017 Without prejudice TITLE [XX] DIGITAL TRADE

Attachment 1. Workflow Designs. NOTE: These workflow designs are for reference only and should not be considered exact specifications or requirements.

Ballot Reconciliation Procedure Guide

TECHNICAL ADVISORY GROUP ON MACHINE READABLE TRAVEL DOCUMENTS (TAG-MRTD)

Risk-Limiting Audits for Denmark and Mongolia

Cost Implications of State Ownership of the Verbatim Record in California

A procedure to compute a probabilistic bound for the maximum tardiness using stochastic simulation

Additional Case study UK electoral system

Voting Methods for Municipal Elections: Propaganda, Field Experiments and what USA voters want from an Election Algorithm

IT COMMITTEE Agenda Administration Conference Room Thursday, March 21, :00 p.m.

MINISTRY OF COMMUNICATIONS AND INFORMATION TECHNOLOGY (Department of Information Technology) NOTIFICATION New Delhi, the 11th April, 2011

Transcription:

CS 5523 Operating Systems: Synchronization in Distributed Systems Instructor: Dr. Tongping Liu Thank Dr. Dakai Zhu and Dr. Palden Lama for providing their slides. Outline Physical clock/time in distributed systems Ø No global time is available Ø Network Time Protocol Ø Berkeley Algorithm Logical clock/time and Happen Before Relation Ø Lamport s logical clock à total ordering multicast Ø Vector clocks à Causally ordering Mutual Exclusion: Distributed synchronizations Ø De/Centralized algorithms Ø Distributed algorithms (Ricart & Agrawala) Ø Logical token ring 2 Objectives To understand synchronization and related issues in DS # To learn about clocks and how to sync them# # Misconceptions about Distributed Systems The same globe time Perfect network/communication Ø Latency is zero Ø Bandwidth is infinite Ø The network is reliable Ø The network is secure Ø The network is homogeneous The topology does not change There is one administrator 4 1

Time in Physical World What is a second? Time it takes the cesium 133 atom to make exactly 9,192,631,770 transitions. International Atomic Time is based on very accurate physical clocks (drift rate 10-13 ) It is based on atomic time, but occasionally adjusted to astronomical time Computer Clocks and Timing Events Each computer has its own internal clock: quartz cystal Ø Used by local processes to obtain current time value Problems with quartz Ø Drift rate: the difference per unit of time from some ideal reference Ø Ordinary quartz clocks drift by about 1 sec in 11-12 days (10-6 secs/sec). Ø High precision quartz clocks drift rate is about 10-7 or 10-8 secs/sec Clock Skew: difference between times on two clocks (at any instant) 5 6 Computer Clocks and Timing Events Processes on different computers can timestamp their events using their own clocks Ø Clocks on different computers may give different times Ø Computer clocks drift from perfect time and their drift rates differ from one another How to sync N clocks with a global clock? Let each computer have a UTC(Universal Coordinated Time) receiver.# Ordinary quartz : ±10ms might be too much for some applications (e.g., GPS)# It might be costly (e.g., in case of sensor nodes)# Indoor equipment may not get the UTC signals# Netw ork 7 We may have some nodes with a UTC receiver, then can we sync others with those nodes?# What if none have UTC receiver, can we sync them with each other?# 2

Clock Synchronization Algorithms All algorithms have the same system model:# Ø Each machine has a timer causing H interrupts/sec. # Ø The interrupt handler adds 1 to software clock C # Ø C keeps track of the number of ticks since some agreedupon time in the past# l Let C p (t) be the clock at p when the UTC time is t, #! In a perfect world, C p (t) = t (i.e., frequency C p (t)=dc/dt=1 )# l The skew of a clock is C p (t) 1# l The offset relative to a specific time is C p (t) t# Clock Synchronization Algorithms n Real timers do not tick exactly H times per second. For example, H=60 should generate 216,000 thick per hour but it may range 215,998 to 216,002 per hour# So if there exists a constant p: # # 1- ρ dc/dt 1+ ρ # #then, timer is working within its specifications# #ρ (maximum drift rate) is given by the manufacturer # n How often two clocks should be synchronized?# Clock Synchronization Algorithms If two clocks are drifting from UTC in the opposite directions, they would be apart as much as 2ρ Δt n So if want to guarantee that no two clocks ever differ by more than δ (i.e., 2ρ Δt < δ) then we should sync them Δt < δ/2ρ seconds n Various algorithms differ in precisely how to do this resync! l NTP (Network Time Protocol) l The Berkeley algorithm l Clock sync in wireless networks NTP (Network Time Protocol) At least one machine has a UTC receiver Suppose we have a server with UTC receiver. # The server has an accurate clock# So clients can simply contact it and get the accurate time (every δ/2ρ sec) # n A gets T1, T2, T3, T4. # n How should A adjust its clock?# n The problem is the delay which causes inaccuracy# Accurate 3

NTP: basic idea Suppose propagation delay is the same in both ways? Assume dt req =dt res# A can estimate offset value to B(θ)# θ = T3 + ((T2-(T1+θ)) #+((T4+θ)-T3))/2 T4# = ((T3-T4) + (T2-T1))/2# ## Confuse: the object file is earlier than the source θ > 0, A is slower# θ < 0, A is faster, but time cannot run backward?# Introduce the difference gradually# NTP At least one machine has a UTC receiver Use this basic idea in a pairwise manner to distribute time information over the Internet. # Objectives# Ø Enable clients on Internet to synchronize to UCT # Ø Reliable service through redundant servers/paths# Ø Provide protection against interference with the time service, whether malicious or accidental# Need: accurate measure of round trip delay, interrupt handling & processing messages# NTP (cont.) Outline Provided by a network of servers located across the Internet# Primary servers are connected to UCT sources and time server is passive# Secondary servers are synchronized to primary servers# Synchronization subnet - lowest level servers in users computers# 3 2 1 3 3 2 15 Physical clock/time in distributed systems Ø No global time is available Ø Network Time Protocol Ø Berkeley Algorithm Logical clock/time and Happen Before Relation Ø Lamport s logical clock à total ordering multicast Ø Vector clocks à Causally ordering Mutual Exclusion: Distributed synchronizations Ø De/Centralized algorithms Ø Distributed algorithms (Ricart & Agrawala) Ø Logical token ring Election Algorithms 16 4

Berkeley Algorithm No machine has UTC receiver Berkeley Algorithm No machine has UTC receiver Operator manually sets the time at the time server (daemon)# Time server is active and does the followings:# Ø periodically poll all machines# Ø compute the average and # Ø tell other machines to adjust their times # ü gradually slow down or advance the clock# Time does not need to be the actual time # As long as all machines agree, then that is OK for many applications# Gradually advance or slow down the clock # Outline Time in Distributed Systems Physical clock/time in distributed systems Ø No global time is available Ø Network Time Protocol Ø Berkeley Algorithm Logical clock/time and Happen Before Relation Ø Lamport s logical clock à total ordering multicast Ø Vector clocks à Causally ordering Mutual Exclusion: Distributed synchronizations Ø De/Centralized algorithms Ø Distributed algorithms (Ricart & Agrawala) Ø Logical token ring Election Algorithms There is no global clock in a distributed system Logical time is an alternative Ø Order of events - also useful for consistency of replicated data Algorithms for clock synchronization are useful for Ø concurrency control based on timestamp ordering Ø Consistency in distributed transactions Ø checking the authenticity of requests 19 20 5

Logical Time The order of two events occurring at two different computers cannot be determined based on their local time. Problem: How do we maintain a global view on the system s behavior that is consistent with the happened-before relation Why Logic Clock from Lamport If two processes do not interact, it is not necessary that their clocks be synchronized because the lack of synchronization would not be observable and thus could not cause problems. What matters is the they agree on the order in which events occur. The notion of logical time/clock is fairly general and constitutes the basis of many distributed algorithms 21 22 Happened Before Relation Happened Before : Partial Order Lamport first defined a happened before relation (à) to capture the causal dependencies between events. p 1 a b m 1 Same process: A à B, if A and B are events in the same process and A occurred before B. p 2 c d m 2 Phy si cal ti me Different processes: A à B, if A is the event of sending a message m in a process and B is the event of the receipt of the same message m by another process. If AàB, and B à C, then A à C (happened-before relation is transitive). p 3 e a b (at p1); c d (at p2); b c ; also d f Not all events are related by the relation Ø a and e (different processes and no message chain) Ø they are not related by Ø they are said to be concurrent (written as a e) f 23 24 6

Logical Clocks (Lamport, 1978) 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: For different processes, if a corresponds to sending a message m, and b to the receipt of that message, then also C(a) < C(b). How to get timestamp à consistent logical clocks Logical Clocks (Lamport, 1978) Each process Pi maintains a logical clock, which is a monotonically increasing software counter (no relation to physical clock) Update the logical clock/counter following Ø 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 ts(m) = Ci; Ø Whenever a message m is received by a process Pj, Pj adjusts its local counter Cj to max{cj, ts(m)+1} 25 26 Logical Clock: Example Logical Clock: Where to Put It? The positioning of Lamport s logical clocks in distributed systems 27 28 7

Logical Clock: Properties e à e implies L(e) < L(e ) An Example: Logical Clock Application Updating a replicated database (Initially $1000) The converse is not true, that is L(e) < L(e') does not imply e à e. Add $100 Add 1% interest Lamport s happened before relation defines an irreflexive partial order among the events in the distributed system Result $1111 Result $1110 Two updates should perform in the same order. But which one is first is not important! 29 30 Totally-Ordered Multicast Consider a group of n distributed processes, m n processes multicasts update messages Ø How to guarantee that all the updates are performed in the same order by all the processes? Assumptions Ø No messages are lost (Reliable delivery) Ø Messages from the same sender are received in the order they were sent (FIFO) Ø A copy of each message is also sent to the sender Totally-Ordered Multicast (cont.) Process P i sends time stamped message msg i to all others. The message itself is put in a local queue queue i. Any incoming message at P j is queued in queue j, according to its timestamp, and acknowledged to every other process. P j passes a message msg i to its application if: Ø (1) msg i is at the head of queue j Ø (2) for each process P k, there is a acknowledgement message msg k in queue j with a larger timestamp. 31 32 8

Outline Physical clock/time in distributed systems Ø No global time is available Ø Network Time Protocol Ø Berkeley Algorithm Logical clock/time and Happen Before Relation Ø Lamport s logical clock à total ordering multicast Ø Vector clocks à Causally ordering Mutual Exclusion: Distributed synchronizations Ø De/Centralized algorithms Ø Distributed algorithms (Ricart & Agrawala) Ø Logical token ring Problem with Lamport s Clocks Observation: Lamport s clocks do not guarantee that if C(a) < C(b) that a causally preceded b: Ø Event a: m1 is received at T = 16. Ø Event b: m2 is sent at T = 20. We cannot conclude that a causally precedes b. 33 34 Vector Clocks Vector Clocks: Update Vector clocks are constructed by letting each process P i maintain a vector VC i with the following two properties Ø 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. Ø If VC i [ j ] = k then P i knows that k events have occurred at P j. It is P i s knowledge of the local time at P j. Rule 1: Before executing an event, P i executes VC i [ i ] VC i [i ] + 1. Rule 2: When process P i sends m to P j, it sets m s (vector) timestamp ts (m) = VC i after Rule 1; Rule 3: Upon the receipt of m, process P j adjust VC j [k ] max{vc j [k ], ts (m)[k ]} for each k, after which it executes Rule 1 and delivers m to the application It is possible to ensure that a message is delivered only if all messages that causally precede it have been received 35 36 9

Causally-Ordered Multicasting Causally-Ordered Multicasting Ensure to deliver a message only if all causally preceding messages have already been delivered P j postpones delivery of m from P i until: Ø R1: ts(m)[i] = VC j [i] + 1; à m is the next message expected from P i For P 2, when receive m* from P 1, ts(m*) = (1,1,0), but VC 2 = (0,0,0); m* is delayed as P 2 didn t see message from P 0 before; Whe P 2 receive m from P 0, ts(m)=(1,0,0), with VC2=(0,0,0) à both R1 and R2 is ok, and m is delivered à VC2 = (1,0,0), then m* is delivered Ø R2: ts(m)[k] VC j [k] for k i à P j see all messages that have been seen by P i when it sent out message m. 37 38 Outline Physical clock/time in distributed systems Ø No global time is available Ø Network Time Protocol Ø Berkeley Algorithm Logical clock/time and Happen Before Relation Ø Lamport s logical clock à total ordering multicast Ø Vector clocks à Causally ordering Mutual Exclusion: Distributed synchronizations Ø De/Centralized algorithms Ø Distributed algorithms (Ricart & Agrawala) Ø Logical token ring Mutual Exclusion in Distributed Systems To ensure exclusive access to some resource for processes in a distributed system Ø Permission-based vs. token-based approaches Solutions Ø Centralized server; Ø Decentralized, using a peer-to-peer system; Ø Distributed, with no topology imposed; Ø Completely distributed along a (logical) ring; 39 40 10

Centralized Server to Grant the Permission Decentralized Mutual Exclusion Good: mutual exclusion, fair, no starvation What is the problem with this scheme? Coordinate is the single point of failure. Other processes can t distinguish from permission denied. Coordinator can be performance bottleneck. 41 Assumptions: Ø Assume every resource is replicated n times, with each replica having its own coordinator Ø A coordinator always responds immediately to a request. Ø Access requires a majority vote from m > n/2 coordinators; Ø When a coordinator crashes, it will recover quickly, but will have forgotten about permissions it had granted. Probabilistic correct solution Ø With n=32, m=0.75n à incorrect permission grant: 10-40 42 Distributed: Ricart & Agrawala Logical Token Ring Same as Lamport, except that ack aren t sent. Instead, replies (i.e. grants) are sent only when: Ø Receive process has no interest in the shared resource; or Ø Receive process is waiting for the resource, but has lower priority (known through comparison of timestamps) Processes in a logical ring, and let a token be passed between them. The one that holds the token is allowed to enter the critical region (if it wants to) What if the token is lost?! Two processes are asking for the same resource 43 44 11

Token-based solutions Performance Passing a special message between the processes Ø There is only one token Ø Who has the token is allowed to access the shared resources Good: Ø Ensure that every process will get a chance (no starvation) Ø No deadlocks Bad: Ø When token is lost, difficult to create a new one that is the only token 45 46 Summary Physical clock/time in distributed systems Ø No global time is available Logical clock/time and Happen Before Relation Ø Lamport, 1978 Ø Application: total ordering multicast à consistency Vector clocks Ø Causally ordering Distributed synchronizations Ø De/Centralized server Ø Distributed algorithms (Ricart & Agrawala) Ø Logical token ring 47 12