µOS++ IIIe / CMSIS++ / POSIX++ Reference  v6.3.11
“Perfekt ist nicht gut genug”
The third edition of µOS++ and CMSIS++, a proposal for the next generation CMSIS, written in C++.

C API thread definitions. More...

Classes

struct  os_thread_attr_s
 Thread attributes. More...
 
struct  os_thread_context_s
 Thread context. More...
 
struct  os_thread_s
 Thread object storage. More...
 
struct  os_thread_stack_s
 Thread stack. More...
 
struct  os_thread_statistics_s
 Thread statistics. More...
 

Types

typedef struct os_thread_attr_s os_thread_attr_t
 Thread attributes. More...
 
typedef struct os_thread_context_s os_thread_context_t
 Thread context. More...
 
typedef void * os_thread_func_args_t
 Type of thread function arguments. More...
 
typedef void *(* os_thread_func_t) (os_thread_func_args_t args)
 Type of thread function. More...
 
typedef uint8_t os_thread_prio_t
 Type of variables holding thread priorities. More...
 
typedef os_port_thread_stack_allocation_element_t os_thread_stack_allocation_element_t
 Type of variables holding aligned stack elements. More...
 
typedef os_port_thread_stack_element_t os_thread_stack_element_t
 Type of variables holding stack words. More...
 
typedef struct os_thread_stack_s os_thread_stack_t
 Thread stack. More...
 
typedef uint8_t os_thread_state_t
 Type of variables holding thread states. More...
 
typedef struct os_thread_statistics_s os_thread_statistics_t
 Thread statistics. More...
 
typedef struct os_thread_s os_thread_t
 Thread object storage. More...
 

Enumerations

enum  {
  os_thread_priority_none = 0,
  os_thread_priority_idle = (1 << (4) ),
  os_thread_priority_lowest = (2 << (4) ),
  os_thread_priority_low = (2 << (4) ),
  os_thread_priority_below_normal = (4 << (4) ),
  os_thread_priority_normal = (6 << (4) ),
  os_thread_priority_above_normal = (8 << (4) ),
  os_thread_priority_high = (10 << (4) ),
  os_thread_priority_realtime = (12 << (4) ),
  os_thread_priority_highest = (((13 + 1) << (4) ) - 1),
  os_thread_priority_isr = (((14 + 1) << (4) ) - 1),
  os_thread_priority_error = (((15 + 1) << (4) ) - 1)
}
 Thread priorities; intermediate values are also possible. More...
 
enum  {
  os_thread_state_undefined = 0,
  os_thread_state_ready = 1,
  os_thread_state_running = 2,
  os_thread_state_suspended = 3,
  os_thread_state_terminated = 4,
  os_thread_state_destroyed = 5
}
 An enumeration with all possible thread states. More...
 

Current Thread Functions

os_thread_tos_this_thread (void)
 Get the current running thread. More...
 
void os_this_thread_suspend (void)
 Suspend the current running thread to wait for an event. More...
 
void os_this_thread_exit (void *exit_ptr)
 Terminate the current running thread. More...
 
os_result_t os_this_thread_flags_wait (os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Wait for thread event flags. More...
 
os_result_t os_this_thread_flags_try_wait (os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Try to wait for thread event flags. More...
 
os_result_t os_this_thread_flags_timed_wait (os_flags_mask_t mask, os_clock_duration_t timeout, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Timed wait for thread event flags. More...
 
os_result_t os_this_thread_flags_clear (os_flags_mask_t mask, os_flags_mask_t *oflags)
 Clear thread event flags. More...
 
os_flags_mask_t os_this_thread_flags_get (os_flags_mask_t mask, os_flags_mode_t mode)
 Get/clear thread event flags. More...
 

Thread Attribute Functions

void os_thread_attr_init (os_thread_attr_t *attr)
 Initialise the thread attributes. More...
 

Thread Creation Functions

void os_thread_construct (os_thread_t *thread, const char *name, os_thread_func_t func, const os_thread_func_args_t args, const os_thread_attr_t *attr)
 Construct a statically allocated thread object instance. More...
 
void os_thread_destruct (os_thread_t *thread)
 Destruct the statically allocated thread object instance. More...
 
os_thread_tos_thread_new (const char *name, os_thread_func_t func, const os_thread_func_args_t args, const os_thread_attr_t *attr)
 Allocate a thread object instance and construct it. More...
 
void os_thread_delete (os_thread_t *thread)
 Destruct the thread object instance and deallocate it. More...
 

Thread Functions

const char * os_thread_get_name (os_thread_t *thread)
 Get the thread name. More...
 
os_thread_prio_t os_thread_get_priority (os_thread_t *thread)
 Get the thread current scheduling priority. More...
 
os_result_t os_thread_set_priority (os_thread_t *thread, os_thread_prio_t prio)
 Set the thread dynamic scheduling priority. More...
 
os_result_t os_thread_join (os_thread_t *thread, void **exit_ptr)
 Wait for thread termination. More...
 
void os_thread_resume (os_thread_t *thread)
 Resume the thread. More...
 
os_result_t os_thread_flags_raise (os_thread_t *thread, os_flags_mask_t mask, os_flags_mask_t *oflags)
 Raise thread event flags. More...
 
os_thread_state_t os_thread_get_state (os_thread_t *thread)
 Get the thread scheduler state. More...
 
os_thread_user_storage_t * os_thread_get_user_storage (os_thread_t *thread)
 Get the thread user storage. More...
 
os_thread_stack_tos_thread_get_stack (os_thread_t *thread)
 Get the thread context stack. More...
 

Compatibility Macros

#define os_thread_create   os_thread_construct
 
#define os_thread_destroy   os_thread_destruct
 
#define os_timer_create   os_timer_construct
 
#define os_timer_destroy   os_timer_destruct
 
#define os_mutex_create   os_mutex_construct
 
#define os_mutex_recursive_create   os_mutex_recursive_construct
 
#define os_mutex_destroy   os_mutex_destruct
 
#define os_condvar_create   os_condvar_construct
 
#define os_condvar_destroy   os_condvar_destruct
 
#define os_semaphore_create   os_semaphore_construct
 
#define os_semaphore_binary_create   os_semaphore_binary_construct
 
#define os_semaphore_counting_create   os_semaphore_counting_construct
 
#define os_semaphore_destroy   os_semaphore_destruct
 
#define os_mempool_create   os_mempool_construct
 
#define os_mempool_destroy   os_mempool_destruct
 
#define os_mqueue_create   os_mqueue_construct
 
#define os_mqueue_destroy   os_mqueue_destruct
 
#define os_evflags_create   os_evflags_construct
 
#define os_evflags_destroy   os_evflags_destruct
 

Thread Stack Functions

size_t os_thread_stack_get_default_size (void)
 Get the default stack size. More...
 
size_t os_thread_stack_set_default_size (size_t size_bytes)
 Set the default stack size. More...
 
size_t os_thread_stack_get_min_size (void)
 Get the min stack size. More...
 
size_t os_thread_stack_set_min_size (size_t size_bytes)
 Set the min stack size. More...
 
os_thread_stack_element_tos_thread_stack_get_bottom (os_thread_stack_t *stack)
 Get the stack lowest reserved address. More...
 
os_thread_stack_element_tos_thread_stack_get_top (os_thread_stack_t *stack)
 Get the top stack address. More...
 
size_t os_thread_stack_get_size (os_thread_stack_t *stack)
 Get the stack size. More...
 
size_t os_thread_stack_get_available (os_thread_stack_t *stack)
 Compute how much available stack remains. More...
 
bool os_thread_stack_check_bottom_magic (os_thread_stack_t *stack)
 Check if bottom magic word is still there. More...
 
bool os_thread_stack_check_top_magic (os_thread_stack_t *stack)
 Check if top magic word is still there. More...
 

Thread Statistics Functions

os_statistics_counter_t os_thread_stat_get_context_switches (os_thread_t *thread)
 Get the number of thread context switches. More...
 
os_statistics_duration_t os_thread_stat_get_cpu_cycles (os_thread_t *thread)
 Get the thread execution time. More...
 

Thread Children Iterator Functions

os_iterator_t os_children_threads_iter_begin (os_thread_t *thread)
 Get the beginning of the list of children threads. More...
 
os_iterator_t os_children_threads_iter_end (os_thread_t *thread)
 Get the end of the list of children threads. More...
 
os_thread_tos_children_threads_iter_get (os_iterator_t iterator)
 Get the thread from the current iterator position. More...
 
os_iterator_t os_children_threads_iter_next (os_iterator_t iterator)
 Advance the iterator to the next position. More...
 

Detailed Description

C API thread definitions.

For the complete definition, see
RTOS C++ API
Examples
void*
func (void* args )
{
printf ("%s\n", __func__);
return NULL;
}
int
os_main (int argc, char* argv[])
{
{
// Unnamed default thread; stack dynamically allocated.
os_thread_construct (&th1, NULL, func, NULL, NULL);
name = os_thread_get_name (&th1);
os_thread_join (&th1, NULL);
// The destroy() is recommended, but not mandatory when using join().
// The test checks if join() fully destroys the thread.
}
{
// Named default threads.
os_thread_construct (&th2, "th2", func, NULL, NULL);
os_thread_join (&th2, NULL);
}
{
// Custom thread with static stack and lower priority.
ath3.th_stack_size_bytes = sizeof(stack);
os_thread_construct (&th3, "th3", func, NULL, &ath3);
prio = os_thread_get_priority (&th3);
// Lower main thread priority to allow task to run.
os_thread_join (&th3, NULL);
// Restore main thread priority.
}
{
}
{
size_t n;
}
}

Macro Definition Documentation

#define os_condvar_create   os_condvar_construct

Definition at line 1638 of file os-c-api.h.

#define os_condvar_destroy   os_condvar_destruct

Definition at line 1639 of file os-c-api.h.

#define os_evflags_create   os_evflags_construct

Definition at line 2628 of file os-c-api.h.

#define os_evflags_destroy   os_evflags_destruct

Definition at line 2629 of file os-c-api.h.

#define os_mempool_create   os_mempool_construct

Definition at line 2118 of file os-c-api.h.

#define os_mempool_destroy   os_mempool_destruct

Definition at line 2119 of file os-c-api.h.

#define os_mqueue_create   os_mqueue_construct

Definition at line 2414 of file os-c-api.h.

#define os_mqueue_destroy   os_mqueue_destruct

Definition at line 2415 of file os-c-api.h.

#define os_mutex_create   os_mutex_construct

Definition at line 1445 of file os-c-api.h.

#define os_mutex_destroy   os_mutex_destruct

Definition at line 1447 of file os-c-api.h.

#define os_mutex_recursive_create   os_mutex_recursive_construct

Definition at line 1446 of file os-c-api.h.

#define os_semaphore_binary_create   os_semaphore_binary_construct

Definition at line 1912 of file os-c-api.h.

#define os_semaphore_counting_create   os_semaphore_counting_construct

Definition at line 1913 of file os-c-api.h.

#define os_semaphore_create   os_semaphore_construct

Definition at line 1911 of file os-c-api.h.

#define os_semaphore_destroy   os_semaphore_destruct

Definition at line 1914 of file os-c-api.h.

#define os_thread_create   os_thread_construct

Definition at line 627 of file os-c-api.h.

#define os_thread_destroy   os_thread_destruct

Definition at line 628 of file os-c-api.h.

#define os_timer_create   os_timer_construct

Definition at line 1144 of file os-c-api.h.

#define os_timer_destroy   os_timer_destruct

Definition at line 1145 of file os-c-api.h.

Types

Thread attributes.

Initialise this structure with os_thread_attr_init(), and then set any of the individual members directly.

See also
os::rtos::thread::attributes

Thread context.

The members of this structure are hidden and should not be accessed directly, but through associated functions.

See also
os::rtos::thread::context
typedef void* os_thread_func_args_t

Type of thread function arguments.

Useful to cast other similar types to silence possible compiler warnings.

See also
os::rtos::thread::func_args_t

Definition at line 343 of file os-c-decls.h.

typedef void*(* os_thread_func_t) (os_thread_func_args_t args)

Type of thread function.

Useful to cast other similar types to silence possible compiler warnings.

See also
os::rtos::thread::func_t

Definition at line 355 of file os-c-decls.h.

typedef uint8_t os_thread_prio_t

Type of variables holding thread priorities.

A numeric type used to hold thread priorities, affecting the thread behaviour, like scheduling and thread wakeup due to events; usually an unsigned 8-bits type.

Higher values represent higher priorities.

See also
os::rtos::thread::priority_t

Definition at line 376 of file os-c-decls.h.

typedef os_port_thread_stack_allocation_element_t os_thread_stack_allocation_element_t

Type of variables holding aligned stack elements.

A numeric type intended to be used for stack allocations.

See also
os::rtos::stack::allocation_element_t

Definition at line 399 of file os-c-decls.h.

typedef os_port_thread_stack_element_t os_thread_stack_element_t

Type of variables holding stack words.

A numeric type intended to store a stack word as stored by push instructions.

See also
os::rtos::stack::element_t

Definition at line 389 of file os-c-decls.h.

Thread stack.

The members of this structure are hidden and should not be accessed directly, but through associated functions.

See also
os::rtos::thread::stack
typedef uint8_t os_thread_state_t

Type of variables holding thread states.

See also
os::rtos::thread::state_t

Definition at line 362 of file os-c-decls.h.

Thread statistics.

The members of this structure are hidden and should not be accessed directly, but through associated functions.

See also
os::rtos::thread::statistics
typedef struct os_thread_s os_thread_t

Thread object storage.

This C structure has the same size as the C++ os::rtos::thread object and must be initialised with os_thread_create().

Later on a pointer to it can be used both in C and C++ to refer to the thread object instance.

The members of this structure are hidden and should not be used directly, but only through specific functions.

See also
os::rtos::thread

Enumeration Type Documentation

anonymous enum

Thread priorities; intermediate values are also possible.

See also
os::rtos::thread::state
Enumerator
os_thread_priority_none 
os_thread_priority_idle 
os_thread_priority_lowest 
os_thread_priority_low 
os_thread_priority_below_normal 
os_thread_priority_normal 
os_thread_priority_above_normal 
os_thread_priority_high 
os_thread_priority_realtime 
os_thread_priority_highest 
os_thread_priority_isr 
os_thread_priority_error 

Definition at line 285 of file os-c-decls.h.

anonymous enum

An enumeration with all possible thread states.

See also
os::rtos::thread::state
Enumerator
os_thread_state_undefined 

Used to catch uninitialised threads.

os_thread_state_ready 

Present in the READY list and competing for CPU.

os_thread_state_running 

Has the CPU and runs.

os_thread_state_suspended 

Not present in the READY list, waiting for an event.

os_thread_state_terminated 

No longer usable, but resources not yet released.

os_thread_state_destroyed 

Terminated and resources (like stack) released.

Definition at line 307 of file os-c-decls.h.

Function Documentation

os_iterator_t os_children_threads_iter_begin ( os_thread_t thread)

Get the beginning of the list of children threads.

Parameters
[in]threadPointer to thread object or NULL for the list of top threads.
Returns
An iterator positioned at the list begin.

Return the position of the first element in the list of children threads of the given thread. If NULL, the position first element in the list of top threads is returned.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 1070 of file os-c-wrapper.cpp.

os_iterator_t os_children_threads_iter_end ( os_thread_t thread)

Get the end of the list of children threads.

Parameters
[in]threadPointer to thread object or NULL for the list of top threads.
Returns
An iterator positioned at the list end.

Return the position after the last element in the list of children threads of the given thread. If NULL, the position after the last element in the list of top threads is returned.

The iteration loop must be terminated when the current iterator is equal to this position, before entering the loop body.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 1088 of file os-c-wrapper.cpp.

os_thread_t* os_children_threads_iter_get ( os_iterator_t  iterator)

Get the thread from the current iterator position.

Parameters
[in]iteratorAn active iterator.
Returns
The pointer to the thread object instance.

Calling it when the iterator is equal to the end position leads to unpredictable results.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 1102 of file os-c-wrapper.cpp.

os_iterator_t os_children_threads_iter_next ( os_iterator_t  iterator)

Advance the iterator to the next position.

Parameters
[in]iteratorAn active iterator.
Returns
An iterator positioned at the next list element.

Calling it when the iterator is equal to the end position leads to unpredictable results.

Warning
Cannot be invoked from Interrupt Service Routines.

Definition at line 1118 of file os-c-wrapper.cpp.

os_thread_t* os_this_thread ( void  )

Get the current running thread.

Parameters
None.
Returns
Pointer to the current running thread object instance.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::this_thread::thread()

Definition at line 510 of file os-c-wrapper.cpp.

void os_this_thread_exit ( void *  exit_ptr)

Terminate the current running thread.

Parameters
[in]exit_ptrPointer to object to return. (Optional, may be NULL).
Returns
Nothing.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::this_thread::exit()

Definition at line 538 of file os-c-wrapper.cpp.

os_result_t os_this_thread_flags_clear ( os_flags_mask_t  mask,
os_flags_mask_t oflags 
)

Clear thread event flags.

Parameters
[in]maskThe OR-ed flags to clear.
[out]oflagsOptional pointer where to store the previous flags; may be NULL.
Return values
os_okThe flags were cleared.
EPERMCannot be invoked from an Interrupt Service Routines.
EINVALThe mask is zero.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::this_thread::flags_clear()

Definition at line 599 of file os-c-wrapper.cpp.

os_flags_mask_t os_this_thread_flags_get ( os_flags_mask_t  mask,
os_flags_mode_t  mode 
)

Get/clear thread event flags.

Parameters
[in]maskThe OR-ed flags to get/clear; may be zero.
[in]modeMode bits to select if the flags should be cleared (the other bits are ignored).
Return values
flagsThe selected bits from the current thread event flags mask.
sig::allCannot be invoked from an Interrupt Service Routines.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::this_thread::flags_get()

Definition at line 613 of file os-c-wrapper.cpp.

os_result_t os_this_thread_flags_timed_wait ( os_flags_mask_t  mask,
os_clock_duration_t  timeout,
os_flags_mask_t oflags,
os_flags_mode_t  mode 
)

Timed wait for thread event flags.

Parameters
[in]maskThe expected flags (OR-ed bit-mask); may be zero.
[out]oflagsPointer where to store the current flags; may be NULL.
[in]modeMode bits to select if either all or any flags are expected, and if the flags should be cleared.
[in]timeoutTimeout to wait, in clock units (ticks or seconds).
Return values
os_okAll expected flags are raised.
EPERMCannot be invoked from an Interrupt Service Routines.
ETIMEDOUTThe expected condition did not occur during the entire timeout duration.
EINVALThe mask is outside of the permitted range.
EINTRThe operation was interrupted.
ENOTRECOVERABLEWait failed.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::this_thread::flags_timed_wait()

Definition at line 582 of file os-c-wrapper.cpp.

os_result_t os_this_thread_flags_try_wait ( os_flags_mask_t  mask,
os_flags_mask_t oflags,
os_flags_mode_t  mode 
)

Try to wait for thread event flags.

Parameters
[in]maskThe expected flags (OR-ed bit-mask); may be zero.
[out]oflagsPointer where to store the current flags; may be NULL.
[in]modeMode bits to select if either all or any flags are expected, and if the flags should be cleared.
Return values
os_okAll expected flags are raised.
EINVALThe mask is outside of the permitted range.
EWOULDBLOCKThe expected condition did not occur.
ENOTRECOVERABLEWait failed.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::this_thread::flags_try_wait()

Definition at line 567 of file os-c-wrapper.cpp.

os_result_t os_this_thread_flags_wait ( os_flags_mask_t  mask,
os_flags_mask_t oflags,
os_flags_mode_t  mode 
)

Wait for thread event flags.

Parameters
[in]maskThe expected flags (OR-ed bit-mask); may be zero.
[out]oflagsPointer where to store the current flags; may be NULL.
[in]modeMode bits to select if either all or any flags are expected, and if the flags should be cleared.
Return values
os_okAll expected flags are raised.
EPERMCannot be invoked from an Interrupt Service Routines.
EINVALThe mask is outside of the permitted range.
EINTRThe operation was interrupted.
ENOTRECOVERABLEWait failed.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::this_thread::flags_wait()

Definition at line 552 of file os-c-wrapper.cpp.

void os_this_thread_suspend ( void  )

Suspend the current running thread to wait for an event.

Parameters
None.
Returns
Nothing.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::this_thread::suspend()

Definition at line 524 of file os-c-wrapper.cpp.

void os_thread_attr_init ( os_thread_attr_t attr)

Initialise the thread attributes.

Parameters
[in]attrPointer to thread attributes object instance.
Returns
Nothing.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::attributes

Definition at line 629 of file os-c-wrapper.cpp.

void os_thread_construct ( os_thread_t thread,
const char *  name,
os_thread_func_t  func,
const os_thread_func_args_t  args,
const os_thread_attr_t attr 
)

Construct a statically allocated thread object instance.

Parameters
[in]threadPointer to thread object instance storage.
[in]namePointer to name (may be NULL).
[in]funcPointer to thread function.
[in]argsPointer to thread function arguments (may be NULL).
[in]attrPointer to attributes (may be NULL)
Returns
Nothing.
Note
Must be paired with os_thread_destruct().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread

Definition at line 646 of file os-c-wrapper.cpp.

void os_thread_delete ( os_thread_t thread)

Destruct the thread object instance and deallocate it.

Parameters
[in]threadPointer to dynamically allocated thread object instance.
Returns
Nothing.

Destruct the thread and deallocate the dynamically allocated space using the RTOS system allocator.

Note
Equivalent of C++ delete ptr_th.
Must be paired with os_thread_new().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread

Definition at line 719 of file os-c-wrapper.cpp.

void os_thread_destruct ( os_thread_t thread)

Destruct the statically allocated thread object instance.

Parameters
[in]threadPointer to thread object instance.
Returns
Nothing.
Note
Must be paired with os_thread_construct().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread

Definition at line 671 of file os-c-wrapper.cpp.

os_result_t os_thread_flags_raise ( os_thread_t thread,
os_flags_mask_t  mask,
os_flags_mask_t oflags 
)

Raise thread event flags.

Parameters
[in]threadPointer to thread object instance.
[in]maskThe OR-ed flags to raise.
[out]oflagsOptional pointer where to store the previous flags; may be NULL.
Return values
os_okThe flags were raised.
EINVALThe mask is zero.
EPERMCannot be invoked from an Interrupt Service Routines.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::flags_raise()

Definition at line 810 of file os-c-wrapper.cpp.

const char* os_thread_get_name ( os_thread_t thread)

Get the thread name.

Parameters
[in]threadPointer to thread object instance.
Returns
Null terminated string.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::name()

Definition at line 734 of file os-c-wrapper.cpp.

os_thread_prio_t os_thread_get_priority ( os_thread_t thread)

Get the thread current scheduling priority.

Parameters
[in]threadPointer to thread object instance.
Returns
The thread priority.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::priority()

Definition at line 749 of file os-c-wrapper.cpp.

os_thread_stack_t* os_thread_get_stack ( os_thread_t thread)

Get the thread context stack.

Parameters
[in]threadPointer to thread object instance.
Returns
A pointer to the context stack object instance.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::stack()

Definition at line 865 of file os-c-wrapper.cpp.

os_thread_state_t os_thread_get_state ( os_thread_t thread)

Get the thread scheduler state.

Parameters
[in]threadPointer to thread object instance.
Returns
Thread scheduler state.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::state()

Definition at line 827 of file os-c-wrapper.cpp.

os_thread_user_storage_t* os_thread_get_user_storage ( os_thread_t thread)

Get the thread user storage.

Parameters
[in]threadPointer to thread object instance.
Returns
The address of the thread user storage.
Note
Available only when OS_INCLUDE_RTOS_CUSTOM_THREAD_USER_STORAGE is defined.
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::user_storage()

Definition at line 848 of file os-c-wrapper.cpp.

os_result_t os_thread_join ( os_thread_t thread,
void **  exit_ptr 
)

Wait for thread termination.

Parameters
[in]threadPointer to terminating thread object instance.
[in]exit_ptrPointer to thread exit value. (may be NULL).
Return values
os_okThe thread was terminated.
EPERMCannot be invoked from an Interrupt Service Routines.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::join()

Definition at line 780 of file os-c-wrapper.cpp.

os_thread_t* os_thread_new ( const char *  name,
os_thread_func_t  func,
const os_thread_func_args_t  args,
const os_thread_attr_t attr 
)

Allocate a thread object instance and construct it.

Parameters
[in]namePointer to name (may be NULL).
[in]funcPointer to thread function.
[in]argsPointer to thread function arguments (may be NULL).
[in]attrPointer to attributes (may be NULL)
Returns
Pointer to new thread object instance.

Dynamically allocate the thread object instance using the RTOS system allocator and construct it.

Note
Equivalent of C++ new thread(...).
Must be paired with os_thread_delete().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread

Definition at line 692 of file os-c-wrapper.cpp.

void os_thread_resume ( os_thread_t thread)

Resume the thread.

Parameters
[in]threadPointer to thread object instance.
Returns
Nothing.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::resume()

Definition at line 795 of file os-c-wrapper.cpp.

os_result_t os_thread_set_priority ( os_thread_t thread,
os_thread_prio_t  prio 
)

Set the thread dynamic scheduling priority.

Parameters
[in]threadPointer to thread object instance.
[in]prioNew priority.
Return values
os_okThe priority was set.
EPERMCannot be invoked from an Interrupt Service Routines.
EINVALThe value of prio is invalid for the scheduling policy of the specified thread.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::priority(priority_t)

Definition at line 764 of file os-c-wrapper.cpp.

bool os_thread_stack_check_bottom_magic ( os_thread_stack_t stack)

Check if bottom magic word is still there.

Parameters
[in]stackPointer to stack object instance.
Return values
trueThe magic word is still there.
falseThe magic word was overwritten.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::stack::check_bottom_magic()

Definition at line 998 of file os-c-wrapper.cpp.

bool os_thread_stack_check_top_magic ( os_thread_stack_t stack)

Check if top magic word is still there.

Parameters
[in]stackPointer to stack object instance.
Return values
trueThe magic word is still there.
falseThe magic word was overwritten.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::stack::check_top_magic()

Definition at line 1013 of file os-c-wrapper.cpp.

size_t os_thread_stack_get_available ( os_thread_stack_t stack)

Compute how much available stack remains.

Parameters
[in]stackPointer to stack object instance.
Returns
Number of available bytes.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::stack::available()

Definition at line 983 of file os-c-wrapper.cpp.

os_thread_stack_element_t* os_thread_stack_get_bottom ( os_thread_stack_t stack)

Get the stack lowest reserved address.

Parameters
[in]stackPointer to stack object instance.
Returns
The address of the stack reserved area.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::stack::bottom()

Definition at line 938 of file os-c-wrapper.cpp.

size_t os_thread_stack_get_default_size ( void  )

Get the default stack size.

Parameters
None.
Returns
The default stack size in bytes.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::stack::default_size()

Definition at line 882 of file os-c-wrapper.cpp.

size_t os_thread_stack_get_min_size ( void  )

Get the min stack size.

Parameters
None.
Returns
The min stack size in bytes.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::stack::min_size()

Definition at line 910 of file os-c-wrapper.cpp.

size_t os_thread_stack_get_size ( os_thread_stack_t stack)

Get the stack size.

Parameters
[in]stackPointer to stack object instance.
Returns
The stack size in bytes.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::stack::size()

Definition at line 968 of file os-c-wrapper.cpp.

os_thread_stack_element_t* os_thread_stack_get_top ( os_thread_stack_t stack)

Get the top stack address.

Parameters
[in]stackPointer to stack object instance.
Returns
The address after the last stack element.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::stack::top()

Definition at line 953 of file os-c-wrapper.cpp.

size_t os_thread_stack_set_default_size ( size_t  size_bytes)

Set the default stack size.

Parameters
[in]size_bytesDefault stack size in bytes.
Returns
The previous value of the default stack size in bytes.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::stack::default_size(std::size_t)

Definition at line 896 of file os-c-wrapper.cpp.

size_t os_thread_stack_set_min_size ( size_t  size_bytes)

Set the min stack size.

Parameters
[in]size_bytesMinimum stack size in bytes.
Returns
The previous value of the min stack size in bytes.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::stack::min_size(std::size_t)

Definition at line 924 of file os-c-wrapper.cpp.

os_statistics_counter_t os_thread_stat_get_context_switches ( os_thread_t thread)

Get the number of thread context switches.

Returns
A long integer with the number of times the thread was scheduled for execution.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::statistics::context_switches()

Definition at line 1032 of file os-c-wrapper.cpp.

os_statistics_duration_t os_thread_stat_get_cpu_cycles ( os_thread_t thread)

Get the thread execution time.

Returns
A long integer with the accumulated number of CPU cycles, possibly divided by some prescaller.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::thread::statistics::cpu_cycles()

Definition at line 1051 of file os-c-wrapper.cpp.