OS_TLS_GetID
Description
Called by the application to assign a TLS (thread-local storage) ID for a specific purpose. See Thread Safety of the Compiler’s Run-Time Library for details on TLS. TLS IDs are assigned dynamically as needed by the application. Once assigned, TLS IDs cannot be un-assigned.
Files
os.h/os_tls.c
Prototype
OS_TLS_ID OS_TLS_GetID (OS_ERR *p_err)
Arguments
p_err
is a pointer to a variable that contains an error code returned by this function. Possible values are:
OS_ERR_NONE
If the call was successful and the caller was returned a TLS ID.
OS_ERR_TLS_NO_MORE_AVAIL
If you called OS_TLS_GetID() more than OS_CFG_TLS_TBL_SIZE times.
Returned Value
The next available TLS ID or OS_CFG_TLS_TBL_SIZE if there are no more TLS IDs available.
Required Configuration
OS_CFG_TLS_TBL_SIZE must be greater than 0 in os_cfg.h. Refer to µC-OS-III Configuration Manual.
Callers
Application.
Notes/Warnings
None
Example Usage
OS_TLS_ID MyTLS_ID;
void main (void)
{
OS_ERR err;
:
OSInit(&err);
:
:
MyTLS_ID = OS_TLS_GetID(&err); /* Obtain the next available TLS ID */
/* Check "err" */
:
:
}