11.10 Thread Local Storage (TLS)

Thread Local Storage is a method of allowing common static variables to have per thread instances. This feature is provided through the GNU __thread keyword and implemented across devices supported by XC-DSC.

The standard MUSL Library does not implement any global variables (such as errno) using TLS, but the Picolibc implementation does. Nevertheless, client code may wish to make use of the TLS support in applications, perhaps with a bespoke thread safe library. This section will cover those details.

When there are TLS variables, the language tool will arrange to access these objects through the current thread. By default, the main thread will have an allocated and initialized thread local storage area. More areas may be allocated and accessed using the interfaces described in this section.