question on semantics

Chris Friesen cfriesen@nortel.com
Wed May 4 21:45:00 GMT 2005


Diego Novillo wrote:
> On Wed, May 04, 2005 at 02:47:14PM -0600, Chris Friesen wrote:

>>In multiple messages to comp.programming.threads he has stated that 
>>volatile is not necessary between threads if you use the posix locking 
>>functions, and in fact that one of the main purposes of the posix locks 
>>is to ensure correct memory visibility between threads.

> That still assumes that the compiler isn't pulling the body of
> pthread_mutex_lock, deciding that it doesn't really clobber any
> globals and proceeding to consider it a read-only function.  At
> this point in time, and for the foreseeable future this will
> remain to be true.

Right.  I suspect that he would consider such behaviour as rendering 
that version of GCC as non POSIX compliant.

> The real future-proof fix is to mark them as such and have the
> compiler recognize that attribute.  This means adding concurrency
> semantics to the compiler.  Something that we are in the process
> of doing.

Cool.  Thanks for all the explanations.  I'm going to be giving an 
internal talk on programming for concurrency, and I've learned way more 
doing the research for the talk than most of the attendees will 
currently be able to appreciate.

Chris




More information about the Gcc mailing list