THREADS AND LOCKS
Nonatomic Treatment of
double
and
long
17.4
After a variable is created, every thread must perform an
assign
or
load
action
on that variable before performing a
use
or
store
action on that variable. (Less
formally: a new variable is created only in main memory and is not initially in
any thread's working memory.)
Provided that all the constraints above and below are obeyed, a
load
or
store
action may be issued at any time by any thread on any variable, at the whim of the
implementation.
There are also certain constraints on the
read
and
write
actions performed by
main memory:
For every
load
action performed by any thread
T
on its working copy of a
variable
V
, there must be a corresponding preceding
read
action by the main
memory on the master copy of
V
, and the
load
action must put into the work
ing copy the data transmitted by the corresponding
read
action.
For every
store
action performed by any thread
T
on its working copy of a
variable
V
, there must be a corresponding following
write
action by the main
memory on the master copy of
V
, and the
write
action must put into the master
copy the data transmitted by the corresponding
store
action.
Let action
A
be a
load
or
store
by thread
T
on variable
V
, and let action
P
be
the corresponding
read
or
write
by the main memory on variable
V
. Similarly,
let action
B
be some other
load
or
store
by thread
T
on that same variable
V
,
and let action
Q
be the corresponding
read
or
write
by the main memory on
variable
V
. If
A
precedes
B
, then
P
must precede
Q
. (Less formally: actions on
the master copy of any given variable on behalf of a thread are performed by
the main memory in exactly the order that the thread requested.)
Note that this last rule applies
only
to actions by a thread on the
same
variable.
However, there is a more stringent rule for
volatile
variables ( 17.7).
17.4 Nonatomic Treatment of
double
and
long
If a
double
or
long
variable is not declared
volatile
, then for the purposes of
load
,
store
,
read
, and
write
actions they are treated as if they were two variables of
32 bits each: wherever the rules require one of these actions, two such actions are
performed, one for each 32 bit half. The manner in which the 64 bits of a
double
or
long
variable are encoded into two 32 bit quantities is implementation depen
dent.
This matters only because a
read
or
write
of a
double
or
long
variable may
be handled by an actual main memory as two 32 bit
read
or
write
actions that may
405
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved