Subj : Re: posix and lock-free algorithms To : comp.programming.threads From : David Schwartz Date : Fri Aug 12 2005 05:21 pm "Mayan Moudgill" wrote in message news:11fqai13ktc8930@corp.supernews.com... > Actually, it is worse than this. As declared, an ISO standard > compliant C compiler is free to reorder, get rid of, and do > miscellaneous other optimizations to i and j. Of course, but since nobody was talking about an ISO standard compliant C compiler, how is the an issue? > ISO/ANSI C has *NO* knowledge of multi-threading or concurrent > execution. Right, that's why POSIX was created. > There are only a couple of requirements that the compiler has to > satisfy: > - the optimized code must have the same black-box behavior as the > abstract > *sequential* machine > - volatiles force order w.r.t. other volatiles. Umm, no, a POSIX-compliant compiler also has to satisfy the requirements imposed by POSIX. > Unless you declare i & j as volatile, all bets are off. And all the > talk about POSIX (in the context of C) is meaningless, since you're > trying to impose a requirement on the code that is not expressible in > the underlying language (well, at least not in C) That is a totally retarded argument. Every standard that builds on previous standards add new requirements. The POSIX standard *adds* requirements to the C standard. So for your argument to work, it would have to have been impossible for the C standard to have imposed such requirements. What utter nonsense! DS .