Subj : Re: Adding thread support for C... To : comp.programming.threads From : Ian Date : Sat Jul 23 2005 12:11 pm Joe Seigh wrote: >> The compiler was eliminating the wait-loops [as it should]. We had to >> introduce a mechanism to inhibit this optimization. >> >> It turns out that, as the compiler starts optimizing more, and worse, >> doing whole program optimizations, it becomes critical with >> multi-threaded programs to make sure that the compiler can distinguish >> between optimizations that would be correct in single-threaded C but >> are invalid in multi-threaded codes. >> > > What you won't get is support for writing your own synchronization api's, > Not unless you can construct them out of the synchronization functions they > give you. Probablly something like the atomic stuff in JSR 166. You > might want to take a look at that. > > Also look at the current discussion of what's being looked at for C++. > http://decadentplace.org.uk/pipermail/cpp-threads_decadentplace.org.uk/ > > What people don't realize is that most C compilers can't do all the > optimization > they could do because they'd break all kinds of things, Linux kernel > and lot's > of device drivers for instance. Once you put in official thread support > you can > be rigidly restricted to the rules. No more coding outside the box. > I've seen a couple of embedded compilers that provide extensions to work round these issues, maybe a better solution is through pragmas or compiler options as this stuff tends to be platform specific. Ian .