[c++-pthreads] pthreads and operator new
Howard Hinnant
hinnant at twcny.rr.com
Fri Mar 16 20:55:52 UTC 2007
On Mar 16, 2007, at 9:00 AM, Markus Schaber wrote:
> My question is simple: Does the combination of C++98 and Posix pthread
> standards give any guarantee that the operator new is "thread safe",
> means that several threads can allocate objects via "new" concurrently
> without explicit locking by the user code?
>
> Our current research seems to indicate that pthread standards don't
> mention C++ in any way, and C++ does not mention threads, and it is
> pure benevolence (or plain sanity?) of the implementations I have seen
> up to now to provide a thread safe implementation of new (mostly based
> on a global lock).
Your research is correct. Though you might also add "market value" to
your list of reasons. C++ vendors would otherwise go out of business.
The C++ committee is attempting to address this shortcoming in an
upcoming standard colloquially termed C++0X (we hope the X will become
a 9).
-Howard
More information about the c++-pthreads
mailing list