µ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++.
Core & scheduler

C API core & scheduler definitions. More...

Macros

#define os_flags_all   0xFFFFFFFF
 
#define os_flags_any   0
 Special mask to represent any flag. More...
 

Types

typedef os_port_clock_duration_t os_clock_duration_t
 Type of variables holding clock durations. More...
 
typedef os_port_clock_offset_t os_clock_offset_t
 Type of variables holding clock offsets. More...
 
typedef os_port_clock_timestamp_t os_clock_timestamp_t
 Type of variables holding clock time stamps. More...
 
typedef uint32_t os_flags_mask_t
 Type of variables holding flags masks. More...
 
typedef uint32_t os_flags_mode_t
 Type of variables holding flags modes. More...
 
typedef os_port_irq_state_t os_irq_state_t
 Type of variables holding interrupts priority values. More...
 
typedef void * os_iterator_t
 Generic iterator, implemented as a pointer. More...
 
typedef uint32_t os_result_t
 Type of values returned by RTOS functions. More...
 
typedef os_port_scheduler_state_t os_sched_state_t
 Type of variables holding scheduler state codes. More...
 
typedef uint64_t os_statistics_counter_t
 Type of variables holding context switches counters. More...
 
typedef uint64_t os_statistics_duration_t
 Type of variables holding durations in CPU cycles. More...
 

Enumerations

enum  {
  os_flags_mode_all = 1,
  os_flags_mode_any = 2,
  os_flags_mode_clear = 4
}
 Bits used to specify the flags modes. More...
 

Return Codes

enum  { os_ok = 0 }
 Return codes, in addition to POSIX codes. More...
 

Scheduler Functions

os_result_t os_sched_initialize (void)
 Initialise the RTOS scheduler. More...
 
void os_sched_start (void)
 Start the RTOS scheduler. More...
 
bool os_sched_is_started (void)
 Check if the scheduler was started. More...
 
os_sched_state_t os_sched_lock (void)
 Lock the scheduler. More...
 
os_sched_state_t os_sched_unlock (void)
 Unlock the scheduler. More...
 
os_sched_state_t os_sched_set_locked (os_sched_state_t state)
 Lock/unlock the scheduler. More...
 
bool os_sched_is_locked (void)
 Check if the scheduler is locked. More...
 
bool os_sched_is_preemptive (void)
 Check if the scheduler is in preemptive mode. More...
 
bool os_sched_set_preemptive (bool state)
 Set the scheduler preemptive mode. More...
 

Scheduler Statistics Functions

os_statistics_counter_t os_sched_stat_get_context_switches (void)
 Get the total number of context switches. More...
 
os_statistics_duration_t os_sched_stat_get_cpu_cycles (void)
 Get the total duration of all threads. More...
 

Interrupts Functions

bool os_irq_in_handler_mode (void)
 Check if the CPU is in handler mode. More...
 
os_irq_state_t os_irq_critical_enter (void)
 Enter an interrupts critical section. More...
 
void os_irq_critical_exit (os_irq_state_t state)
 Exit the interrupts critical section. More...
 
os_irq_state_t os_irq_uncritical_enter (void)
 Enter an interrupts uncritical section. More...
 
void os_irq_uncritical_exit (os_irq_state_t state)
 Exit the interrupts uncritical section. More...
 
os_thread_stack_tos_irq_get_stack (void)
 Get the interrupts stack. More...
 

Detailed Description

C API core & scheduler definitions.

For the complete definition, see
RTOS C++ API
Examples
int
os_main (int argc, char* argv[])
{
{
assert(flag);
// ...
{
// Scheduler critical section
st = os_sched_lock (true);
// ...
flag = os_sched_is_locked ();
assert(flag);
// ...
}
// ...
flag = os_sched_is_locked ();
assert(!flag);
}
{
// Interrupts critical section
// ...
{
// Interrupts uncritical section
// ...
}
// ...
}
}

Macro Definition Documentation

#define os_flags_all   0xFFFFFFFF

Special mask to represent all flags.

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

#define os_flags_any   0

Special mask to represent any flag.

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

Types

typedef os_port_clock_duration_t os_clock_duration_t

Type of variables holding clock durations.

A numeric type intended to store a clock duration, either in ticks cycles, or seconds.

See also
os::rtos::clock::duration_t

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

typedef os_port_clock_offset_t os_clock_offset_t

Type of variables holding clock offsets.

A numeric type intended to store a clock offset (difference to epoch), either in ticks or in seconds.

See also
os::rtos::clock::duration_t

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

typedef os_port_clock_timestamp_t os_clock_timestamp_t

Type of variables holding clock time stamps.

A numeric type intended to store a clock timestamp, either in ticks cycles or seconds.

See also
os::rtos::clock::timestamp_t

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

typedef uint32_t os_flags_mask_t

Type of variables holding flags masks.

An unsigned type large enough to store all the flags, usually 32-bits wide.

Both thread event flags and generic event flags use this definition.

See also
os::rtos::flags::mask_t

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

typedef uint32_t os_flags_mode_t

Type of variables holding flags modes.

An unsigned type used to hold the mode bits passed to functions returning flags.

Both thread event flags and generic event flags use this definition.

See also
os::rtos::flags::mode_t

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

typedef os_port_irq_state_t os_irq_state_t

Type of variables holding interrupts priority values.

Usually an integer large enough to hold the CPU register where the interrupt priorities are stored.

Used to temporarily store the CPU register during critical sections.

See also
os::rtos::interrupts::state_t

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

typedef void* os_iterator_t

Generic iterator, implemented as a pointer.

To simplify things, the C implementation of iterators includes a single pointer to a C++ object instance. Internally, the functions used to iterate must cast this pointer properly, but this should be transparent for the user.

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

typedef uint32_t os_result_t

Type of values returned by RTOS functions.

For error processing reasons, most CMSIS++ RTOS functions return a numeric result, which, according to POSIX, when the call was successful, must be 0 (os_ok) or an error code defined in <errno.h> otherwise.

See also
os::rtos::result_t

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

typedef os_port_scheduler_state_t os_sched_state_t

Type of variables holding scheduler state codes.

Usually a boolean telling if the scheduler is locked or not, but for recursive locks it might also be a numeric counter.

See also
os::rtos::scheduler::state_t

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

typedef uint64_t os_statistics_counter_t

Type of variables holding context switches counters.

See also
os::rtos::statistics::counter_t

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

typedef uint64_t os_statistics_duration_t

Type of variables holding durations in CPU cycles.

See also
os::rtos::statistics::duration_t

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

Enumeration Type Documentation

anonymous enum

Return codes, in addition to POSIX codes.

Enumerator
os_ok 

Function completed; no error or event occurred.

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

anonymous enum

Bits used to specify the flags modes.

See also
os::rtos::flags::mode
Enumerator
os_flags_mode_all 
os_flags_mode_any 
os_flags_mode_clear 

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

Function Documentation

os_irq_state_t os_irq_critical_enter ( void  )

Enter an interrupts critical section.

Parameters
None.
Returns
The previous value of the interrupts priority register.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::interrupts::critical_section::enter()

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

void os_irq_critical_exit ( os_irq_state_t  state)

Exit the interrupts critical section.

Parameters
stateThe value to restore the interrupts priority register.
Returns
Nothing.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::interrupts::critical_section::exit()

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

os_thread_stack_t* os_irq_get_stack ( void  )

Get the interrupts stack.

Parameters
None.
Returns
A pointer to the interrupts stack object instance.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::interrupts::stack()

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

bool os_irq_in_handler_mode ( void  )

Check if the CPU is in handler mode.

Parameters
None.
Return values
trueExecution is in an exception handler context.
falseExecution is in a thread context.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::interrupts::in_handler_mode()

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

os_irq_state_t os_irq_uncritical_enter ( void  )

Enter an interrupts uncritical section.

Parameters
None.
Returns
The previous value of the interrupts priority register.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::interrupts::uncritical_section::enter()

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

void os_irq_uncritical_exit ( os_irq_state_t  state)

Exit the interrupts uncritical section.

Parameters
stateThe value to restore the interrupts priority register.
Returns
Nothing.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::interrupts::uncritical_section::exit()

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

os_result_t os_sched_initialize ( void  )

Initialise the RTOS scheduler.

Parameters
None.
Return values
os_okThe scheduler was initialised.
EPERMCannot be invoked from an Interrupt Service Routines.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::scheduler::initialize()

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

bool os_sched_is_locked ( void  )

Check if the scheduler is locked.

Parameters
None.
Return values
trueThe scheduler is locked.
falseThe scheduler is switching threads (not locked).
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::scheduler::locked()

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

bool os_sched_is_preemptive ( void  )

Check if the scheduler is in preemptive mode.

Parameters
None.
Return values
trueThe scheduler is in preemptive mode.
falseThe scheduler is not in preemptive mode.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::scheduler::preemptive()

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

bool os_sched_is_started ( void  )

Check if the scheduler was started.

Parameters
None.
Return values
trueThe scheduler was started.
falseThe scheduler was not started.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::scheduler::started()

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

os_sched_state_t os_sched_lock ( void  )

Lock the scheduler.

Parameters
None.
Returns
The previous state of the scheduler lock.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::scheduler::lock()

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

os_sched_state_t os_sched_set_locked ( os_sched_state_t  state)

Lock/unlock the scheduler.

Parameters
[in]stateThe new state of the scheduler lock.
Returns
The previous state of the scheduler lock.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::scheduler::lock()

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

bool os_sched_set_preemptive ( bool  state)

Set the scheduler preemptive mode.

Parameters
[in]stateThe new state of the scheduler preemptive mode.
Returns
The previous state of the preemptive mode.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::scheduler::preemptive(bool)

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

void os_sched_start ( void  )

Start the RTOS scheduler.

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

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

os_statistics_counter_t os_sched_stat_get_context_switches ( void  )

Get the total number of context switches.

Returns
Integer with the total number of context switches since scheduler start.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::scheduler::statistics::context_switches()

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

os_statistics_duration_t os_sched_stat_get_cpu_cycles ( void  )

Get the total duration of all threads.

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

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

os_sched_state_t os_sched_unlock ( void  )

Unlock the scheduler.

Parameters
None.
Returns
The previous state of the scheduler lock.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::scheduler::unlock()

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