Xenomai
3.0-rc7
|
![]() |
Typedefs | |
typedef void(* | rtdm_task_proc_t) (void *arg) |
Real-time task procedure. More... | |
Functions | |
int | rtdm_task_init (rtdm_task_t *task, const char *name, rtdm_task_proc_t task_proc, void *arg, int priority, nanosecs_rel_t period) |
Initialise and start a real-time task. More... | |
void | rtdm_task_destroy (rtdm_task_t *task) |
Destroy a real-time task. More... | |
int | rtdm_task_should_stop (void) |
Check for pending termination request. More... | |
void | rtdm_task_set_priority (rtdm_task_t *task, int priority) |
Adjust real-time task priority. More... | |
int | rtdm_task_set_period (rtdm_task_t *task, nanosecs_rel_t period) |
Adjust real-time task period. More... | |
int | rtdm_task_wait_period (void) |
Wait on next real-time task period. More... | |
int | rtdm_task_unblock (rtdm_task_t *task) |
Activate a blocked real-time task. More... | |
rtdm_task_t * | rtdm_task_current (void) |
Get current real-time task. More... | |
int | rtdm_task_sleep (nanosecs_rel_t delay) |
Sleep a specified amount of time. More... | |
int | rtdm_task_sleep_until (nanosecs_abs_t wakeup_time) |
Sleep until a specified absolute time. More... | |
int | rtdm_task_sleep_abs (nanosecs_abs_t wakeup_time, enum rtdm_timer_mode mode) |
Sleep until a specified absolute time. More... | |
int | rtdm_task_busy_wait (bool condition, nanosecs_rel_t spin_ns, nanosecs_rel_t sleep_ns) |
Safe busy waiting. More... | |
void | rtdm_task_join (rtdm_task_t *task) |
Wait on a real-time task to terminate. More... | |
void | rtdm_task_busy_sleep (nanosecs_rel_t delay) |
Busy-wait a specified amount of time. More... | |
Task Priority Range | |
#define | RTDM_TASK_LOWEST_PRIORITY 0 |
#define | RTDM_TASK_HIGHEST_PRIORITY 99 |
Task Priority Modification | |
#define | RTDM_TASK_RAISE_PRIORITY (+1) |
#define | RTDM_TASK_LOWER_PRIORITY (-1) |
typedef void(* rtdm_task_proc_t) (void *arg) |
Real-time task procedure.
[in,out] | arg | argument as passed to rtdm_task_init() |
void rtdm_task_busy_sleep | ( | nanosecs_rel_t | delay | ) |
Busy-wait a specified amount of time.
This service does not schedule out the caller, but rather spins in a tight loop, burning CPU cycles until the timeout elapses.
[in] | delay | Delay in nanoseconds. Note that a zero delay does not have the meaning of RTDM_TIMEOUT_INFINITE here. |
int rtdm_task_busy_wait | ( | bool | condition, |
nanosecs_rel_t | spin_ns, | ||
nanosecs_rel_t | sleep_ns | ||
) |
Safe busy waiting.
This service alternates active spinning and sleeping within a wait loop, until a condition is satisfied. While sleeping, a task is scheduled out and does not consume any CPU time.
rtdm_task_busy_wait() is particularly useful for waiting for a state change reading an I/O register, which usually happens shortly after the wait starts, without incurring the adverse effects of long busy waiting if it doesn't.
[in] | condition | The C expression to be tested for detecting completion. |
[in] | spin_ns | The time to spin on condition before sleeping, expressed as a count of nanoseconds. |
[in] | sleep_ns | The time to sleep for before spinning again, expressed as a count of nanoseconds. |
rtdm_task_t* rtdm_task_current | ( | void | ) |
void rtdm_task_destroy | ( | rtdm_task_t * | task | ) |
Destroy a real-time task.
This call sends a termination request to task, then waits for it to exit. All RTDM task should check for pending termination requests by calling rtdm_task_should_stop() from their work loop.
If task is current, rtdm_task_destroy() terminates the current context, and does not return to the caller.
[in,out] | task | Task handle as returned by rtdm_task_init() |
int rtdm_task_init | ( | rtdm_task_t * | task, |
const char * | name, | ||
rtdm_task_proc_t | task_proc, | ||
void * | arg, | ||
int | priority, | ||
nanosecs_rel_t | period | ||
) |
Initialise and start a real-time task.
After initialising a task, the task handle remains valid and can be passed to RTDM services until either rtdm_task_destroy() or rtdm_task_join() was invoked.
[in,out] | task | Task handle |
[in] | name | Optional task name |
[in] | task_proc | Procedure to be executed by the task |
[in] | arg | Custom argument passed to task_proc() on entry |
[in] | priority | Priority of the task, see also Task Priority Range |
[in] | period | Period in nanoseconds of a cyclic task, 0 for non-cyclic mode. Waiting for the first and subsequent periodic events is done using rtdm_task_wait_period(). |
References xnthread_cancel(), xnthread_init(), xnthread_set_periodic(), and xnthread_start().
void rtdm_task_join | ( | rtdm_task_t * | task | ) |
Wait on a real-time task to terminate.
[in,out] | task | Task handle as returned by rtdm_task_init() |
References xnthread_join().
int rtdm_task_set_period | ( | rtdm_task_t * | task, |
nanosecs_rel_t | period | ||
) |
Adjust real-time task period.
[in,out] | task | Task handle as returned by rtdm_task_init() |
[in] | period | New period in nanoseconds of a cyclic task, 0 for non-cyclic mode |
void rtdm_task_set_priority | ( | rtdm_task_t * | task, |
int | priority | ||
) |
Adjust real-time task priority.
[in,out] | task | Task handle as returned by rtdm_task_init() |
[in] | priority | New priority of the task, see also Task Priority Range |
int rtdm_task_should_stop | ( | void | ) |
Check for pending termination request.
Check whether a termination request was received by the current RTDM task. Termination requests are sent by calling rtdm_task_destroy().
int rtdm_task_sleep | ( | nanosecs_rel_t | delay | ) |
Sleep a specified amount of time.
[in] | delay | Delay in nanoseconds, see RTDM_TIMEOUT_xxx for special values. |
int rtdm_task_sleep_abs | ( | nanosecs_abs_t | wakeup_time, |
enum rtdm_timer_mode | mode | ||
) |
Sleep until a specified absolute time.
[in] | wakeup_time | Absolute timeout in nanoseconds |
[in] | mode | Selects the timer mode, see RTDM_TIMERMODE_xxx for details |
int rtdm_task_sleep_until | ( | nanosecs_abs_t | wakeup_time | ) |
Sleep until a specified absolute time.
[in] | wakeup_time | Absolute timeout in nanoseconds |
int rtdm_task_unblock | ( | rtdm_task_t * | task | ) |
Activate a blocked real-time task.
int rtdm_task_wait_period | ( | void | ) |
Wait on next real-time task period.