skaller <[EMAIL PROTECTED]> writes:

> On Fri, 2007-10-26 at 07:58 -0700, Ian Lance Taylor wrote:
> > skaller <[EMAIL PROTECTED]> writes:
> > 
> > > As I understand it volatile is typically used as a 'hint'
> > > to the compiler that there could be aliases it cannot see.
> > > This is independent of the use suggesting asynchronous changes
> > > in a hardware port for example, although the effect is the same.
> > 
> > Not really.  Volatile has a reasonably precise definition: it means
> > that memory accesses must be done precisely as they are written in the
> > program.  They may not be coalesced, and they may not be moved.
> 
> I understand that's the common meaning .. but the semantics
> aren't specified for ISO C/C++.

Sure they are.  In the C99 standard look at the definition of sequence
points (5.1.2.3) and the definition of volatile (6.7.3).


> > > [BTW I think this sucks, the need to synchronise ALL memory
> > > on mutexing is far too heavy]
> > 
> > It can not be avoided, for the reasons you describe.
> 
> Of course it can be avoided easily if the memory model
> allowed for local synchronisation sets, so the real problem
> appears to be that Posix doesn't provide proper synchronisation
> control.

Or that POSIX only provides heavyweight synchronization.

As I understand it, the draft C++0x memory model has acquire release
semantics for annotated variables.  Of course, it wouldn't help the
originalk test case unless the global variable was annotated.

Ian

Reply via email to