<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
the	O
happened-before	B-Operating_System
relation	O
(	O
denoted	O
:	O
)	O
is	O
a	O
relation	O
between	O
the	O
result	O
of	O
two	O
events	O
,	O
such	O
that	O
if	O
one	O
event	O
should	O
happen	O
before	O
another	O
event	O
,	O
the	O
result	O
must	O
reflect	O
that	O
,	O
even	O
if	O
those	O
events	O
are	O
in	O
reality	O
executed	O
out	O
of	O
order	O
(	O
usually	O
to	O
optimize	O
program	O
flow	O
)	O
.	O
</s>
<s>
This	O
involves	O
ordering	O
events	O
based	O
on	O
the	O
potential	O
causal	O
relationship	O
of	O
pairs	O
of	O
events	O
in	O
a	O
concurrent	O
system	O
,	O
especially	O
asynchronous	B-Architecture
distributed	I-Architecture
systems	I-Architecture
.	O
</s>
<s>
The	O
happened-before	B-Operating_System
relation	O
is	O
formally	O
defined	O
as	O
the	O
least	O
strict	O
partial	O
order	O
on	O
events	O
such	O
that	O
:	O
</s>
<s>
For	O
example	O
,	O
in	O
some	O
programming	O
languages	O
such	O
as	O
Java	O
,	O
C	O
,	O
C++	O
or	O
Rust	O
,	O
a	O
happens-before	B-Operating_System
edge	O
exists	O
if	O
memory	O
written	O
to	O
by	O
statement	O
A	O
is	O
visible	O
to	O
statement	O
B	O
,	O
that	O
is	O
,	O
if	O
statement	O
A	O
completes	O
its	O
write	O
before	O
statement	O
B	O
starts	O
its	O
read	O
.	O
</s>
<s>
Like	O
all	O
strict	O
partial	O
orders	O
,	O
the	O
happened-before	B-Operating_System
relation	O
is	O
transitive	O
,	O
irreflexive	O
and	O
antisymmetric	O
,	O
i.e.	O
</s>
<s>
This	O
means	O
that	O
for	O
any	O
three	O
events	O
,	O
if	O
happened	B-Operating_System
before	I-Operating_System
,	O
and	O
happened	B-Operating_System
before	I-Operating_System
,	O
then	O
must	O
have	O
happened	B-Operating_System
before	I-Operating_System
.	O
</s>
<s>
This	O
means	O
that	O
for	O
any	O
two	O
distinct	O
events	O
,	O
if	O
happened	B-Operating_System
before	I-Operating_System
then	O
cannot	O
have	O
happened	B-Operating_System
before	I-Operating_System
.	O
</s>
<s>
The	O
processes	O
that	O
make	O
up	O
a	O
distributed	B-Architecture
system	I-Architecture
have	O
no	O
knowledge	O
of	O
the	O
happened-before	B-Operating_System
relation	O
unless	O
they	O
use	O
a	O
logical	B-Operating_System
clock	I-Operating_System
,	O
like	O
a	O
Lamport	B-Operating_System
clock	I-Operating_System
or	O
a	O
vector	B-Operating_System
clock	I-Operating_System
.	O
</s>
<s>
This	O
allows	O
one	O
to	O
design	O
algorithms	O
for	O
mutual	B-Operating_System
exclusion	I-Operating_System
,	O
and	O
tasks	O
like	O
debugging	O
or	O
optimising	O
distributed	B-Architecture
systems	I-Architecture
.	O
</s>
