µ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 event flags definitions. More...

Classes

struct  os_evflags_attr_s
 Event flags attributes. More...
 
struct  os_evflags_s
 Event flags object storage. More...
 

Typedefs

typedef struct os_evflags_attr_s os_evflags_attr_t
 Event flags attributes.
 
typedef struct os_evflags_s os_evflags_t
 Event flags object storage.
 

Event Flags Attributes Functions

void os_evflags_attr_init (os_evflags_attr_t *attr)
 Initialise the event flags attributes.
 

Event Flags Creation Functions

void os_evflags_construct (os_evflags_t *evflags, const char *name, const os_evflags_attr_t *attr)
 Construct a statically allocated event flags object instance.
 
void os_evflags_destruct (os_evflags_t *evflags)
 Destruct the statically allocated event flags object instance.
 
os_evflags_tos_evflags_new (const char *name, const os_evflags_attr_t *attr)
 Allocate an event flags object instance and construct it.
 
void os_evflags_delete (os_evflags_t *evflags)
 Destruct the event flags object instance and deallocate it.
 

Event Flags Functions

const char * os_evflags_get_name (os_evflags_t *evflags)
 Get the event flags name.
 
os_result_t os_evflags_wait (os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Wait for event flags.
 
os_result_t os_evflags_try_wait (os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Try to wait for event flags.
 
os_result_t os_evflags_timed_wait (os_evflags_t *evflags, os_flags_mask_t mask, os_clock_duration_t timeout, os_flags_mask_t *oflags, os_flags_mode_t mode)
 Timed wait for event flags.
 
os_result_t os_evflags_raise (os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags)
 Raise event flags.
 
os_result_t os_evflags_clear (os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags)
 Clear event flags.
 
os_flags_mask_t os_evflags_get (os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mode_t mode)
 Get (and possibly clear) event flags.
 
bool os_evflags_are_waiting (os_evflags_t *evflags)
 Check if there are threads waiting.
 

Compatibility Macros

#define os_evflags_create   os_evflags_construct
 
#define os_evflags_destroy   os_evflags_destruct
 

Detailed Description

For the complete definition, see
RTOS C++ API
Examples
int
os_main (int argc, char* argv[])
{
{
os_evflags_construct (&ev1, "ev1", NULL);
// Clear all flags.
os_evflags_clear (&ev1, 0x0, NULL);
os_evflags_raise (&ev1, 0x1, NULL);
os_evflags_wait (&ev1, 0x1, NULL,
os_evflags_raise (&ev1, 0x1, NULL);
os_evflags_try_wait (&ev1, 0x1, NULL,
os_evflags_raise (&ev1, 0x1, NULL);
os_evflags_timed_wait (&ev1, 0x1, 1, NULL,
name = os_evflags_get_name (&ev1);
}
{
// Initialise custom event flags with a specific clock.
os_evflags_construct (&ev2, "ev2", &aev2);
}
}
os_clock_t * os_clock_get_rtclock(void)
Get rtclock (the real-time clock).
@ os_flags_mode_clear
Definition os-c-decls.h:131
@ os_flags_mode_all
Definition os-c-decls.h:129
os_result_t os_evflags_try_wait(os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
Try to wait for event flags.
os_result_t os_evflags_clear(os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags)
Clear event flags.
os_result_t os_evflags_wait(os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags, os_flags_mode_t mode)
Wait for event flags.
const char * os_evflags_get_name(os_evflags_t *evflags)
Get the event flags name.
os_result_t os_evflags_raise(os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mask_t *oflags)
Raise event flags.
void os_evflags_attr_init(os_evflags_attr_t *attr)
Initialise the event flags attributes.
os_flags_mask_t os_evflags_get(os_evflags_t *evflags, os_flags_mask_t mask, os_flags_mode_t mode)
Get (and possibly clear) event flags.
os_result_t os_evflags_timed_wait(os_evflags_t *evflags, os_flags_mask_t mask, os_clock_duration_t timeout, os_flags_mask_t *oflags, os_flags_mode_t mode)
Timed wait for event flags.
void os_evflags_destruct(os_evflags_t *evflags)
Destruct the statically allocated event flags object instance.
void os_evflags_construct(os_evflags_t *evflags, const char *name, const os_evflags_attr_t *attr)
Construct a statically allocated event flags object instance.
int os_main(int argc, char *argv[])
Application entry point, running on the main thread context.
Event flags attributes.
void * clock
Pointer to clock object instance.
Event flags object storage.

Macro Definition Documentation

◆ os_evflags_create

#define os_evflags_create   os_evflags_construct

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

◆ os_evflags_destroy

#define os_evflags_destroy   os_evflags_destruct

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

Typedef Documentation

◆ os_evflags_attr_t

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

See also
os::rtos::event_flags::attributes

◆ os_evflags_t

typedef struct os_evflags_s os_evflags_t

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

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

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

See also
os::rtos::event_flags

Function Documentation

◆ os_evflags_are_waiting()

bool os_evflags_are_waiting ( os_evflags_t evflags)
Parameters
[in]evflagsPointer to event flags object instance.
Return values
trueThere are threads waiting.
falseThere are no threads waiting.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::event_flags::raise()

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

3195{
3196 assert (evflags != nullptr);
3197 return (reinterpret_cast<event_flags&> (*evflags)).waiting ();
3198}
Synchronised event flags.
Definition os-evflags.h:57

◆ os_evflags_attr_init()

void os_evflags_attr_init ( os_evflags_attr_t attr)
Parameters
[in]attrPointer to event flags attributes object instance.
Returns
Nothing.
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::event_flags::attributes

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

2999{
3000 assert (attr != nullptr);
3001 new (attr) event_flags::attributes ();
3002}
Event flags attributes.
Definition os-evflags.h:67

◆ os_evflags_clear()

os_result_t os_evflags_clear ( os_evflags_t evflags,
os_flags_mask_t  mask,
os_flags_mask_t oflags 
)
Parameters
[in]evflagsPointer to event flags object instance.
[in]maskThe OR-ed flags to clear. Zero means 'all'.
[out]oflagsOptional pointer where to store the previous value of the flags; may be NULL.
Return values
os_okThe flags were cleared.
EINVALThe mask is zero.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::event_flags::clear()

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

3166{
3167 assert (evflags != nullptr);
3168 return (os_result_t)(reinterpret_cast<event_flags&> (*evflags))
3169 .clear (mask, oflags);
3170}
uint32_t os_result_t
Type of values returned by RTOS functions.
Definition os-c-decls.h:94

◆ os_evflags_construct()

void os_evflags_construct ( os_evflags_t evflags,
const char *  name,
const os_evflags_attr_t attr 
)
Parameters
[in]evflagsPointer to event flags object instance storage.
[in]namePointer to name (may be NULL).
[in]attrPointer to attributes (may be NULL).
Returns
Nothing.
Note
Must be paired with os_evflags_destruct().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::event_flags

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

3015{
3016 assert (evflags != nullptr);
3017 if (attr == nullptr)
3018 {
3020 }
3021 new (evflags) event_flags (name, (const event_flags::attributes&)*attr);
3022}
static const attributes initializer
Default event flags initialiser.
Definition os-evflags.h:119

References os::rtos::event_flags::initializer.

◆ os_evflags_delete()

void os_evflags_delete ( os_evflags_t evflags)
Parameters
[in]evflagsPointer to dynamically allocated event flags object instance.
Returns
Nothing.

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

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

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

3078{
3079 assert (evflags != nullptr);
3080 delete reinterpret_cast<event_flags*> (evflags);
3081}

◆ os_evflags_destruct()

void os_evflags_destruct ( os_evflags_t evflags)
Parameters
[in]evflagsPointer to event flags object instance.
Returns
Nothing.
Note
Must be paired with os_evflags_construct().
Warning
Cannot be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::event_flags

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

3034{
3035 assert (evflags != nullptr);
3036 (reinterpret_cast<event_flags&> (*evflags)).~event_flags ();
3037}

◆ os_evflags_get()

os_flags_mask_t os_evflags_get ( os_evflags_t evflags,
os_flags_mask_t  mask,
os_flags_mode_t  mode 
)
Parameters
[in]evflagsPointer to event flags object instance.
[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).
Returns
The selected bits from the flags mask.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::event_flags::get()

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

3181{
3182 assert (evflags != nullptr);
3183 return (os_flags_mask_t)(reinterpret_cast<event_flags&> (*evflags))
3184 .get (mask, mode);
3185}
uint32_t os_flags_mask_t
Type of variables holding flags masks.
Definition os-c-decls.h:120

◆ os_evflags_get_name()

const char * os_evflags_get_name ( os_evflags_t evflags)
Parameters
[in]evflagsPointer to event flags object instance.
Returns
Null terminated string.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::event_flags::name()

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

3091{
3092 assert (evflags != nullptr);
3093 return (reinterpret_cast<event_flags&> (*evflags)).name ();
3094}

◆ os_evflags_new()

os_evflags_t * os_evflags_new ( const char *  name,
const os_evflags_attr_t attr 
)
Parameters
[in]namePointer to name (may be NULL).
[in]attrPointer to attributes (may be NULL).
Returns
Pointer to new event flags object instance.

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

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

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

3054{
3055 if (attr == nullptr)
3056 {
3058 }
3059 return reinterpret_cast<os_evflags_t*> (
3060 new event_flags (name, (const event_flags::attributes&)*attr));
3061}

References os::rtos::event_flags::initializer.

◆ os_evflags_raise()

os_result_t os_evflags_raise ( os_evflags_t evflags,
os_flags_mask_t  mask,
os_flags_mask_t oflags 
)
Parameters
[in]evflagsPointer to event flags object instance.
[in]maskThe OR-ed flags to raise.
[out]oflagsOptional pointer where to store the new value of the flags; may be NULL.
Return values
os_okThe flags were raised.
EINVALThe mask is zero.
ENOTRECOVERABLERaise failed.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::event_flags::raise()

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

3151{
3152 assert (evflags != nullptr);
3153 return (os_result_t)(reinterpret_cast<event_flags&> (*evflags))
3154 .raise (mask, oflags);
3155}
int raise(int sig)

References raise().

◆ os_evflags_timed_wait()

os_result_t os_evflags_timed_wait ( os_evflags_t evflags,
os_flags_mask_t  mask,
os_clock_duration_t  timeout,
os_flags_mask_t oflags,
os_flags_mode_t  mode 
)
Parameters
[in]evflagsPointer to event flags object instance.
[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.
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::event_flags::timed_wait()

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

3136{
3137 assert (evflags != nullptr);
3138 return (os_result_t)(reinterpret_cast<event_flags&> (*evflags))
3139 .timed_wait (mask, timeout, oflags, mode);
3140}

◆ os_evflags_try_wait()

os_result_t os_evflags_try_wait ( os_evflags_t evflags,
os_flags_mask_t  mask,
os_flags_mask_t oflags,
os_flags_mode_t  mode 
)
Parameters
[in]evflagsPointer to event flags object instance.
[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 were raised.
EINVALThe mask is outside of the permitted range.
EWOULDBLOCKThe expected condition did not occur.
ENOTRECOVERABLEWait failed.
Note
Can be invoked from Interrupt Service Routines.
For the complete definition, see
os::rtos::event_flags::try_wait()

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

3120{
3121 assert (evflags != nullptr);
3122 return (os_result_t)(reinterpret_cast<event_flags&> (*evflags))
3123 .try_wait (mask, oflags, mode);
3124}

◆ os_evflags_wait()

os_result_t os_evflags_wait ( os_evflags_t evflags,
os_flags_mask_t  mask,
os_flags_mask_t oflags,
os_flags_mode_t  mode 
)
Parameters
[in]evflagsPointer to event flags object instance.
[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 were 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::event_flags::wait()

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

3105{
3106 assert (evflags != nullptr);
3107 return (os_result_t)(reinterpret_cast<event_flags&> (*evflags))
3108 .wait (mask, oflags, mode);
3109}
pid_t wait(int *stat_loc)

References wait().