|
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_abs_t start_date, nanosecs_rel_t period) |
| Adjust real-time task period. More...
|
|
int | rtdm_task_wait_period (unsigned long *overruns_r) |
| 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_wait_prepare (struct rtdm_wait_context *wc) |
| Register wait context. More...
|
|
void | rtdm_wait_complete (struct rtdm_wait_context *wc) |
| Mark completion for a wait context. More...
|
|
int | rtdm_wait_is_completed (struct rtdm_wait_context *wc) |
| Test completion of a wait context. 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...
|
|
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.
- Parameters
-
[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. |
- Returns
- 0 on success if condition is satisfied, otherwise:
- -EINTR is returned if the calling task has been unblocked by a Linux signal or explicitly via rtdm_task_unblock().
- -EPERM may be returned if an illegal invocation environment is detected.
- Tags
- primary-only, might-switch
void rtdm_wait_prepare |
( |
struct rtdm_wait_context * |
wc | ) |
|
Register wait context.
rtdm_wait_prepare() registers a wait context structure for the caller, which can be later retrieved by a call to rtdm_wait_get_context(). This call is normally issued before the current task blocks on a wait object, waiting for some (producer) code to wake it up. Arbitrary data can be exchanged between both sites via the wait context structure, which is allocated by the waiter (consumer) side.
wc is the address of an anchor object which is commonly embedded into a larger structure with arbitrary contents, which needs to be shared between the consumer (waiter) and the producer for implementing the wait code.
A typical implementation pattern for the wait side is:
1 struct rtdm_waitqueue wq;
2 struct some_wait_context {
5 struct rtdm_wait_context wc;
8 wait_context.input_value = 42;
9 rtdm_wait_prepare(&wait_context);
10 ret = rtdm_wait_condition(&wq, rtdm_wait_is_completed(&wait_context));
13 handle_event(wait_context.output_value);
On the producer side, the implementation would look like:
1 struct rtdm_waitqueue wq;
2 struct some_wait_context {
5 struct rtdm_wait_context wc;
7 struct rtdm_wait_context *wc;
10 rtdm_for_each_waiter(task, &wq) {
11 wc = rtdm_wait_get_context(task);
12 wait_context_ptr = container_of(wc, struct some_wait_context, wc);
13 wait_context_ptr->output_value = 12;
15 rtdm_waitqueue_broadcast(&wq);
- Parameters
-
wc | Wait context to register. |