<s>
The	O
Lamport	B-Operating_System
timestamp	I-Operating_System
algorithm	O
is	O
a	O
simple	O
logical	B-Operating_System
clock	I-Operating_System
algorithm	I-Operating_System
used	O
to	O
determine	O
the	O
order	O
of	O
events	O
in	O
a	O
distributed	B-Architecture
computer	I-Architecture
system	I-Architecture
.	O
</s>
<s>
As	O
different	O
nodes	O
or	O
processes	O
will	O
typically	O
not	O
be	O
perfectly	O
synchronized	O
,	O
this	O
algorithm	O
is	O
used	O
to	O
provide	O
a	O
partial	O
ordering	O
of	O
events	O
with	O
minimal	O
overhead	O
,	O
and	O
conceptually	O
provide	O
a	O
starting	O
point	O
for	O
the	O
more	O
advanced	O
vector	B-Operating_System
clock	I-Operating_System
method	O
.	O
</s>
<s>
If	O
there	O
is	O
a	O
timing	O
delay	O
causing	O
the	O
disk	O
to	O
receive	O
both	O
messages	O
at	O
the	O
same	O
time	O
,	O
it	O
can	O
determine	O
which	O
message	O
happened-before	B-Operating_System
the	O
other	O
:	O
happens-before	B-Operating_System
if	O
one	O
can	O
get	O
from	O
to	O
by	O
a	O
sequence	O
of	O
moves	O
of	O
two	O
types	O
:	O
moving	O
forward	O
while	O
remaining	O
in	O
the	O
same	O
process	O
,	O
and	O
following	O
a	O
message	O
from	O
its	O
sending	O
to	O
its	O
reception	O
.	O
</s>
<s>
A	O
logical	B-Operating_System
clock	I-Operating_System
algorithm	I-Operating_System
provides	O
a	O
mechanism	O
to	O
determine	O
facts	O
about	O
the	O
order	O
of	O
such	O
events	O
.	O
</s>
<s>
Lamport	O
invented	O
a	O
simple	O
mechanism	O
by	O
which	O
the	O
happened-before	B-Operating_System
ordering	O
can	O
be	O
captured	O
numerically	O
.	O
</s>
<s>
A	O
Lamport	B-Operating_System
logical	I-Operating_System
clock	I-Operating_System
is	O
a	O
numerical	O
software	O
counter	O
value	O
maintained	O
in	O
each	O
process	O
.	O
</s>
<s>
Conceptually	O
,	O
this	O
logical	B-Operating_System
clock	I-Operating_System
can	O
be	O
thought	O
of	O
as	O
a	O
clock	O
that	O
only	O
has	O
meaning	O
in	O
relation	O
to	O
messages	O
moving	O
between	O
processes	O
.	O
</s>
<s>
When	O
a	O
process	O
receives	O
a	O
message	O
,	O
it	O
re-synchronizes	O
its	O
logical	B-Operating_System
clock	I-Operating_System
with	O
that	O
sender	O
.	O
</s>
<s>
The	O
above-mentioned	O
vector	B-Operating_System
clock	I-Operating_System
is	O
a	O
generalization	O
of	O
the	O
idea	O
into	O
the	O
context	O
of	O
an	O
arbitrary	O
number	O
of	O
parallel	O
,	O
independent	O
processes	O
.	O
</s>
<s>
In	O
pseudocode	B-Language
,	O
the	O
algorithm	O
for	O
sending	O
is	O
:	O
</s>
<s>
The	O
logical	B-Operating_System
clock	I-Operating_System
be	O
set	O
so	O
that	O
there	O
is	O
a	O
minimum	O
of	O
one	O
clock	O
"	O
tick	O
"	O
(	O
increment	O
of	O
the	O
counter	O
)	O
between	O
events	O
and	O
;	O
</s>
<s>
For	O
any	O
two	O
events	O
,	O
and	O
,	O
if	O
there	O
’s	O
any	O
way	O
that	O
could	O
have	O
influenced	O
,	O
then	O
the	O
Lamport	B-Operating_System
timestamp	I-Operating_System
of	O
will	O
be	O
less	O
than	O
the	O
Lamport	B-Operating_System
timestamp	I-Operating_System
of	O
.	O
</s>
<s>
A	O
Lamport	B-Operating_System
clock	I-Operating_System
may	O
be	O
used	O
to	O
create	O
a	O
partial	O
ordering	O
of	O
events	O
between	O
processes	O
.	O
</s>
<s>
Given	O
a	O
logical	B-Operating_System
clock	I-Operating_System
following	O
these	O
rules	O
,	O
the	O
following	O
relation	O
is	O
true	O
:	O
if	O
then	O
,	O
where	O
means	O
happened-before	B-Operating_System
.	O
</s>
<s>
This	O
relation	O
only	O
goes	O
one	O
way	O
,	O
and	O
is	O
called	O
the	O
clock	O
consistency	O
condition	O
:	O
if	O
one	O
event	O
comes	O
before	O
another	O
,	O
then	O
that	O
event	O
's	O
logical	B-Operating_System
clock	I-Operating_System
comes	O
before	O
the	O
other	O
's	O
.	O
</s>
<s>
The	O
strong	O
clock	O
consistency	O
condition	O
,	O
which	O
is	O
two	O
way	O
(	O
if	O
then	O
)	O
,	O
can	O
be	O
obtained	O
by	O
other	O
techniques	O
such	O
as	O
vector	B-Operating_System
clocks	I-Operating_System
.	O
</s>
<s>
Using	O
only	O
a	O
simple	O
Lamport	B-Operating_System
clock	I-Operating_System
,	O
only	O
a	O
partial	O
causal	O
ordering	O
can	O
be	O
inferred	O
from	O
the	O
clock	O
.	O
</s>
<s>
So	O
,	O
for	O
example	O
,	O
if	O
then	O
cannot	O
have	O
happened-before	B-Operating_System
.	O
</s>
<s>
Another	O
way	O
of	O
putting	O
this	O
is	O
that	O
means	O
that	O
may	O
have	O
happened-before	B-Operating_System
,	O
or	O
be	O
incomparable	O
with	O
in	O
the	O
happened-before	B-Operating_System
ordering	O
,	O
but	O
did	O
not	O
happen	O
after	O
.	O
</s>
<s>
Nevertheless	O
,	O
Lamport	B-Operating_System
timestamps	I-Operating_System
can	O
be	O
used	O
to	O
create	O
a	O
total	O
ordering	O
of	O
events	O
in	O
a	O
distributed	B-Architecture
system	I-Architecture
by	O
using	O
some	O
arbitrary	O
mechanism	O
to	O
break	O
ties	O
(	O
e.g.	O
,	O
the	O
ID	O
of	O
the	O
process	O
)	O
.	O
</s>
<s>
In	O
a	O
distributed	B-Architecture
system	I-Architecture
,	O
it	O
is	O
not	O
possible	O
in	O
practice	O
to	O
synchronize	O
time	O
across	O
entities	O
(	O
typically	O
thought	O
of	O
as	O
processes	O
)	O
within	O
the	O
system	O
;	O
hence	O
,	O
the	O
entities	O
can	O
use	O
the	O
concept	O
of	O
a	O
logical	B-Operating_System
clock	I-Operating_System
based	O
on	O
the	O
events	O
through	O
which	O
they	O
communicate	O
.	O
</s>
<s>
A	O
distributed	B-Architecture
system	I-Architecture
is	O
said	O
to	O
have	O
partial	O
order	O
if	O
we	O
can	O
have	O
a	O
partial	O
order	O
relationship	O
among	O
the	O
events	O
in	O
the	O
system	O
.	O
</s>
<s>
If	O
the	O
system	O
has	O
partial	O
order	O
between	O
processes	O
,	O
which	O
is	O
the	O
type	O
of	O
order	O
Lamport	O
's	O
logical	B-Operating_System
clock	I-Operating_System
provides	O
,	O
then	O
we	O
can	O
only	O
tell	O
the	O
ordering	O
between	O
entities	O
that	O
interact	O
.	O
</s>
<s>
Thus	O
two	O
timestamps	O
or	O
counters	O
may	O
be	O
the	O
same	O
within	O
a	O
distributed	B-Architecture
system	I-Architecture
,	O
but	O
in	O
applying	O
the	O
logical	B-Operating_System
clocks	I-Operating_System
algorithm	O
events	O
that	O
occur	O
will	O
always	O
maintain	O
at	O
least	O
a	O
strict	O
partial	O
ordering	O
.	O
</s>
<s>
Lamport	B-Operating_System
clocks	I-Operating_System
lead	O
to	O
a	O
situation	O
where	O
all	O
events	O
in	O
a	O
distributed	B-Architecture
system	I-Architecture
are	O
totally	O
ordered	O
.	O
</s>
<s>
That	O
is	O
,	O
if	O
,	O
then	O
we	O
can	O
say	O
actually	O
happened	B-Operating_System
before	I-Operating_System
.	O
</s>
<s>
If	O
the	O
logical	B-Operating_System
clock	I-Operating_System
says	O
,	O
that	O
does	O
not	O
mean	O
in	O
reality	O
that	O
actually	O
happened	B-Operating_System
before	I-Operating_System
in	O
terms	O
of	O
real	O
time	O
.	O
</s>
<s>
Lamport	B-Operating_System
clocks	I-Operating_System
show	O
non-causality	O
,	O
but	O
do	O
not	O
capture	O
all	O
causality	O
.	O
</s>
<s>
This	O
kind	O
of	O
information	O
can	O
be	O
important	O
when	O
trying	O
to	O
replay	O
events	O
in	O
a	O
distributed	B-Architecture
system	I-Architecture
(	O
such	O
as	O
when	O
trying	O
to	O
recover	O
after	O
a	O
crash	O
)	O
.	O
</s>
