[Patch (preview)] libstdc++/24469
Paolo Carlini
pcarlini@suse.de
Fri Sep 1 03:41:00 GMT 2006
Paolo Carlini wrote:
> I think everything is fine... Otherwise, please stop me before it's
> too late! :)
Well, I can see a serious problem myself but it's fixable ;)
In a pure producer/consumer scheme, for example, some threads only
allocate and some, different, threads only deallocate, thus _M_used of
the allocating threads can easily overflow, especially so the atomic
counters, which are only 32-bits wide. The solution, simple, is
resyncing _M_used of each thread to its reclaimed counterpart at the
beginning of both _M_reclaim_block and _M_reserve_block (the fast
allocations, using _M_adjust_freelist are not affected and the binary
compatibility still safe). In order not to affect the performance we can
do that every fixed number of allocations and deallocations, say 1 << 12
or something, and easily amortize the atomic... Will do tomorrow....
Paolo.
More information about the Libstdc++
mailing list