OS_TLS_SetValue()
void OS_TLS_SetValue (OS_TCB *p_tcb,
OS_TLS_ID id,
OS_TLS value,
OS_ERR *p_err);
File |
Called from |
Code enabled by |
os_tls.c |
Task |
OS_CFG_TLS_TBL_SIZE |
OS_TLS_SetValue() allows your application to set the value of a TLS (thread-local storage) entry in the specified task’s OS_TCB. Specifically, this function assigns value to p_tcb->TLS_Tbl[id]. See Chapter 20, “Thread Safety of the Compiler’s Run-Time Library” on page 419 for details on TLS.
Arguments
p_tcb
is a pointer to the OS_TCB of the task you wish to assign the TLS value to. value will thus be assigned to p_tcb->TLS_Tbl[id].
id
is the TLS ID of the entry you are setting.
value
is the value to store at p_tcb->TLS_Tbl[id].
p_err
is a pointer to a variable that contains an error code returned by this function. Possible values are:
Returned Value
None
Notes/Warnings
You cannot call OS_TLS_SetValue() for a task until that task gets created.
Example
OS_TLS_ID MyTLS_ID;
void MyTask (void *p_arg) { OS_ERR err; OS_TLS p_tls;
: : while (DEF_TRUE) { p_tls = OSTLS_GetValue((OS_TCB *)0, (OS_TLS_ID)MyTLS_ID, (OS_ERR *)&err); /* Check “err” */ : : } } |