Subj : Re: 'volatile' Rules To : comp.programming.threads From : Uenal Mutlu Date : Tue Jun 07 2005 07:51 pm "David Schwartz" wrote > > "Uenal Mutlu" wrote > > > Some experimentations show that the second method ("b and c and d") > > is by no means reliable. It _seems_ to work only if there is no function > > call > > between the visits to the variable, or if the called functions are all > > inlined > > (--> ie. rule d seems to be wrong). > > The consequence is: only the use of locking gives a safe method, > > everything else is unreliable and very risky. > > Unless you're just screwing around for the heck of it, why would you > even mess with something that "just happens to work"? Would you advocate > 'malloc'ing smaller blocks of memory that you are going to use because your > implementation of 'malloc' happens to round them up?! It was an attempt to find reliable rules when and when not to use 'volatile'. There seems indeed be no good reason to use volatile: it's unsafe/unreliable/unpredictable and a performance killer, in short: totally useless. Maybe someone can list when it is ever useful, if any. .