Subj : Re: Memory Barriers, Compiler Optimizations, etc. To : comp.programming.threads From : Scott Meyers Date : Thu Feb 03 2005 07:45 pm On Thu, 3 Feb 2005 16:58:10 -0800, SenderX wrote: > I use volatile for source code documentation only. That about how usefull it > really is wrt this kind of stuff. So if you want to write something like this: int data; bool dataIsReady; ... data = 22; // set data to communicate to other threads dataIsReady = true; // let other threads know that they can read data How do you ensure that the compiler doesn't invert the order of those assignments? > What do think about this "simple" strategy??? It seems reasonable to me, and it's consistent with another posting I just made. In theory, you could get arbitrarily fine-grained with the information you pass to the compilers this way. Unfortunately, pragmas are defined to be inherently platform-specific, and my guess is that it'd be very difficult to get the C or C++ committees to standardize pragmas. A similar idea is something like Microsoft's attributes, which, oddly enough, might be easier push, because it's introducing something brand new rather than changing the semantics of something that currently exists. Scott .