Re: JavaMemoryModel: prescient write question

From: Yue Yang (yyang@cs.utah.edu)
Date: Tue Jul 09 2002 - 19:40:37 EDT


It seems to me that reading back future write on the same variable from
the same thread would make programming a lot harder and more error prone.

This behavior is very counterintuitive because most people expect to get
serial result, i.e., the value from the most rescent previous write, if
it comes from the same thread.

If this relaxation is permitted by the JMM, to make sure a read won't be
fullfilled by a later write, a memory barrier has to be inserted in the
program after every read if the same variable might be rewritten in the
future.

First, this is error prone since people might forget to do it.
It also introduces a maintenance nightmare because when new code is
added, a correct program might become broken due to the added
write instructions. Second, this might acturally increase the
synchronization burden if the compiler is not smart enough to remove those
extra synchronization instructions in case they're unnecessary for the
underlying implementation.

Questions for all experts in this group:

Are their any existing memory models that allow such behavior, i.e.,
reading back future write at the same location from the same process?

Are there any existing or future implementations that might have to take
advantage of this kind of relaxation?

Thanks!

-- Jason

On Fri, 5 Jul 2002, Bill Pugh wrote:

> >Is it a legitimate concern that the behavior in Case 2 is too relaxed
> >if the read obtains its value from a future write on the _same_
> >variable from the same thread?
> >
> >-- Jason
>
> I don't think so. The fact that the same variable is being used isn't
> particularly significant.
>
> I'm getting a lot of pressure from several people not to impose any
> constraints in the memory model unless they are well motivated. I
> can't see any motivation for forbidding r1 == r2 == 1 in case 2.
>
>
> > > At 9:56 AM -0600 7/2/02, Yue Yang wrote:
> >> >Bill,
> >> >
> >> >Does your semantics allow r1 = 1 in the following cases?
> > > >
> > >> >
> >> >* Case 2:
> >> >
> >> >Thread 1 Thread 2
> >> >
> >> >r1 = x; r2 = x;
> >> >x = 1; x = r2;
> >> >
> >> >
> >> >It's not clear if x = r2 would use the same GUID as x = 1 or if it would
> >> >use a different GUID since assignment with local varialbes is not
> >> >explicitly discussed in your semantics.
> >> >
> >> >Thanks!
> >> >
> >> >-- Jason
> > > >
>

-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



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