Chap 5
Click here to load reader
Transcript of Chap 5
Chapter-5Synchronization
Introduction A DS consists of a collection of distinct processes that are separated
spatially and run concurrently Sharing of resources may be co-operative or competitive. The rules for enforcing correct interaction are implemented in the form of
synchronization. The number of resources in a computing system is restricted , one process
must influence the action of other concurrently executing processes as it competes for resources.
The synchronization mechanisms suitable for distributed system are1. Clock synchronization2. Event ordering3. Mutual exclusion4. Election algorithm
Clock synchronization issues Practically no two clocks can be perfectly synchronized A set of clocks are said to synchronized if their clock skew less than some
constant(∂) Clock synchronization requires each node to read other nodes’ clock Time must never run backward
Clock synchronization algorithmsBroadly classified into two types1. Centralized algorithms2. Distributed algorithms
Centralized algorithms In this mechanism, one node has a real time receiver. This node is called
TIME SERVER NODE and clock time of this node is used as a reference. The clocks of all other nodes are synchronized with respect to time server
node Two types of clock synchronizations (Active, Passive)
Passive time server centralized algorithms In this method. Each node periodically sends a message to the time server When the time server receives the message, it quickly responds with
current TIME message (T) Unpredictable variation of message passing duration effects on ‘T’ Message passing duration is considered based on a threshold value.
Active time server centralized algorithms In this scheme, the time server periodically broadcasts it clock time. The other nodes receive the broadcast message and use the clock time in
the message for correcting their own clocks. Each node has a priori knowledge of the propagation delay
Disadvantages These are subject to single point failure – Time server fails, synchronization
cannot be performed Makes system unreliable Not supports scalability (difficult) Propagation delay is unpredictable
Distributed algorithms Externally synchronized clocks are also internally synchronized Each node of the system are synchronized wrt real-time server Multiple real-time clocks are used
Global averaging The clock process at each node broadcasts its local clock time in the form of
‘resync’ message (Resynchronization) It takes the average of the estimated skews and use it as the correction for
the local clock The estimated skew is compared with threshold value It discards highest and lowest estimated skews Calculates the average of the remaining skews
Localized averaging In this approach, all the nodes of the distributed system are logically
arranged in some pattern ( Ring, grid, etc) Periodically, each node exchanges its clock time with its neighbors in the
ring or grid Set the clock time to the average of its own and clock times of neighbor
Event ordering For most applications it is not necessary and difficult to keep the clocks in a
distributed system synchronized. It is sufficient to ensure that, all events that occur in a DS be totally ordered
in a consistent manner with an observed behavior. For partial ordering of events Happened-Before and logical clocks relation is
used.
Happened-Before relation The happened-before relation ()on a set of events satisfies1. If a and b are events in the same process and a occurs before b, then ab.2. If a is the event of sending message to b, and b is the event of receiving
from a then ab3. Satisfies Causality- A receiver cannot receive a message until the sender
sends it.4. The propagation delay is always positive5. If ab and bc, the ac (transitive law)6. It is irreflexive aa7. if a and b are said to be concurrent, then ab is not possible.
• Example:
e10
e13
e12
e11
e24
e23
e22
e21
e20 e30
e31
e32
Some happened relation are:e11e23 , e21e13, e30e22, e24e32e30e24 (e30e22e24)
Some concurrent eventse12 and e20, e21 and e30, e10 and e30, e11 and e31, e12 and e32, e13 and e22
• Logical clocks concept It is a way to associate a timestamp (a number independent of any clock time)
with each system event so that events that are related to each other by happened-before relation can be properly ordered.
Each process Pi has a clock Ci associated with a number Ci(a) to any event a
Conditions If a and b are two events within the same process Pi and a occurs before b,
then Ci(a)<Ci(b) If a is sending a message by Pi and b is the receipt of that message by process
Pj , then Ci(a)<Cj(b) A clock of Ci associated with process Pi must always go forward
Implementation of logical clocks using counters The counters acts as logical clocks At beginning, counters are initialized to zero A process increments its counter by 1 whenever an event occurs For receiving message, the counter value should always greater than the
counter value of sender