[Patch/RFC] tr1::shared_ptr<> removal of lock, choosing thread safety

Peter Dimov pdimov@mmltd.net
Sat Jul 8 01:55:00 GMT 2006


Phillip Jordan wrote:
> Peter Dimov wrote:
>> In addition to your test, you might consider something along the
>> lines of
>>
>> http://www.boost.org/libs/smart_ptr/test/weak_ptr_mt_test.cpp
>>
>> It's still a probabilistic approach, but with a slightly better
>> coverage of the possible races.
>
> I've had a look at this now; looks like a good idea. However, I was
> under the impression that rand() wasn't thread safe as it maintains
> internal state?

http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/stdlib/random.c?rev=1.18&content-type=text/x-cvsweb-markup&cvsroot=glibc

says that

/* POSIX.1c requires that there is mutual exclusion for the `rand' and
   `srand' functions to prevent concurrent calls from modifying common
   data.  */

and seems to have a lock around __random, which rand calls. 



More information about the Libstdc++ mailing list