Arm® C++ libraries and multithreading [ALPHA]
The C++ Thread Porting Application Programming Interface (API) is an [ALPHA]-supported API that enables the use of C++11 concurrency constructs with Arm® Compiler 6. Operating system or library vendors must provide an implementation of this API to enable the seamless use of C++11 concurrency constructs within user applications.
NoteThis topic describes an [ALPHA] feature. See Support level definitions.
The C++11 standard offers several high-level concurrency constructs intended to simplify parallel programming and make multithreaded programs portable across platforms. Future versions of the C++ standard are set to introduce additional high-level concurrency constructs. For more information, see https://isocpp.org/std/status.
Most standard library implementations expect an underlying operating system or library platform to provide a comprehensive set of primitive concurrency constructs on top of which these higher level constructs can be built.
The default standard C++ library supplied with Arm Compiler 6 has been built without concurrency support to avoid passing these dependencies to target bare-metal systems.
Arm Compiler 6 includes
a special variant of the standard C++ library that enables support for C++11
concurrency constructs. This library variant requires platform vendors to provide an
implementation of the threading API described in this document. On certain
architectures, for example the Armv6‑M architecture, this threaded library variant might contain
library calls to various
__atomic_* functions. On
these architectures, platform vendors must also provide an implementation of an
atomics library as discussed in LLVM Atomic Instructions and Concurrency Guide.
To select the threaded standard C++ library variant instead of the default
variant use the compiler options
-D_ARM_LIBCPP_EXTERNAL_THREADS together with linker option
Platform vendors can selectively implement subsets of the porting API based on the dependencies between the high-level C++11 concurrency constructs and the underlying platform concurrency primitives.
Arm Compiler 6 provides C++ libraries that are based on open source LLVM technology. The libraries for multithreaded applications are:
- The standard library,
- Low level support for the standard library,
- Exception unwinding support library,
The C++ Thread Porting API enables these libraries to correctly operate in different multithreaded environments.
NoteThe C++ Thread Porting API is independent of the multithreaded support API provided in the Arm C library. For more information, see Multithreaded support in Arm® C libraries. Platform vendors must implement both of these APIs, to the respective specifications, to ensure correct operation of multithreaded programs. The C++ Thread Porting API is declared in the
<arm-tpl.h>header file of the Arm Compiler 6 distribution.
The C++ Thread Porting API functional areas include:
- Conditional variables.
- Miscellaneous functions.