Clock Synchronization

Post on 21-May-2017

238 views 3 download

Transcript of Clock Synchronization

CLOCK SYNCHRONIZATION

Prepared by:Megha Naruka07CS000042

Introduction The technique used to coordinate a

common time notion among processes is known as Clock Synchronization.

Clock synchronization deals with understanding the temporal ordering of events produced by concurrent processes.

Goal Goal of Clock Synchronization is that

multiple unrelated processes running on different machines should be in agreement with and be able to make consistent decisions about the ordering of events in a system.

For this event, we introduce the Concept of logical Clocks.

Time in Distributed System Time is a key Factor in DS to analyze how

distributed execution evolve. Each computer is equipped with a

physical clock. It can be viewed as a counter

incremented by ticks of a oscillator.

Problems Lacking of global reference time: it's hard

to know the state of a process during a distributed computation.

However, it's important for processes to share a common time notion.

Why clock Synchronization important??

UNIX make command is used to compile source code.

Typically a large UNIX program is spitted in several files.

A change to one source file only requires that file to be compiled.

Make goes through all the source files to find out which one needs to be recompiled.

It examines the time in which source and object files were last modified.

If the source file was last modified after the object file ,make calls the compiler to recompile it.

Let’s suppose to have editor and compiler running on two different machines, with no global agreement on time.

Suppose the output.o has time 2144 and shortly after output.c is modified but is assigned time

2143 because the clock on that machine is slower.

Make will not call the compiler. The executable program will contain a mixture

of code that probably will lead to an unpredictable behavior.

Physical Clocks A computer timer is usually a precisely machined

quartz crystal. When kept under tension, quartz crystals

oscillate at a well-defined frequency that depends on the kind of crystal.

Associated with each crystal are two registers, a counter and a holding register.

Each oscillation of the crystal decrements the counter by one. When the counter gets to zero, an interrupt is generated and the counter is reloaded from the holding register.

Each interrupt is called one clock tick.

Global Positioning System GPS is a satellite-based distributed

system that was launched in 1978. 29 Satellites at an orbit of 20000km

above Earth. Each Satellite has four atomic clocks,

which are regularly calibrated from Earth. A GPS receiver can compute its own

position using three satellites, assuming that the receiver has accurate time. Otherwise it requires four satellites.

Real World Facts that Complicate GPS

It takes a while before data on a satellite’s position reaches the receiver.

The receiver’s clock is generally not in sync with that of a satellite.

Network Time Protocol A common approach in many protocols

and originally proposed by Cristian (1989) is to let clients contact a time server.

The latter can accurately provide the current time, for example, because it is equipped with a WWV receiver or an accurate clock.

The problem, of course, is that when contacting the server, message delays will have outdated the reported time.

Berkeley Algorithm In Berkeley UNIX, the time server is active. polling every machine from time to time to ask

what time it is there. Based on the answers, it computes an average

time and tells all the other machines to advance their clocks to the new time or slow their clocks down until some specified reduction has been achieved.

This method is suitable for a system in which no machine has a WWV receiver.

The time server time must be set manually by the operator periodically.

Lamport’s Logical clock synchronization

To synchronize logical clocks, Lamport defined a relation called happens-before.

The expression a b is read “ a happens before b” and means that all processes agree that first event ‘a’ occurs, then afterward, event ‘b’ occurs.

Happens-before is a transitive relation. If two events x and y, happen in different processes that do not exchange messages, then x y is not true, but neither is y x. These events are said to be concurrent.

The happens-before relation can be observed directly in two situations:

1. If ‘a’ and ‘b’ are events in the same process and ‘a’ occurs before ‘b’, then a b is true.

2. 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 is also true.

Vector’s Clock Vector clocks are constructed by letting each

process Pi maintain a vector VCi with the following two properties:

1. VCi [ i ] is the number of events that have occurred so far at Pi. In other words, VCi [ i ] is the local logical clock at process Pi .

2. If VCi [ j ] = k then Pi knows that k events have occurred at Pj. It is thus Pi’s knowledge of the local time at Pj

THANK YOU