2009/12/7 Gabriel Redner
Dear Boosters,
I'm involved in a bit of a dispute in which a colleague is claiming that 'volatile' is necessary to make certain synchronization patterns correct. As part of my response I pointed out that the boost.thread examples don't use it, but he maintains his position - saying that the examples are flawed. I'm frankly somewhat out of my element here, and I'd like to get input from people who have presumably thought about this stuff a good deal.
The example in question is here, under "synopsis":
http://www.boost.org/doc/libs/1_41_0/doc/html/thread/synchronization.html#th...
The claim is that 'volatile' is needed on the boolean, otherwise the compiler might cache the boolean in a register, and the loop would never exit. He cites for support two articles:
http://www.ddj.com/cpp/184403766
https://www.securecoding.cert.org/confluence/display/seccode/DCL17-C.+Beware...
Who's right?
Thanks, -Gabe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Required reading http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for...