This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: question on semantics


Diego Novillo wrote:
On Wed, May 04, 2005 at 01:47:20PM -0600, Chris Friesen wrote:


Also, what about threads and pthread locking? Do I need to use volatile there? If not, then what about using pthread locking between processes?

Things will only break for you when GCC pulls in function bodies
at link time.  At that point, yes, you will need to declare your
pointed-to area as volatile.

Dave Butenhof (author of "Programming with POSIX Threads") seems to disagree with that position:


"In general, use of "volatile" for variables that are simply shared between threads is unnecessary and wasteful. Proper synchronization is necessary and sufficient; there is no substitute short of coding carefully with specific knowledge of the memory architecture of a specific platform."

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.

Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]