Skip to main content

IAR Embedded Workbench for Arm 9.70.x

Managing a multithreaded environment

In this section:

In a multithreaded environment, the standard library must treat all library objects according to whether they are global or local to a thread. If an object is a true global object, any updates of its state must be guarded by a locking mechanism to make sure that only one thread can update it at any given time. If an object is local to a thread, the static variables containing the object state must reside in a variable area local to that thread. This area is commonly named thread-local storage (TLS).

The low-level implementations of locks and TLS are system-specific, and is not included in the DLIB runtime environment. If you are using an RTOS, check if it provides some or all of the required functions. Otherwise, you must provide your own.

C++ exceptions in threads

Using exceptions in threads works as long as the main function for the thread has the noexcept exception specification. Otherwise non-caught exceptions will not correctly terminate the application.