Subj : Re: 'volatile' Rules To : comp.programming.threads From : David Butenhof Date : Tue Jun 07 2005 02:29 pm Marcin 'Qrczak' Kowalczyk wrote: > Since without memory synchronization (which is done e.g. by locking > and unlocking mutexes) you can't reliably access data from multiple > threads, volatile is not necessary for multithreading at all. > > Except various lock-free algorithms, but there volatile is not enough > - they typically need atomic operations which also synchronize memory > between threads, not available in ISO/ANSI C nor even in POSIX. Yes. The capsule summary is: "volatile has nothing to do with threads". Either you don't need help in the first place and volatile will only hurt, or you need "something", but standard volatile semantics will not be enough. An interesting and surprisingly relevant dictionary definition for "volatile": Inconstant; fickle: a flirt's volatile affections. Don't count on volatile. ;-) -- Dave Butenhof, David.Butenhof@hp.com HP Utility Pricing software, POSIX thread consultant Manageability Solutions Lab (MSL), Hewlett-Packard Company 110 Spit Brook Road, ZK2/3-Q18, Nashua, NH 03062 .