Threads and memory model for C++

This page provides information related to the effort to clarify the meaning of multi-threaded C++ programs, and to provide some standard thread-related APIs where those are currently missing.

Although some minor bug fixes are always likely, this effort has now been largely completed. The C++0x (most likely really C+11) international standard was recently approved. It contains a carefully defined memory model (mostly in 1.10, with a few pieces in clause 29), an atomic operations library (clause 29), and a threads API (clause 30). The addition of lambda expressions (5.1.2) to the language also makes it easier to write small multithreaded applications.

Here we list some of the documents relevant to that effort.

Memory model background papers

H. Boehm, ``Threads Cannot Be Implemented As a Library'', HP Labs Technical Report HPL-2004-209, also in PLDI 2005. [The issues that motivated at least the author to look at this.]

Peter Buhr, "Are Safe Concurrency Libraries Possible?". Compressed PostScript. [A much older paper with a similar conclusion, but a different justification.]

Java memory model specification. [The Java memory model specification. This is has to address sand-boxing and type-safety issues. Hence this is not quite the same problem.]

OpenMP Application Program Interface. (Their Architecture Review Board, the authors of this document, has apparently also been concerned with memory model issues. There is some discussion in section 2.7.5, and perhaps in other places.)

Manson, Pugh, Adve, "The Java Memory Model", POPL '05. Author's web site version. [Discussion of the Java memory model.]

Adve, Gharachorloo, "Shared Memory Consistency Models: A Tutorial", DEC WRL Research Report 95/7 HP web site copy. [A very good and relatively brief overview of hardware memory consistency models.]

Sarita Adve, "Designing Memory Consistency Models for Shared-Memory Multiprocessors", University of Wisconsin-Madison Technical Report #1198, December 1993, [Sarita Adve's Ph.D. Thesis. Looks at different memory models along the lines we have been discussing.]

Atomic operations background material

The java.util.concurrent.atomic package.

The atomic_ops package.

Alexander Terekhov and Peter Dimov discussion of memory barriers