...
Description
Sets 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 20Chapter 20, “Thread Safety of the Compiler’s Run-Time Library” on page 419 for details on TLS. Anchor
Files
os.h/os_tls.c
Prototype
Code Block |
---|
void OS_TLS_SetValue (OS_TCB *p_tcb,
OS_TLS_ID id,
OS_TLS value,
OS_ERR *p_err) |
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
1078046 Anchor
is the value to store at p_tcb->TLS_Tbl[id]
.
Anchor
p_err
is a pointer to a variable that contains an error code returned by this function. Possible values are:
...
...
OS_ERR_NONE
...
class | WebWorks_Indent_2 |
---|
...
If the call was successful and the caller was returned the value.
...
class | WebWorks_Indent_1 |
---|
...
OS_ERR_OS_NOT_RUNNING
...
class | WebWorks_Indent_2 |
---|
...
If you called OS_TLS_SetValue()
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
.
...
class | WebWorks_Indent_1 |
---|
...
...
OS_ERR_TLS_ID_INVALID
...
class | WebWorks_Indent_2 |
---|
...
If you called OS_TLS_GetValue()
and specified a TLS ID that has not been assigned. See OS_TLS_GetID()
about assigning TLS IDs.
...
class | WebWorks_Indent_1 |
---|
...
...
OS_ERR_TLS_NOT_EN
...
class | WebWorks_Indent_2 |
---|
...
If you called OS_TLS_SetValue()
but the task was created with the option OS_OPT_TASK_NO_TLS
indicating that the task does not need TLS support.
...
...
Returned Value
anchorNone
Required Configuration
OS_CFG_TLS_TBL_SIZE
must greater than 0 in os_cfg.h
. Refer to µC-OS-III Configuration Manual.
Callers
Application.
Notes/Warnings
...
- You cannot call
OS_TLS_SetValue()
for a task until that task gets created.
...
...
Example Usage
...
Code Block |
---|
...
HTML Table | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
summary | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class | Code_Listing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Cell (td) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083151 | 1083151 |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OS_TLS_ID MyTLS_ID; Anchor | | 1083152 | 1083152 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083153 | 1083153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083154 | 1083154 | void MyTask (void *p_arg)|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083155 | 1083155 | {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083156 | 1083156 | OS_ERR err;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083157 | 1083157 | OS_TLS p_tls;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083158 | 1083158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083159 | 1083159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083160 | 1083160 | :|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083161 | 1083161 | :|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083162 | 1083162 | while (DEF_TRUE) {|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083163 | 1083163 | p_tls =|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083164 | 1083164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083165 | 1083165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083166 | 1083166 | /* Check “err” */|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083167 | 1083167 | :|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083168 | 1083168 | :|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083169 | 1083169 | }|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anchor | 1083170 | 1083170 | }|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Table Row (tr) |
...
/* Check "err" */
:
:
}
} |