JavaMemoryModel: SC or Coherence for Volatiles?

From: Yang, Yue (yyang@enterasys.com)
Date: Thu Mar 21 2002 - 11:50:25 EST


Bill,
 
In your semantics for volatile variables, you propose to only require total
orders on operations
to each individual variable.
 
Consider the following case:
 
Initially, complete_step1 = complete_step2 = complete_step3 = false;
complete_step1 is normal, complete_ step2 and complete_step3 are volatile.
 
Thread 1:
{
            complete_step1 = true;
            complete_step2 = true;
            complete_step3 = true;
}
 
Thread 2:
{
            if(complete_step3 == true) {
                        r1 = complete_step1;
                        r2 = complete_step2;
                        // at this point, r1 is always true,
                        // but r2 may not be true.
            }
}
 
If we advocate to programmers that they can use volatiles as synchronization
flags, it seems to be
very non-intuitive that a volatile variable flag turns out to have a weaker
meaning than a normal
variable flag.
 
In my opinion, we probably want to enforce SC on volatiles. What's your
thought on this?
 
Jason Yue Yang
Firmware Engineer
Enterasys Networks
Phone: 801-887-9833
 

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



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