<s>
In	O
computing	O
,	O
a	O
memory	B-General_Concept
model	I-General_Concept
describes	O
the	O
interactions	O
of	O
threads	B-Operating_System
through	O
memory	B-General_Concept
and	O
their	O
shared	O
use	O
of	O
the	O
data	B-General_Concept
.	O
</s>
<s>
A	O
memory	B-General_Concept
model	I-General_Concept
allows	O
a	O
compiler	O
to	O
perform	O
many	O
important	O
optimizations	O
.	O
</s>
<s>
Compiler	B-Application
optimizations	I-Application
like	O
loop	O
fusion	O
move	O
statements	O
in	O
the	O
program	O
,	O
which	O
can	O
influence	O
the	O
order	O
of	O
read	O
and	O
write	O
operations	O
of	O
potentially	O
shared	O
variables	O
.	O
</s>
<s>
Changes	O
in	O
the	O
ordering	O
of	O
reads	O
and	O
writes	O
can	O
cause	O
race	B-Operating_System
conditions	I-Operating_System
.	O
</s>
<s>
Without	O
a	O
memory	B-General_Concept
model	I-General_Concept
,	O
a	O
compiler	O
is	O
not	O
allowed	O
to	O
apply	O
such	O
optimizations	O
to	O
multi-threaded	B-Operating_System
programs	O
in	O
general	O
,	O
or	O
only	O
in	O
special	O
cases	O
.	O
</s>
<s>
Or	O
for	O
some	O
compilers	O
assume	O
no	O
multi-threaded	B-Operating_System
execution	O
(	O
so	O
better	O
optimized	O
code	O
can	O
be	O
produced	O
)	O
,	O
which	O
can	O
lead	O
to	O
optimizations	O
that	O
are	O
incompatible	O
with	O
multi-threading	O
-	O
these	O
can	O
often	O
lead	O
to	O
subtle	O
bugs	O
,	O
that	O
do	O
n't	O
show	O
up	O
in	O
early	O
testing	O
.	O
</s>
<s>
Modern	O
programming	O
languages	O
like	O
Java	B-Language
therefore	O
implement	O
a	O
memory	B-General_Concept
model	I-General_Concept
.	O
</s>
<s>
The	O
memory	B-General_Concept
model	I-General_Concept
specifies	O
synchronization	B-Operating_System
barriers	I-Operating_System
that	O
are	O
established	O
via	O
special	O
,	O
well-defined	O
synchronization	O
operations	O
such	O
as	O
acquiring	O
a	O
lock	O
by	O
entering	O
a	O
synchronized	O
block	O
or	O
method	O
.	O
</s>
<s>
The	O
memory	B-General_Concept
model	I-General_Concept
stipulates	O
that	O
changes	O
to	O
the	O
values	O
of	O
shared	O
variables	O
only	O
need	O
to	O
be	O
made	O
visible	O
to	O
other	O
threads	B-Operating_System
when	O
such	O
a	O
synchronization	B-Operating_System
barrier	I-Operating_System
is	O
reached	O
.	O
</s>
<s>
Moreover	O
,	O
the	O
entire	O
notion	O
of	O
a	O
race	B-Operating_System
condition	I-Operating_System
is	O
defined	O
over	O
the	O
order	O
of	O
operations	O
with	O
respect	O
to	O
these	O
memory	B-General_Concept
barriers	I-General_Concept
.	O
</s>
<s>
These	O
semantics	O
then	O
give	O
optimizing	B-Application
compilers	I-Application
a	O
higher	O
degree	O
of	O
freedom	O
when	O
applying	O
optimizations	O
:	O
the	O
compiler	O
needs	O
to	O
make	O
sure	O
only	O
that	O
the	O
values	O
of	O
(	O
potentially	O
shared	O
)	O
variables	O
at	O
synchronization	B-Operating_System
barriers	I-Operating_System
are	O
guaranteed	O
to	O
be	O
the	O
same	O
in	O
both	O
the	O
optimized	O
and	O
unoptimized	O
code	O
.	O
</s>
<s>
In	O
particular	O
,	O
reordering	O
statements	O
in	O
a	O
block	O
of	O
code	O
that	O
contains	O
no	O
synchronization	B-Operating_System
barrier	I-Operating_System
is	O
assumed	O
to	O
be	O
safe	O
by	O
the	O
compiler	O
.	O
</s>
<s>
Most	O
research	O
in	O
the	O
area	O
of	O
memory	B-General_Concept
models	I-General_Concept
revolves	O
around	O
:	O
</s>
<s>
Designing	O
a	O
memory	B-General_Concept
model	I-General_Concept
that	O
allows	O
a	O
maximal	O
degree	O
of	O
freedom	O
for	O
compiler	B-Application
optimizations	I-Application
while	O
still	O
giving	O
sufficient	O
guarantees	O
about	O
race-free	O
and	O
(	O
perhaps	O
more	O
importantly	O
)	O
race-containing	O
programs	O
.	O
</s>
<s>
Proving	O
program	O
optimizations	O
that	O
are	O
correct	O
with	O
respect	O
to	O
such	O
a	O
memory	B-General_Concept
model	I-General_Concept
.	O
</s>
<s>
The	O
Java	B-General_Concept
Memory	I-General_Concept
Model	I-General_Concept
was	O
the	O
first	O
attempt	O
to	O
provide	O
a	O
comprehensive	O
threading	O
memory	B-General_Concept
model	I-General_Concept
for	O
a	O
popular	O
programming	O
language	O
.	O
</s>
<s>
After	O
it	O
was	O
established	O
that	O
threads	B-Operating_System
could	O
not	O
be	O
implemented	O
safely	O
as	O
a	O
library	B-Library
without	O
placing	O
certain	O
restrictions	O
on	O
the	O
implementation	O
and	O
,	O
in	O
particular	O
,	O
that	O
the	O
C	B-Language
and	O
C++	B-Language
standards	O
(	O
C99	B-Language
and	O
C++03	B-Language
)	O
lacked	O
necessary	O
restrictions	O
,	O
the	O
C++	B-Language
threading	O
subcommittee	O
set	O
to	O
work	O
on	O
suitable	O
memory	B-General_Concept
model	I-General_Concept
;	O
in	O
2005	O
,	O
they	O
submitted	O
C	B-Language
working	O
document	O
n1131	O
to	O
get	O
the	O
C	B-Language
Committee	O
on	O
board	O
with	O
their	O
efforts	O
.	O
</s>
<s>
The	O
final	O
revision	O
of	O
the	O
proposed	O
memory	B-General_Concept
model	I-General_Concept
,	O
C++	B-Language
n2429	O
,	O
was	O
accepted	O
into	O
the	O
C++	B-Language
draft	O
standard	O
at	O
the	O
October	O
2007	O
meeting	O
in	O
Kona	O
.	O
</s>
<s>
The	O
memory	B-General_Concept
model	I-General_Concept
was	O
then	O
included	O
in	O
the	O
next	O
C++	B-Language
and	O
C	B-Language
standards	O
,	O
C++11	B-Language
and	O
C11	O
.	O
</s>
