JavaMemoryModel: SC or Coherence for Volatiles?

From: Eliot Moss (
Date: Thu Mar 21 2002 - 12:57:33 EST

Hmmm ... my understanding of the intent was a little bit different:

If a single thread, say T1, writes more than one volatile field, say VA and
VB, in that order, I think all other threads should be required to see
those in that order. That is:

volatiles VA and VB; initially VA = VB = 0;

  VA = 1;
  VB = 1;

   if (VB == 1) {
     int x = VA;

I would say that it is _desired_ that x == 1.

However, if Ta writes VA and Tb writes VB, with no other connection between
those writes, then other threads may observes the writes in either
order. Put another way, in T1, the write of VA must be complete, throughout
the system, before the write to VB starts. However, if two writes to
different variables are _concurrent_, then they may be perceived in
different orders by different observers. To get ordering, you have to touch
something _in common_.

I would claim we want _causality_ at a minimum, and that SC is too strong
(for good performance on some hardware). Causality becomes a little more
interesting if you conceive of a write (or read) as something that occurs
over a span of time, rather than at a single moment. You can place one
operation entirely before another only if the second _starts_ after the
first one _completes_.

I would be interested in Bill's and Jeremy's views on this :-) .... Eliot
J. Eliot B. Moss, Associate Professor www
Department of Computer Science +1-413-545-4206 voice
140 Governor's Drive, Room 372 +1-413-545-1249 fax
University of Massachusetts email
Amherst, MA 01003-9264 USA +1-413-545-3733 Priscilla Coe sec'y
JavaMemoryModel mailing list -

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:38 EDT