Time%20and%20Clock - PowerPoint PPT Presentation

About This Presentation
Title:

Time%20and%20Clock

Description:

Total ordering is feasible in a single process that has only one clock. ... (1 atomic second = 9,192,631,770 orbital transitions of Cs 133 atom. – PowerPoint PPT presentation

Number of Views:83
Avg rating:3.0/5.0
Slides: 19
Provided by: Suku89
Category:

less

Transcript and Presenter's Notes

Title: Time%20and%20Clock


1
Time and Clock
  • Primary standard rotation of earth
  • De facto primary standard atomic clock
  • (1 atomic second 9,192,631,770 orbital
    transitions of Cs 133 atom.
  • 86400 atomic sec 1 solar day 3 ms).
  • What is GPS?
  • There is nothing called simultaneous
  • in the physical world.

2
Sequential and Concurrent events
  • Sequential Totally ordered in time. Total
    ordering is feasible in a single process that has
    only one clock. This is not true in a distributed
    system.
  • Two issues are important here
  • How to synchronize physical clocks ?
  • Can we define sequential and concurrent events
    without using physical clocks?

3
Causality
  • Causality helps determine sequential and
    concurrent events
  • without using physical clocks.
  • Joke ? Re joke (? implies causally ordered
    before)
  • Message sent ? message received
  • Local ordering a ? b ? c (based on the local
    clock)

4
Defining causal relationship
  • Rule 1. If a, b are two events in a single
    process P, and the time of a is less than the
    time of b then a ? b.
  • Rule 2. If a sending a message, and b
    receipt of that message, then a ? b.
  • Rule 3. a ? b ? b ? c ? a ? c

5
Example of causality
  • a ? d since (a ? b ? b ? c ? c ? d)
  • e ? d since (e ? f ? f ? d)
  • (Thus ? defines a PARTIAL order).
  • Is g ? f or f ? g? NO. They are concurrent.
  • Concurrency absence of causal order.

6
Logical clocks
  • LC is a counter. Its value respects causal
    ordering as follows
  • a ? b ? LC(a) lt LC(b)
  • Note that LC(a) lt LC(b) does NOT imply a ? b.
  • Each process maintains its logical clock as
    follows
  • LC1. Each time a local event takes place,
    increment LC.
  • LC2. Append the value of LC to outgoing
    messages.
  • LC3. When receiving a message, set LC to
  • 1 max (local LC, message LC)

7
Total order
  • So, does total order exist in a distributed
    system?
  • It is important to define a total order for some
    applications.
  • Causal order is strengthened to define a total
    order (ltlt) among events.
  • The (id, LC) value sent out with each message is
    called its timestamp.
  • Let a, b be events in processes i and j
    respectively. Then
  • a ltlt b iff LC(a) lt LC(b) OR LC(a) LC(b) and
    i lt j
  • a ? b ? a ltlt b, but the converse is not true.

8
Vector clock
  • Causality detection can be an important issue is
    applications like group communication.
  • Logical clocks do not detect causal ordering.
    Vector clocks do.
  • a ? b ? VC(a) lt VC(b)

9
Vector clocks
  • Example
  • 3, 3, 4, 5, 3, 2, 1, 4 lt
  • 3, 3, 4, 5, 3, 2, 2, 5
  • But,
  • 3, 3, 4, 5, 3, 2, 1, 4 and
  • 3, 3, 4, 5, 3, 2, 2, 3
  • are not comparable
  • Define. VC(a) lt VC(b) iff
  • ?i 0 i N-1 VC(a)i VC(b)i, and
  • ? j 0 j N-1 VC(a)j lt VC(b)j,

10
Implementing VC
  • Actions of process j
  • VC1. Increment VCj) for each local event.
  • VC2. Append local VC to every outgoing message.
  • VC3. When a message with a vector timestamp T
    arrives, first increment the jth component VCj
    of the local vector clock, and then update it as
    follows
  • ?k 0 k N-1 VCk max(Tk, VCk).

11
Physical clock synchronization
  • Question 1.Why is physical clock synchronization
    important?
  • Question 2.With atomic clocks becoming
    affordable, should we care about physical clock
    synchronization? Cant we use GPS?

12
Classification
  • Types of Synchronization
  • External Synchronization
  • Internal Synchronization
  • Phase Synchronization
  • Types of clocks
  • Unbounded 0, 1, 2, 3, . . .
  • Bounded 0, 1, 2, . . . M-1, 0, 1, . . .
  • Unbounded clocks are not realistic, but are
    easier to deal with in algorithms

13
Terminologies
  • What are these?
  • Drift rate ?
  • Clock skew ?
  • Resynchronization interval R
  • Challenges
  • (Drift is unavoidable)
  • Accounting for propagation delay
  • Processing delay
  • Faulty clocks

14
Internal synchronization
  • A simple averaging algorithm
  • Step 1. Read every clock in the system.
  • Step 2. Discard outliers and substitute them by
    the value of the local clock.
  • Step 3. Update the clock using the average of
    these values.
  • Synchronization is maintained if
  • n gt 3t1
  • where t is the number of faulty
  • (may be 2-faced) clocks. Why?

Some clocks may be faulty
15
Internal synchronization
  • A simple averaging algorithm
  • If there are t faulty clocks, then
  • the maximum difference between
  • the averages computed by two
  • non-faulty nodes is be 3td /n
  • To keep the clocks synchronized,
  • 3td /n lt d
  • So, 3t lt n

Some clocks may be faulty
16
Cristians method
  • Client pulls data from a time server.
  • For accuracy, it computes the round
  • trip time (RTT), and compensates for this
  • delay while adjusting its own clock

Time server
17
Network Time Protocol
  • Tiered architecture
  • Broadcast mode
  • -least accurate
  • Procedure call
  • -medium accuracy
  • Peer-to-peer mode
  • -higher level servers
  • use this for max accuracy

Time server
18
P2P mode of NTP
  • Let Qs time be ahead of Ps time by ?. Then
  • T2 T1 TPQ ?
  • T4 T3 TQP - ?
  • RTT y TPQ TQP T2 T4 -T1 -T3
  • ? (T2 -T4 -T1 T3) / 2 -(TPQ - TQP) / 2
  • Ping several times, and obtain the smallest value
    of y. Use it to calculate ?

T2
T3
Q
P
T1
T4
x
Between y/2 and -y/2
Write a Comment
User Comments (0)
About PowerShow.com