Jeremy and Bill,
In Section 8.6.1 of your JMM proposal, you indicated that:
"The simple semantics enforce a total order over all volatile writes. This
means that each
thread must see accesses to every volatile variable in the order in which
they were written."
Based on this, you tried to relax the restriction so that there is only a
total order over writes
to individual volatile variables by splitting a writeVolatile into
initVolatileWrite and
performVolatileWrite in Section 8.6.2.
However, it seems to me that your simple semantics on volatiles as dictated
by Figure 12
is already more relaxed than SC.
You use a single buffer volatileValue for each individual volatile variable.
When you read
two different volatileValues, there is no constraint on order based on the
time stamp of
the volatileValues. So even though each writeVolatile is carried out in a
single step, two
writes to different variables can be observed by other threads in different
order.
For your example in Foigure 13:
Initially, a = b = u = v = w = x = 0; a, b are volatile
T1 T2 T3 T4
a = 1; u = b; b = 1; w = a;
v = a; x = b;
The following execution should be a legal trace allowed by semantics in
Figure 12:
T1 T2 T3 T4
u=read b, 0
write b, 1
w=read a, 0
a = 1
v=read a, 1
x=read b, 1
Therefore, (u == 0, v == 1, w == 0, x == 1) is indeed a legal result. As a
result, you
don't need to split writeVolatile to achieve your intention.
Is there anything I'm missing from your simple semantics?
Jason Yue Yang
Firmware Engineer
Enterasys Networks
Phone: 801-887-9833
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:38 EDT