Description
Returns the current value of a task’s TLS (thread-local storage) stored in the task’s p_tcb->TLS_Tbl[id]. See Chapter 20, “Thread Safety of the Compiler’s Run-Time Library” for details on TLS.
Files
os.h/os_tls.c
Prototype
Code Block |
---|
OS_TLS OS_TLS_GetValue (OS_TCB *p_tcb, |
...
OS_TLS_ID id, |
...
OS_ERR *p_err); |
File | Called from | Code enabled by |
---|---|---|
| Task | OS_CFG_TLS_TBL_SIZE |
OS_TLS_GetValue()
is called by the application to retrieve the current value of a task’s TLS (thread-local storage) stored in the task’s p_tcb->TLS_Tbl[id]
. See Chapter 20, “Thread Safety of the Compiler’s Run-Time Library” for details on TLS.
Arguments
p_tcb
is a pointer to the OS_TCB
of the task you wish to retrieve the TLS from. You will get a copy of the p_tcb->TLS_Tbl[id]
entry and of course, the entry will not be changed.
...
is a pointer to a variable that contains an error code returned by this function. Possible values are:
OS_ERR_NONE
if If the call was successful and the caller was returned the value.
OS_ERR_OS_NOT_RUNNING
if If you called OS_TLS_GetValue()
and the kernel has not started yet. However, it’s acceptable to call this function prior to starting multitasking but in this case, you must specify a non-NULL
pointer for p_tcb
.
OS_ERR_TLS_ID_INVALID
if If you called OS_TLS_GetValue()
and specified a TLS ID that has not been assigned. See OS_TLS_GetID()
about assigning TLS IDs.
OS_ERR_TLS_NOT_EN
if If you called OS_TLS_GetValue()
but the task was created with the option OS_OPT_TASK_NO_TLS
indicating that the task does not need TLS support.
Returned Value
The value store in p_tcb->TLS_Tbl[id]
or NULL
if an error occurred.
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
- You cannot call
OS_TLS_GetValue()
for a task until that task gets created.
Example Usage
Code Block | ||
---|---|---|
| ||
OS_TLS_ID MyTLS_ID;
void MyTask (void *p_arg)
{
OS_ERR err;
OS_TLS p_tls;
:
:
while (DEF_TRUE) {
p_tls = OS_TLS_GetValue((OS_TCB *)0,
(OS_TLS_ID)MyTLS_ID,
(OS_ERR *)&err);
/* Check "err" */
:
:
}
} |