RE: JavaMemoryModel: Volatiles - where does SC work and PO doesn' t?

From: Doug Lea (
Date: Tue Nov 21 2000 - 19:59:15 EST

> The difference of interest between SC and PO is that if two processors
> perform multiple writes then all processors will observe the writes of each
> of these processors in the order written (just as with SC) but the
> interleaving of the writes may appear different to different processors. I'm
> looking for algorithms where observing different interleavings of writes on
> different processors breaks the algorithm.
> Put another way, I'm trying to find useful algorithms where a total ordering
> of stores is needed instead of a partial ordering of the stores.

The only kind of case I can imagine is one where you'd like to reason:
  If thread A has progressed to the point where x == X (for some shared x)
  then thread B must have already progressed to where y == Y
Which won't always happen under your PO rules.

For example, the very contrived:

class Job {
  volatile boolean done = false;
  volatile long result = 0;

Job job;

Thread A:
    job.result = nonzero;

Thread B:
   while (job.result == 0) /* spin */ ;
   job.done = true;

Thread C:
   while (!job.done) /* spin */ ;
   answer = job.result; // might not be seen as set yet?

Considering how hard it was to come up with even a stupid, contrived
example, I'm not yet(!) bothered by this rule.

I think the problems Bill alluded to about my deque algorithms for
fork/join frameworks (see
are unrelated to this.

JavaMemoryModel mailing list -

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