libstdc++/5037: Multithreaded read access to strings not threadsafe on Solaris/Sparc
Nathan Myers
ncm-nospam@cantrip.org
Thu Dec 6 18:06:00 GMT 2001
On Thu, Dec 06, 2001 at 07:40:26PM -0600, Loren James Rittle wrote:
> ... I am afraid that this is an
> ABI change for all sparc ports. Assume that others might prefer
> another final solution to fix this on the 3.0.X branch with a
> different performance tradeoff.]
Yes, a more minimal change for 3.0.x seems advisable.
> In the interest of getting a fix in the mainline tree ASAP, here is
> the obvious solution that requires no change to the abstraction layer
> and I think meets any contention-efficiency goals.
> ...
> ! struct _Atomic_word
> ! {
> ! unsigned char __lock;
> ! int __word;
> ! operator int() const { return __word; }
> ! operator = (const int x) { return x == __word; }
> ! _Atomic_word () : __lock (0), __word (0) {}
> ! };
Unfortunately this makes a basic_string<>::_Rep substantially larger.
Also, it cannot be put in places that need a POD. Probably if we do
something like this in 3.1 a change to the abstraction layer is
appropriate.
Do we really expect to see much contention on this lock? It's held
for such a short time.
Nathan Myers
ncm at cantrip dot org
More information about the Libstdc++
mailing list