<s>
In	O
computing	O
,	O
a	O
programming	O
language	O
consists	O
of	O
a	O
syntax	O
plus	O
an	O
execution	B-Device
model	I-Device
.	O
</s>
<s>
The	O
execution	B-Device
model	I-Device
specifies	O
the	O
behavior	O
of	O
elements	O
of	O
the	O
language	O
.	O
</s>
<s>
By	O
applying	O
the	O
execution	B-Device
model	I-Device
,	O
one	O
can	O
derive	O
the	O
behavior	O
of	O
a	O
program	B-Application
that	O
was	O
written	O
in	O
terms	O
of	O
that	O
programming	O
language	O
.	O
</s>
<s>
What	O
the	O
programmer	O
is	O
doing	O
is	O
applying	O
the	O
execution	B-Device
model	I-Device
to	O
the	O
code	O
,	O
which	O
results	O
in	O
the	O
behavior	O
of	O
the	O
code	O
.	O
</s>
<s>
Each	O
and	O
every	O
programming	O
language	O
has	O
an	O
execution	B-Device
model	I-Device
,	O
which	O
determines	O
the	O
manner	O
in	O
which	O
the	O
units	O
of	O
work	O
(	O
that	O
are	O
indicated	O
by	O
program	B-Application
syntax	O
)	O
are	O
scheduled	O
for	O
execution	B-General_Concept
.	O
</s>
<s>
Detailed	O
examples	O
of	O
the	O
specification	O
of	O
execution	B-Device
models	I-Device
of	O
a	O
few	O
popular	O
languages	O
include	O
those	O
of	O
Python	B-Language
,	O
</s>
<s>
the	O
execution	B-Device
model	I-Device
of	O
the	O
Unified	B-Operating_System
Parallel	I-Operating_System
C	I-Operating_System
(	O
UPC	O
)	O
programming	O
language	O
,	O
</s>
<s>
a	O
discussion	O
of	O
various	O
classes	O
of	O
execution	B-Device
model	I-Device
such	O
as	O
for	O
imperative	B-Application
versus	O
functional	B-Language
languages	I-Language
,	O
</s>
<s>
and	O
an	O
article	O
discussing	O
execution	B-Device
models	I-Device
for	O
real-time	B-General_Concept
embedded	I-General_Concept
languages	O
.	O
</s>
<s>
Operational	O
Semantics	O
is	O
one	O
method	O
of	O
specifying	O
a	O
language	O
's	O
execution	B-Device
model	I-Device
.	O
</s>
<s>
The	O
observed	O
behavior	O
of	O
a	O
running	O
program	B-Application
must	O
match	O
the	O
behavior	O
derived	O
from	O
the	O
operational	O
semantics	O
(	O
which	O
define	O
the	O
execution	B-Device
model	I-Device
of	O
the	O
language	O
)	O
.	O
</s>
<s>
An	O
execution	B-Device
model	I-Device
covers	O
things	O
such	O
as	O
what	O
is	O
an	O
indivisible	O
unit	O
of	O
work	O
,	O
and	O
what	O
are	O
the	O
constraints	O
on	O
the	O
order	O
in	O
which	O
those	O
units	O
of	O
work	O
may	O
take	O
place	O
.	O
</s>
<s>
To	O
illustrate	O
this	O
,	O
consider	O
the	O
C	B-Language
programming	I-Language
language	I-Language
,	O
as	O
described	O
in	O
the	O
book	O
by	O
Kernighan	O
and	O
Richie	O
.	O
</s>
<s>
C	B-Language
has	O
a	O
concept	O
called	O
a	O
statement	O
.	O
</s>
<s>
The	O
language	O
spec	O
then	O
says	O
that	O
"	O
execution	B-General_Concept
of	O
the	O
program	B-Application
proceeds	O
one	O
statement	O
after	O
the	O
other	O
,	O
in	O
sequence	O
"	O
.	O
</s>
<s>
Those	O
words	O
:	O
"	O
execution	B-General_Concept
of	O
the	O
program	B-Application
proceeds	O
one	O
statement	O
after	O
the	O
other	O
,	O
in	O
sequence	O
"	O
are	O
one	O
piece	O
of	O
the	O
execution	B-Device
model	I-Device
of	O
C	B-Language
.	O
Those	O
words	O
tell	O
us	O
that	O
statements	O
are	O
indivisible	O
units	O
of	O
work	O
and	O
that	O
they	O
proceed	O
in	O
the	O
same	O
order	O
as	O
their	O
syntactic	O
appearance	O
in	O
the	O
code	O
(	O
except	O
when	O
a	O
control	O
statement	O
such	O
as	O
IF	O
or	O
FOR	O
modifies	O
the	O
order	O
)	O
.	O
</s>
<s>
By	O
stating	O
that	O
"	O
execution	B-General_Concept
of	O
the	O
program	B-Application
proceeds	O
one	O
statement	O
after	O
the	O
other	O
,	O
in	O
sequence	O
"	O
,	O
the	O
programming	O
model	O
has	O
stated	O
constraints	O
on	O
the	O
order	O
of	O
performing	O
units	O
of	O
work	O
.	O
</s>
<s>
The	O
C	B-Language
language	I-Language
actually	O
has	O
an	O
additional	O
level	O
to	O
its	O
execution	B-Device
model	I-Device
,	O
which	O
is	O
the	O
order	O
of	O
precedence	O
.	O
</s>
<s>
Hence	O
,	O
these	O
parts	O
of	O
the	O
C	B-Language
language	I-Language
specification	O
are	O
also	O
part	O
of	O
the	O
execution	B-Device
model	I-Device
of	O
the	O
C	B-Language
language	I-Language
.	O
</s>
<s>
Execution	B-Device
models	I-Device
can	O
also	O
exist	O
independently	O
from	O
programming	O
languages	O
,	O
examples	O
of	O
which	O
would	O
be	O
the	O
POSIX	B-Operating_System
Threads	I-Operating_System
library	O
,	O
and	O
Hadoop	O
's	O
Map-Reduce	O
programming	O
model	O
.	O
</s>
<s>
The	O
implementation	O
of	O
an	O
execution	B-Device
model	I-Device
can	O
be	O
via	O
compiler	B-Language
,	O
or	O
interpreter	O
,	O
and	O
often	O
includes	O
a	O
runtime	B-Device
system	I-Device
.	O
</s>
<s>
An	O
implementation	O
of	O
an	O
execution	B-Device
model	I-Device
controls	O
the	O
order	O
in	O
which	O
work	O
takes	O
place	O
during	O
execution	B-General_Concept
.	O
</s>
<s>
This	O
order	O
may	O
be	O
chosen	O
ahead	O
of	O
time	O
,	O
in	O
some	O
situations	O
,	O
or	O
it	O
can	O
be	O
dynamically	O
determined	O
as	O
the	O
execution	B-General_Concept
proceeds	O
.	O
</s>
<s>
Most	O
execution	B-Device
models	I-Device
allow	O
varying	O
degrees	O
of	O
both	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
C	B-Language
language	I-Language
fixes	O
the	O
order	O
of	O
work	O
within	O
a	O
statement	O
and	O
it	O
fixes	O
the	O
order	O
of	O
all	O
statements	O
,	O
except	O
ones	O
that	O
involve	O
an	O
IF	O
statement	O
or	O
a	O
form	O
of	O
loop	O
statement	O
.	O
</s>
<s>
Hence	O
,	O
most	O
of	O
the	O
order	O
of	O
execution	B-General_Concept
may	O
be	O
chosen	O
statically	O
,	O
before	O
execution	B-General_Concept
begins	O
,	O
but	O
a	O
small	O
portion	O
must	O
be	O
chosen	O
dynamically	O
,	O
as	O
execution	B-General_Concept
proceeds	O
.	O
</s>
<s>
The	O
static	O
choices	O
are	O
most	O
often	O
implemented	O
inside	O
a	O
compiler	B-Language
,	O
in	O
which	O
case	O
the	O
order	O
of	O
work	O
is	O
represented	O
by	O
the	O
order	O
in	O
which	O
instructions	O
are	O
placed	O
into	O
the	O
executable	B-Application
binary	I-Application
.	O
</s>
<s>
The	O
dynamic	O
choices	O
would	O
then	O
be	O
implemented	O
inside	O
the	O
language	O
's	O
runtime	B-Device
system	I-Device
.	O
</s>
<s>
The	O
runtime	B-Device
system	I-Device
may	O
be	O
a	O
library	O
,	O
which	O
is	O
called	O
by	O
instructions	O
inserted	O
by	O
the	O
compiler	B-Language
,	O
or	O
the	O
runtime	B-Device
system	I-Device
may	O
be	O
embedded	O
into	O
the	O
executable	B-Application
directly	O
,	O
such	O
as	O
by	O
inserting	O
branch	O
instructions	O
,	O
which	O
make	O
dynamic	O
choices	O
about	O
which	O
work	O
to	O
perform	O
next	O
.	O
</s>
<s>
However	O
,	O
an	O
interpreter	O
may	O
also	O
be	O
constructed	O
for	O
any	O
language	O
,	O
in	O
which	O
case	O
all	O
decisions	O
on	O
order	O
of	O
execution	B-General_Concept
are	O
dynamic	O
.	O
</s>
<s>
An	O
interpreter	O
can	O
be	O
viewed	O
as	O
being	O
part	O
translator	O
,	O
and	O
part	O
execution	B-Device
model	I-Device
implementation	O
.	O
</s>
<s>
Assembly	O
languages	O
also	O
have	O
execution	B-Device
models	I-Device
,	O
the	O
same	O
as	O
any	O
other	O
language	O
.	O
</s>
<s>
Such	O
an	O
execution	B-Device
model	I-Device
is	O
implemented	O
by	O
a	O
CPU	O
micro-architecture	O
.	O
</s>
<s>
For	O
example	O
,	O
both	O
a	O
5	O
stage	O
in-order	O
pipeline	O
and	O
a	O
large	O
out	O
of	O
order	O
CPU	O
implement	O
the	O
same	O
assembly	O
language	O
execution	B-Device
model	I-Device
.	O
</s>
<s>
The	O
execution	B-Device
model	I-Device
is	O
the	O
definition	O
of	O
the	O
behavior	O
,	O
so	O
all	O
implementations	O
,	O
whether	O
in-order	O
or	O
out-of-order	O
or	O
interpreted	O
or	O
JIT	O
'd	O
etc	O
..	O
must	O
all	O
give	O
the	O
exact	O
same	O
result	O
,	O
and	O
that	O
result	O
is	O
defined	O
by	O
the	O
execution	B-Device
model	I-Device
.	O
</s>
<s>
Parallel	O
execution	B-Device
models	I-Device
tend	O
to	O
be	O
complex	O
because	O
they	O
involve	O
multiple	O
timelines	O
.	O
</s>
<s>
Parallel	O
execution	B-Device
models	I-Device
necessarily	O
include	O
the	O
behavior	O
of	O
synchronization	O
constructs	O
.	O
</s>
<s>
In	O
Posix	B-Operating_System
threads	I-Operating_System
this	O
would	O
be	O
pthread_mutex_lock( &myMutex	O
)	O
.	O
</s>
<s>
The	O
C	B-Language
and	O
Java	O
execution	B-Device
models	I-Device
are	O
sequential	O
,	O
and	O
they	O
state	O
that	O
the	O
timeline	O
has	O
activities	O
that	O
come	O
before	O
the	O
call	O
to	O
"	O
gain	O
ownership	O
of	O
the	O
lock	O
"	O
,	O
and	O
activities	O
that	O
come	O
after	O
the	O
call	O
.	O
</s>
<s>
In	O
C	B-Language
this	O
would	O
be	O
pthread_mutex_unlock( &myMutex	O
)	O
.	O
</s>
<s>
Again	O
,	O
the	O
execution	B-Device
models	I-Device
C	B-Language
and	O
Java	O
define	O
that	O
one	O
group	O
of	O
statements	O
is	O
executed	O
before	O
ownership	O
of	O
the	O
lock	O
is	O
given	O
up	O
,	O
and	O
another	O
group	O
of	O
statements	O
is	O
executed	O
after	O
ownership	O
of	O
the	O
lock	O
is	O
given	O
up	O
.	O
</s>
<s>
Now	O
,	O
we	O
can	O
say	O
the	O
parallel	O
execution	B-Device
model	I-Device
of	O
the	O
"	O
gain	O
ownership	O
of	O
lock	O
"	O
and	O
"	O
give	O
up	O
ownership	O
of	O
lock	O
"	O
synchronization	O
construct	O
.	O
</s>
<s>
The	O
execution	B-Device
model	I-Device
is	O
this	O
:	O
</s>
<s>
The	O
complication	O
comes	O
from	O
the	O
fact	O
that	O
the	O
execution	B-Device
model	I-Device
does	O
not	O
have	O
any	O
means	O
for	O
the	O
execution	B-General_Concept
of	O
"	O
give	O
up	O
ownership	O
of	O
the	O
lock	O
"	O
to	O
have	O
any	O
influence	O
over	O
which	O
execution	B-General_Concept
of	O
"	O
gain	O
ownership	O
of	O
the	O
lock	O
"	O
in	O
some	O
other	O
timeline	O
(	O
thread	O
)	O
follows	O
.	O
</s>
<s>
Note	O
that	O
modern	O
parallel	O
languages	O
have	O
much	O
easier	O
to	O
use	O
execution	B-Device
models	I-Device
.	O
</s>
<s>
The	O
thread	O
model	O
was	O
one	O
of	O
the	O
original	O
parallel	O
execution	B-Device
models	I-Device
,	O
which	O
may	O
account	O
for	O
why	O
it	O
has	O
persisted	O
despite	O
being	O
difficult	O
to	O
use	O
.	O
</s>
