Вы находитесь на странице: 1из 21

Prepared by: Megha Naruka 07CS000042

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 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 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.

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.

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.

Lets 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.

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.

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.

It takes a while before data on a satellites position reaches the receiver. The receivers clock is generally not in sync with that of a satellite.

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.

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.

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.

1.

2.

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

1.

2.

Vector clocks are constructed by letting each process Pi maintain a vector VCi with the following two properties: 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 . If VCi [ j ] = k then Pi knows that k events have occurred at Pj. It is thus Pis knowledge of the local time at Pj

THANK YOU

Вам также может понравиться