Re: JavaMemoryModel: Moving memory operations across external actions

From: Jerry Schwarz (jerry.schwarz@oracle.com)
Date: Thu Apr 15 2004 - 17:09:24 EDT


At 03:01 PM 4/14/2004, Bill Pugh wrote:
>Say that external() is a function that interacts
>with the world outside of a JVM (e.g., it writes
>to a socket). For simplicity's sake, assume it both
>influences and is influenced by the outside world.
>
>Would a compiler ever want to reorder
>
> * a read of a variable and a following
> call to external() ?

Only if it is sure that external() does not write to the variable

> * a call to external() and a following
> write to a variable?

Only if it is sure that external does not read the variable.

> In these cases, I talking about a normal,
>non-volatile variable.

In other words potential actions of external() need to be regarded as part
of the current thread and treated as if they are part of "happens-before".

Unless the compiler has special knowledge of the behavior of the native it
needs to assume it might read or write any (accessible) variable. If it has
such knowledge it can be allowed to take it into account.

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

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



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