 Hello and welcome to the session on Event Ordering in Distributed Computing. At the end of this session, students will be able to explain Event Ordering in Distributed Computing. Also students will be able to describe the Event Ordering mechanism in Distributed Computing. Keeping the clocks in Distributed System synchronized to somewhat like 5 to 10 millisecond is an expensive and non-revealed task. Lamport observed that most applications it is not necessary to keep the clocks in Distributed System synchronized. It is sufficient to ensure that all events that occur in a Distributed System be totally ordered in a manner that is consistent with an observed behavior. For partial ordering of events, Lamport defined a new relation called Happened Before relation and introduced the concept of logical clocks for ordering of events based on the Happened Before relation. Happened Before relation denoted by a forward arrow on a set of events satisfy the conditions. Condition 1. If A and B are events in the same process and A occurs before B then A is Happened relation with B. 2. If A is the event of sending a message by one process and B is the event of the receipt of the same message by another process then A is Happened relation with B. This condition holds by the law of causality because a receiver cannot receive a message until sender sends it. 3. The time taken to propagate a message from its sender to its receiver is always positive. The third condition is if A is Happened relation with B and B is Happened relation with C then A is Happened relation with C that is Happened before is a transitive relation. It is observed that in a physically meaningful system an event cannot happen before itself A. This implies that Happened before is an irreflexive partial ordering on the set of all events in the system. In terms of Happened before relation 2 events A and B are said to be concurrent if they are not related by the Happened before relation. That is neither A is Happened related with B nor B is Happened related with A is true. This is possible if two events occur in a different process that do not exchange messages either directly or indirectly via other processes. This definition of concurrency simply means that nothing can be said about when the two events happened or which one happened first. Due to this reason the Happened before relation is sometimes also known as relation of causal ordering. Here the diagram shows a space-time diagram which demonstrates the concepts of the Happened before relation and concurrent events. Here in this diagram each vertical line denotes a process and each dot on vertical line denotes an event in the corresponding process and each wavy line denotes a message transfer from one process to another in the direction of arrow. From this space-time diagram it is easy to see that for two events A and B, A is Happened related with B is true if and only if there exists a path from A to B by moving forward in time along the process and message lines in the direction of the arrow. For example some of the events of the diagram that are related by Happened before relations are event 10 is Happened related with event 11, event 20 is Happened related with event 24, event 11 is Happened related with event 23 likewise. Event 11 and event 32 seems from event 11 to event 23, event 23 to event 24 and event 24 to event 32. On the other hand two events A and B are concurrent if and only if no path exists either from A to B or from B to A. For example some of the concurrent events of the diagram are event 12 and event 20, event 21 and event 30, event 10 and event 30, event 11 and event 31, event 12 and event 32 and lastly event 13 and event 22 to determine that an event A happened before an event B either a common clock or a set of perfectly synchronized clock is needed. We know that neither of these is available in a distributed system therefore in a distributed system the Happened before relation must be defined without the use of globally synchronized physical clocks. LAMPORT provided a solution for this problem by introducing the concept of logical clocks. The logical clocks concept is associate a time stamp with each system event so that events that are related to each other by the Happened before relation directly or indirectly can be properly ordered in that sequence so that each process PI has a clock CI associated with it that assigns a number CI of A to any events in that process. The clock of each process is called a logical clock because no assumption is made about the relation of the numbers CI of A to physical time. In fact the logical clocks may be implemented by counters with no actual timing mechanism. With each process having its own clock the entire system of clock is represented by the function C which assigns to any event B the number CI of B where CI of B is equal to Cj of B if B is an event in the process PJ. The logical clocks of a system can be considered to be correct if the event of the system that are related to each other by Happened before relation can be properly ordered using these clocks. For any two events A and B if A is Happened relation with B then C of A is less than C of B. Any two concurrent events must occur at the same time which is not necessarily true for all concurrent events. Here pause the video think and answer. In a distributed systems a logical clock is associated with each process. From the definition of Happened before relation it follows that the clock condition mentioned above is satisfied if the following conditions hold. C1 If A and B are two events within the same process PI and A occurs before B then CI of A is less than CI of B condition C2 if A is the sending of a message by process PI and B is the receipt of that message by process PJ then CI of A is less than Cj of B. In addition to these conditions which are necessary to satisfy the conditions the following condition is necessary for correct functioning of the system that is condition C3. A clock CI associated with a process PI must always go forward never backward that is correction to the time of logical clock must always be made by adding a positive value to the clock never by subtracting value. For any algorithm used for implementing a set of logical clocks must satisfy all these three conditions. Here the diagram shows the implementation of logical clocks by using physical clocks instead of counters. In this case each process has a physical clock associated with each clock runs at a constant rate however the rates at which the different clocks runs are different from instance in the diagram when the clock of a process PI has ticked 10 times the clock of process P2 has ticked only 8 times. To satisfy condition C1 only requirement is that the physical clock of a process must tick at least once between any two events in that processes. This is usually not a problem because a computer clock is normally designed to click several times between two events that happen in a quick succession. To satisfy condition C2 for message sending event for example in the diagram event 4 and event 14 the process sending the message includes its current physical time in the message and for a message receiving event for example event 13 and event 8. Here is my reference. Thank you.