Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [c++-pthreads] pthreads and operator new


  • To: C++ Pthreads Discussion list <c++-pthreads@xxxxxxxxxxxxxxxx>
  • Subject: Re: [c++-pthreads] pthreads and operator new
  • From: Howard Hinnant <hinnant@xxxxxxxxxxxx>
  • Date: Fri, 16 Mar 2007 16:55:52 -0400

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