0% found this document useful (0 votes)
6 views23 pages

Chapter 6 Synchronization

The document discusses real-time systems, emphasizing the importance of timing in the correctness of computations and their interaction with the physical environment. It explores clock synchronization challenges in distributed systems, including clock drift and skew, and outlines methods for synchronization such as external and internal synchronization. Additionally, it describes centralized and distributed algorithms for achieving time synchronization among processors, including Cristian's Algorithm and time daemon methods.

Uploaded by

anwar kadi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views23 pages

Chapter 6 Synchronization

The document discusses real-time systems, emphasizing the importance of timing in the correctness of computations and their interaction with the physical environment. It explores clock synchronization challenges in distributed systems, including clock drift and skew, and outlines methods for synchronization such as external and internal synchronization. Additionally, it describes centralized and distributed algorithms for achieving time synchronization among processors, including Cristian's Algorithm and time daemon methods.

Uploaded by

anwar kadi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

BY-

Harshita Ved
Vini Garg

1
 A Real-time system is a computer system in
which the correctness of the system behavior
depends not only on the logical results of the
computations but also on the time when the
results are produced.

 Real-time systems usually are in strong


interaction with their physical environment. They
receive data, process it, and return results in right
time. E.g. A Distributed real time system.

2
Q. WHICH REQUEST WAS MADE FIRST?
A common
‘Resource’

request A request B

Node A Node B

A Distributed System
3
Q. WHICH REQUEST WAS MADE FIRST?
A common
‘Resource’ Solution

request A request B

A Global Clock ??
Global
Node A Node B Synchronization?
A Distributed System
4
Q. WHICH REQUEST WAS MADE FIRST?
A common
‘Resource’ Solution

Individual Clocks?
Are individual clocks
request B
accurate, precise?
request A
10:02 AM
10:00 AM
One clock might run
faster/slower?

Node A Node B

A Distributed System
5
 A quartz crystal oscillates at well defined
frequency and oscillations are counted (by
hardware) in a register.

 After a certain number of oscillations, an


interrupt is generated; this is the clock tick.

 At each clock tick, the computer clock is


incremented by software.
6
 The problems:
1. Crystals cannot be tuned perfectly. Temperature and
other external factors can also influence their frequency.

Clock drift: the computer clock differs from the real time.

2. Two crystals are never identical.

Clock skew: the computer clocks on different processors of the


distributed system show different time.

7
8
NEED??
 Time driven systems: in statically scheduled systems
activities are started at "precise" times in different points of
the distributed system.
 Time stamps: certain events or messages are associated with
a time stamp showing the actual time when they have been
produced; certain decisions in the system are based on the
"exact" time of the event or event ordering.
 Calculating the duration of activities: if such an activity
starts on one processor and finishes on another (e.g.
transmitting a message), calculating the duration needs
clocks to be synchronized.

9
 These are electronic devices that count oscillations occurring
in a crystal.

 Also called timer, usually a quartz crystal, oscillating at a well


defined frequency.

 Timer is associated with two registers: A Counter and a


Holding Register, counter decreasing one at each oscillations.

 Synchronizing Physical Clocks: done by two methods:


1. External Synchronization
2. Internal Synchronization

10
 The standard for measurement of time intervals:

 International Atomic Time (TAI): It defines the


standard second and is based on atomic
oscillators.
 Coordinated Universal Time (UTC): is based on
TAI, but is kept in step with astronomical time
(by occasionally inserting or deleting a "leap
second").
 UTC signals are broadcast from satellites and
land based radio stations.
11
Synchronization with a time source external to the
distributed systems, such as UTC broadcasting
system.
 One processor in the system (possibly several) is
equipped with UTC receivers (time providers).

 By external synchronization the system is kept


synchronous with the "real time".

 This allows to exchange consistently timing


information with other systems and with users.

12
Synchronization among processors of the system.

 It is needed in order to keep a consistent view of


time over the system.

 A few processors synchronize externally and the


whole system is kept consistent by internal
synchronization.

 Sometimes only internal synchronization is


performed (we don’t care for the drift from
external/ real time).
13
 Assume no central time source –
 Each system maintains its own local clock .
 No total ordering of events .
 Allow to get global ordering on events.

Assign sequence numbers to messages –


 All cooperating processes can agree on order of event.

14
 It is used to provide a partial ordering of events
with minimal overhead.
 It is used to synchronize the logical clock.
 It follows some simple rules:
 A process increments its counter before each event in that
process i.e. Clock must tick once between every two events.
 When a process sends a message, it includes its timestamp
with the message.
 On receiving a message, the receiver process sets its counter
to be the maximum of the message counter and increments
its own counter .

15
 a ‘Happened Before’ b : a→b
1. If a and b are events in the same process, and a
comes before b, then a → b.
2. If
a :message sent
b : receipt of the same message
then a → b.

1. Transitive: If a → b and b → c then a → c.


2. Two distinct events a and b are said to be
concurrent if a -/->b and b -/->a

16
☞ Centralized Algorithms
 There exists one particular node, the so called Time
server node and clock time of this node is used as
reference.
- Passive time server: The other machines ask periodically
for the time. The goal is to keep the clocks of all other
nodes synchronized with the time server.
- Active time server: the Time server is active, broadcasting
other machines periodically about the time.
 Disadvantages:
- Single point of failure i.e. less reliable.
- Propagation delay is unpredictable.
17
☞ Distributed Algorithms
 There is no particular time server.

 The processors periodically reach an agreement on the


clock value by averaging the time of neighbors clock
and its local clock.

-This can be used if no UTC receiver exists (no external


synchronization is needed). Only internal
synchronization is performed.
- Processes can run on different machines and no global
clock to judge which event happens first.
18
 Cristian’s Algorithm is centralized algorithm.

 The simplest algorithm for setting time, it issues a


Remote Procedure Call to time server and obtain the
time.
 A machine sends a request to time server in “d/2”
seconds, where d=max difference between a clock and
UTC.
 The time server sends a reply with current UTC when
receives the request.
 The machine measures the time delay between time
server sending the message and machine receiving it.
Then it uses the measure to adjust the clock.
19
 The best estimate of message propagation time= (T0 + T1)/2
 The new time can be set to the time returned by server plus
time that elapsed since server generated the timestamp:
Tnew = Tserver + (T0 + T1)/2
20
 It is also a Centralized algorithm and its Time server is an
Active Machine.

 The server polls each machine periodically, asking it for


the time.
 When all the results are in, the master computes the
average time.
 Instead of sending the updated time back to slaves,
which would introduce further uncertainty due to
network delays, it sends each machine the offset by
which its clock needs adjustment.
 If master machine fails, any other slave could be elected
to take over.
21
a) The time daemon sends synchronization query to other
machines in group.
b) The machines sends timestamps as a response to query.
c) The Server averages the three timestamps and tells
everyone how to adjust their clock by sending offsets.
22
23

You might also like