Embedded Multicore Building Blocks V1.0.0
Typedefs | Functions
Thread-Specific Storage

Thread-specific storage. More...

Typedefs

typedef opaque_type embb_tss_t
 Opaque type representing a TSS. More...
 

Functions

int embb_tss_create (embb_tss_t *tss)
 Creates thread-specific storage (TSS) pointer slots. More...
 
int embb_tss_set (embb_tss_t *tss, void *value)
 Sets thread-specific slot value of the current thread. More...
 
void * embb_tss_get (const embb_tss_t *tss)
 Gets thread-specific TSS slot value of the current thread. More...
 
void embb_tss_delete (embb_tss_t *tss)
 Deletes all slots of the given TSS. More...
 

Detailed Description

Thread-specific storage.

Implements thread-specific storage (TSS), that is, memory locations that are individual for each thread. Each thread has its own slot for a memory address that can point to a (thread-specific) value. The value pointed to has to be managed, i.e., created and deleted, by the user.

Typedef Documentation

typedef opaque_type embb_tss_t

Opaque type representing a TSS.

Function Documentation

int embb_tss_create ( embb_tss_t tss)

Creates thread-specific storage (TSS) pointer slots.

Precondition
The given TSS has not yet been created or has already been deleted.
Returns
EMBB_SUCCESS if storage could be created
EMBB_NOMEM if not enough memory was available
Dynamic memory allocation
embb_thread_get_max_count() pointers
Concurrency
Not thread-safe
See also
embb_tss_delete(), embb_thread_get_max_count()
Parameters
[out]tssPointer to TSS
int embb_tss_set ( embb_tss_t tss,
void *  value 
)

Sets thread-specific slot value of the current thread.

The value pointed to needs to be managed (created, deleted) by the user.

Precondition
The given TSS has been created
Returns
EMBB_SUCCESS if value could be set
EMBB_ERROR if no thread index could be obtained, that is, the maximum number of threads has been exceeded.
Concurrency
Thread-safe and lock-free
See also
embb_tss_get(), embb_thread_get_max_count()
Parameters
[in,out]tssPointer to TSS
[in]valuePointer to be stored in TSS
void* embb_tss_get ( const embb_tss_t tss)

Gets thread-specific TSS slot value of the current thread.

Precondition
The given TSS has been created
Returns
Thread-specific value if embb_tss_set() has previously been called with a valid address. NULL, if no value was set or the calling thread could not obtain a thread-specific index.
Concurrency
Thread-safe and lock-free
See also
embb_tss_set()
Parameters
[in]tssPointer to TSS
void embb_tss_delete ( embb_tss_t tss)

Deletes all slots of the given TSS.

Does not delete the values pointed to.

Precondition
tss has been created successfully and is not NULL.
Postcondition
All slots are deleted
Concurrency
Not thread-safe
See also
embb_tss_create()
Parameters
[in,out]tssPointer to TSS