Re: JavaMemoryModel: Semantics for yield and sleep

From: Cliff Click (Cliff.Click@sun.com)
Date: Fri Jan 04 2002 - 12:50:12 EST


Bill Pugh wrote:

>
> I don't know of any other acceptable way to prohibit such transformations.
>
> And I don't like the idea of having a semantics that allows these
> transformations, but not clearly spelling out the implications of the
> semantics. If the semantics allows these transformations, the
> description of the semantics should clearly state so.
>
> So, are people happier with the idea of having the semantics clearly
> state that these transformations are legal but undesirable from a
> quality of service point of view?
>
> Bill
>
> -------------------------------
> JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel

Yup. A Quality implementation will transform example 1 into:

Thread 1:
while (x == 0) {
   int r1 = x;
   for( int i=0; i<8 /*unroll-n-jam amount*/; i++ )
     ;
}

thus doing nothing much much faster. :-)
I.e., any hoisting of volatiles or locks exposes us to
starvation or deadlock problems, which can be fixed by
testing the value somewhat less often. If you can't
deny it cleanly in the sematics, then don't bother.
No real implementation will shoot itself in the foot
so vigourously.

Cliff

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



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