Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
0Activity
0 of .
Results for:
No results containing your search query
P. 1
9.Clock Syncronisation

9.Clock Syncronisation

Ratings: (0)|Views: 0 |Likes:
Published by Shashank Gosavi
code
code

More info:

Categories:Types, School Work
Published by: Shashank Gosavi on May 14, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

05/14/2013

pdf

text

original

 
Aim:
To study and implement clock synchronization.
Theory:
Clock synchronization is a problem fromcomputer scienceandengineeringwhich deals with the idea that internalclocksof several computers may differ. Even when initially setaccurately, real clocks will differ after some amount of time due toclock drift,caused byclocks counting time at slightly different rates. There are several problems that occur as arepercussion of rate differences and several solutions, some being more appropriate thanothers in certain contexts.
Problems:
Besides the incorrectness of the time itself, there are problems associated with clock skewthat take on more complexity in adistributed systemin which several computers willneed to realize the same global time.For instance, inUnixsystems themakecommand is used tocompilenew or modified code without the need to recompile unchanged code.The make command uses the clock of the machine it runs on to determine which sourcefiles need to be recompiled. If the sources reside on a separatefile server and the twomachines have unsynchronized clocks, the make program might not produce the correctresults.
Solutions:
In acentralized systemthe solution is trivial; the centralized server will dictate the systemtime.Cristian's algorithmand theBerkeley Algorithmare some solutions to the clock  synchronization problem in a centralized server environment. In adistributed systemthe problem takes on more complexity because a global time is not easily known. The mostused clock synchronization solution on the Internet is the Network Time Protocol (NTP) which is a layered client-server architecture based on UDP message passing.LamporttimestampsandVector clocksare concepts of the logical clocks in distributed systems.
Cristian’s Algorithm:
Cristian's Algorithm is a method for clock synchronisationwhich can be used in manyfields of distributive computer science but is primarily used in low-latencyintranets. Cristian observed that this simple algorithm is probabilistic, in that it only achievessynchronisation if theround-trip time(RTT) of the request is short compared to requiredaccuracy. It also suffers in implementations using a single server, making it unsuitable for many distributive applications where redundancy may be crucial.
 
Cristian's Algorithm
works between a process P and a time server S— connected to asource of UTC(Coordinated Universal Time). Put simply:1.P requests the time from S2.After receiving the request from P, S prepares a response and appends the time Tfrom its own clock.3.P then sets its time to be T + RTT/2P needs to record the Round Trip Time (RTT) of the request it made to S so that it can setits clock to T + RTT/2. This method assumes that the RTT is split equally between bothrequest and response, which may not always be the case but is a reasonable assumptionon a LAN connection.Further accuracy can be gained by making multiple requests to S and using the responsewith the shortest RTT. We can estimate the accuracy of the system as follows. Let min bethe minimum time to transmit a message one-way. The earliest point at which S couldhave placed the time T was min after P sent its request. Therefore the time at S when themessage is received by P is in the range (T + min) to (T + RTT - min). The width of thisrange is (RTT - 2*min). This gives an accuracy of (RTT/2 - min).
Conclusion:
Thus we have studied and implemented Clock Synchronization.
 
#include<iostream.h>#include<conio.h>void main(){clrscr();int i,n,j=1;int t[10];int c[10],s,r;cout<<"enter the number of processes"<<endl;cin>>n;for(i=1;i<=n;i++){cout<<"enter the id of process \t"<<i<<endl;cin>>c[i];cout<<"Enter the timestamp of process \t"<<i<<endl;cin>>t[i];}cout<<"\t Processes"<<"\t Timestamp"<<endl;for(i=1;i<=n;i++){cout<<"\t "<<c[i]<<"\t\t "<<t[i]<<endl;}while(j==1)

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->