shared_ptr's reference counter thread safety on ARM Cortex-M
Oleg Endo
oleg.endo@t-online.de
Mon Feb 19 15:38:00 GMT 2018
On Mon, 2018-02-19 at 15:07 +0000, Jonathan Wakely wrote:
>Â
> > Why is _S_atomic not used?
> Because --enable-threads=single means the library can assume there
> will never be more than one thread, so why use atomic operations?
>
> >
> > Is there a way to build/configure gcc/libstdc++
> > and/or the application to get thread safe shared_ptr on this (bare-
> > metal ARM) platform?
> Yes, don't use --enable-threads=single if you want to use multiple
> threads.
>
Even though on such systems there might not be real threads, atomic
operations can still be useful, e.g. when sharing variables between the
"main thread" and interrupt handlers (adhoc preemptive threads so to
say).
Probably the easiest way around this issue is to pretend all
GCC/libstdc++ configury stuff that the system does support threads.
 Although it might open some cans of worms.  Another alternative is to
hack-n-patch the toolchain source until it fits during the toolchain
build process.
BTW there is one related open issue that comes to mind
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53579
Cheers,
Oleg
More information about the Libstdc++
mailing list