...
When OS_TLS_TBL_SIZE
is set to 1 or greater, each task’s OS_TCB
will contain a new array called .OSTCBTLSTbl[]
as shown below. Each array element is of type OS_TLS
which is actually a pointer to void. This allows an OS_TCB
to be extended so that it can have as many TLS areas as needed.
Figure: Each OS_TCB
contains an array of OS_TLS
when OS_TLS_TBL_SIZE
is greater than 0 in os_cfg.h
The number of entries (i.e., the value to set OS_TLS_TBL_SIZE
to) depends on the compiler being supported as well as whether TLS storage is needed for other purposes.
OS_TLS_GetID()
The index into .OSTCBTLSTbl[]
is called the TLS ID and TLS IDs are assigned through an API function. In other words, TLS IDs are assigned dynamically as needed. Once a TLS ID is assigned for a specific purpose, it cannot be ‘unassigned’. The function used to assign a TLS ID is called OS_TLS_GetID()
.
...