µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches

C++ API threads definitions. More...

Namespaces

namespace  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...
 

Typedefs

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

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.top ();
}
// --------------------------------------------------------------------------
{
this_thread::flags_clear (flags::all);
this_thread::thread ().flags_raise (0x3);
this_thread::flags_wait (0x3, nullptr, flags::mode::all);
this_thread::thread ().flags_raise (0x3);
this_thread::flags_try_wait (0x3);
this_thread::thread ().flags_raise (0x3);
this_thread::flags_timed_wait (0x3, 10);
}
}
bool check_top_magic(void)
Check if top magic word is still there.
Definition os-thread.h:2187
stack()
Construct a thread stack object instance.
Definition os-thread.h:2121
stack::element_t * bottom(void)
Get the stack lowest reserved address.
Definition os-thread.h:2151
bool check_bottom_magic(void)
Check if bottom magic word is still there.
Definition os-thread.h:2178
stack::element_t * top(void)
Get the top stack address.
Definition os-thread.h:2160
Standard thread.
void join(void)
Definition thread-cpp.h:81
int os_main(int argc, char *argv[])
Application entry point, running on the main thread context.
class thread::stack * stack(void)
Get the interrupts stack.
Definition os-core.cpp:571

Typedef Documentation

◆ 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 271 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 303 of file os-thread.h.