µOS++ IIIe Reference  v6.3.15
“Perfekt ist nicht gut genug”
The third edition of µOS++, a POSIX inspired open source system, written in C++.

C++ API threads definitions. More...

Namespaces

 os::rtos::this_thread
 A convenience namespace to access the current running thread.
 

Classes

class  os::rtos::thread::attributes
 Thread attributes. More...
 
class  os::rtos::thread::context
 Thread context. More...
 
struct  os::rtos::thread::priority
 Thread priorities. More...
 
class  os::rtos::thread::stack
 Thread stack. More...
 
struct  os::rtos::thread::state
 Thread states. More...
 
class  os::rtos::thread::statistics
 Thread statistics. More...
 
class  os::rtos::thread
 POSIX compliant thread, using the default RTOS allocator. More...
 
class  os::rtos::thread_allocated< Allocator >
 Template of a POSIX compliant thread with allocator. More...
 
class  os::rtos::thread_inclusive< N >
 Template of a POSIX compliant thread with local stack. More...
 

Types

using os::rtos::thread::priority_t = uint8_t
 Type of variables holding thread priorities. More...
 

Enumerations

enum  : priority_t {
  os::rtos::thread::priority::none = 0,
  os::rtos::thread::priority::idle = (1 << range),
  os::rtos::thread::priority::lowest = (2 << range),
  os::rtos::thread::priority::low = (2 << range),
  os::rtos::thread::priority::below_normal = (4 << range),
  os::rtos::thread::priority::normal = (6 << range),
  os::rtos::thread::priority::above_normal = (8 << range),
  os::rtos::thread::priority::high = (10 << range),
  os::rtos::thread::priority::realtime = (12 << range),
  os::rtos::thread::priority::highest = (((13 + 1) << range) - 1),
  os::rtos::thread::priority::isr = (((14 + 1) << range) - 1),
  os::rtos::thread::priority::error = (((15 + 1) << range) - 1)
}
 Thread priorities; intermediate values are also possible. More...
 

Detailed Description

C++ API threads definitions.

Examples
void*
func (void* args )
{
printf ("%s\n", __func__);
return nullptr;
}
int
os_main (int argc, char* argv[])
{
{
// Regular threads.
thread th1
{ func, nullptr };
thread th2
{ "th2", func, nullptr };
th1.join ();
th2.join ();
}
using my_thread = thread_allocated<memory::new_delete_allocator<thread::stack::allocation_element_t>>;
// Allocated threads.
{
my_thread ath1
{ func, nullptr };
my_thread ath2
{ "ath2", func, nullptr };
ath1.join ();
ath2.join ();
}
{
#pragma GCC diagnostic push
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif
// Statically allocated threads.
static thread_inclusive<> sth1
{ func, nullptr };
static thread_inclusive<> sth2
{ "sth2", func, nullptr };
#pragma GCC diagnostic pop
sth1.join ();
sth2.join ();
}
// --------------------------------------------------------------------------
{
std::size_t n;
n = thread::stack::default_size ();
thread::stack::default_size (n);
n = thread::stack::min_size ();
thread::stack::min_size (n);
class thread::stack& stack = this_thread::thread ().stack ();
stack.bottom ();
stack.top ();
stack.check_bottom_magic ();
stack.check_top_magic ();
}
// --------------------------------------------------------------------------
{
}
}

Types

◆ priority_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.

Definition at line 252 of file os-thread.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : priority_t

Thread priorities; intermediate values are also possible.

Enumerator
none 

Undefined, thread not initialised.

idle 

System reserved for the IDLE thread.

lowest 

Lowest available for user code.

low 
below_normal 
normal 

Default priority.

above_normal 
high 
realtime 
highest 

Highest available for user code.

isr 

System reserved for the ISR deferred thread.

error 

Error.

Definition at line 284 of file os-thread.h.