Re: JavaMemoryModel: prescient write question

From: Bill Pugh (
Date: Sun Jul 14 2002 - 20:56:34 EDT

At 5:23 PM -0700 7/13/02, Jerry Schwarz wrote:
>At 12:17 PM 7/10/2002, Bill Pugh wrote:
>I think the problem is that some of us, including myself, don't see
>any possible allowable reordering that results in r1 = 1.

Perhaps, but so what? It isn't relevant that we can't think up a
reordering that would induce it.

Consider a program P.

Let B(P) represent all of the behaviors that can be induced by by all
of architectures and compiler transformations that you, me, and all
the people on this list can think up.

Let B'(P) represent all the behaviors allowed by the semantics.

Now, you seem indicate that you think B'(P) should be equal to B(P).

Clearly, as much as possible, B'(P) should be a superset of B(P) (it
turns out we will have to rule out a few transformations that aren't
treadsafe, but we'll ignore those for the moment).

But you just aren't going to be able to make the semantics so tight
that the only behaviors allowed are those that can be induced by
transformations we can think of. If you attempt to do so, you are
going to make the semantics more and more baroque. And you will
almost certainly overshoot, and rule out some behavior that can be
induced by some transformation we hadn't considered.

You need to have a semantics that:

* forbids the things that need to be forbidden
* allows the things that need to be allowed
* Is a simple as possible

At 5:23 PM -0700 7/13/02, Jerry Schwarz wrote:
>Assuming that x1 and x2 are local to the threads, then I think only
>way that r1 can get 1 is by having the operations in Thread 1 have
>the ordering
> t1.x2=1 --> x=t1.x2 --> t1.x1=x --> r1=t1.x1

No, in my example x1 and x2 were shared memory.

JavaMemoryModel mailing list -

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