Tomash Brechko writes: > On Mon, Oct 22, 2007 at 11:19:31 +0100, Andrew Haley wrote: > > Please have a read of [1]. Let us know if anything you have observed > > isn't covered in that paper. > > > > [1] Hans-Juergen Boehm. Threads cannot be implemented as a library. In > > Proc. of the ACM SIGPLAN 2005 Conf. on Programming Language > > Design and Implementation (PLDI), pages 261?268, Chicago, IL, June > > 2005. > > Unfortunately I'm not lucky enough to have ACM access. But from the > Abstract:
www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf > We provide specific arguments that a pure library approach, in which > the compiler is designed independently of threading issues, cannot > guarantee correctness of the resulting code. > > Can't agree less! That's why for _practical_ reasons I'd say GCC > should be thread-aware, even if _theoretically_ it doesn't have to. Well, that's a big job: you'd have to decide on what a memory model really should be, and then implement that model. The right approach is surely to do this within the standardization bodies, which seems to be the approach Hans Boehm is suggesting. In the meantime, a prudent programmer will make conservative assumptions and use volatile, especially if they hope to write portable programs. Andrew.