0% found this document useful (0 votes)
205 views1 page

Logical Clock in Distributed System - GeeksforGeeks

Logical clocks are used in distributed systems to maintain a consistent ordering of events across different processes without a globally synchronized clock. Each process is assigned a timestamp based on the order of events. These timestamps obey causality relationships where an event cannot have an earlier timestamp than a causally preceding event. Properties like transitive relationships and concurrent events can be derived from the happen-before relationships between timestamps. Logical clocks allow distributed systems without a shared clock to simulate a global ordering of events.

Uploaded by

shreya
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)
205 views1 page

Logical Clock in Distributed System - GeeksforGeeks

Logical clocks are used in distributed systems to maintain a consistent ordering of events across different processes without a globally synchronized clock. Each process is assigned a timestamp based on the order of events. These timestamps obey causality relationships where an event cannot have an earlier timestamp than a causally preceding event. Properties like transitive relationships and concurrent events can be derived from the happen-before relationships between timestamps. Logical clocks allow distributed systems without a shared clock to simulate a global ordering of events.

Uploaded by

shreya
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

11/24/23, 10:38 PM Logical Clock in Distributed System - GeeksforGeeks

Aptitude Engineering Mathematics Discrete Mathematics Operating System Courses @30% Off DBMS Computer Networks Digital Logic and De

Logical Clock in Distributed System


Read Discuss Courses

Logical Clocks refer to implementing a protocol on all machines within your distributed system, so that the
machines are able to maintain consistent ordering of events within some virtual timespan. A logical clock is a
mechanism for capturing chronological and causal relationships in a distributed system. Distributed systems
may have no physically synchronous global clock, so a logical clock allows global ordering on events from
different processes in such systems.

Example :
If we go outside then we have made a full plan that at which place we have to go first, second and so on. We
don’t go to second place at first and then the first place. We always maintain the procedure or an organization
that is planned before. In a similar way, we should do the operations on our PCs one by one in an organized
way.

Suppose, we have more than 10 PCs in a distributed system and every PC is doing it’s own work but then how
we make them work together. There comes a solution to this i.e. LOGICAL CLOCK.

Method-1:
To order events across process, try to sync clocks in one approach.

This means that if one PC has a time 2:00 pm then every PC should have the same time which is quite not
possible. Not every clock can sync at one time. Then we can’t follow this method.

Method-2:
Another approach is to assign Timestamps to events.

Taking the example into consideration, this means if we assign the first place as 1, second place as 2, third place
as 3 and so on. Then we always know that the first place will always come first and then so on. Similarly, If we
give each PC their individual number than it will be organized in a way that 1st PC will complete its process first
and then second and so on.

BUT, Timestamps will only work as long as they obey causality.

What is causality ?
Causality is fully based on HAPPEN BEFORE RELATIONSHIP.

Taking single PC only if 2 events A and B are occurring one by one then TS(A) < TS(B). If A has timestamp of
1, then B should have timestamp more than 1, then only happen before relationship occurs.
Taking 2 PCs and event A in P1 (PC.1) and event B in P2 (PC.2) then also the condition will be TS(A) < TS(B).
Taking example- suppose you are sending message to someone at 2:00:00 pm, and the other person is
receiving it at 2:00:02 pm.Then it’s obvious that TS(sender) < TS(receiver).

Properties Derived from Happen Before Relationship –

Transitive Relation –
If, TS(A) <TS(B) and TS(B) <TS(C), then TS(A) < TS(C)
Causally Ordered Relation –
a->b, this means that a is occurring before b and if there is any changes in a it will surely reflect on b.
Concurrent Event –
This means that not every process occurs one by one, some processes are made to happen simultaneously
i.e., A || B.

Unlock the Power of Placement Preparation!


Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation Course is the ultimate
guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview
triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation course.

https://www.geeksforgeeks.org/logical-clock-in-distributed-system/?ref=lbp 1/3

You might also like