Xenomai
3.1
|
Macros | |
#define | cobalt_atomic_enter(__context) |
Enter atomic section (dual kernel only) More... | |
#define | cobalt_atomic_leave(__context) |
Leave atomic section (dual kernel only) More... | |
#define | RTDM_EXECUTE_ATOMICALLY(code_block) |
Execute code block atomically (DEPRECATED) More... | |
#define cobalt_atomic_enter | ( | __context | ) |
Enter atomic section (dual kernel only)
This call opens a fully atomic section, serializing execution with respect to all interrupt handlers (including for real-time IRQs) and Xenomai threads running on all CPUs.
__context | name of local variable to store the context in. This variable updated by the real-time core will hold the information required to leave the atomic section properly. |
#define cobalt_atomic_leave | ( | __context | ) |
Leave atomic section (dual kernel only)
This call closes an atomic section previously opened by a call to cobalt_atomic_enter(), restoring the preemption and interrupt state which prevailed prior to entering the exited section.
__context | name of local variable which stored the context. |
#define RTDM_EXECUTE_ATOMICALLY | ( | code_block | ) |
Execute code block atomically (DEPRECATED)
Generally, it is illegal to suspend the current task by calling rtdm_task_sleep(), rtdm_event_wait(), etc. while holding a spinlock. In contrast, this macro allows to combine several operations including a potentially rescheduling call to an atomic code block with respect to other RTDM_EXECUTE_ATOMICALLY() blocks. The macro is a light-weight alternative for protecting code blocks via mutexes, and it can even be used to synchronise real-time and non-real-time contexts.
code_block | Commands to be executed atomically |
break
, return
, goto
, etc. This would leave the global lock held during the code block execution in an inconsistent state. Moreover, do not embed complex operations into the code bock. Consider that they will be executed under preemption lock with interrupts switched-off. Also note that invocation of rescheduling calls may break the atomicity until the task gains the CPU again.