Xenomai API  2.6.5
Collaboration diagram for Task Services:

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)
 Intialise and start a real-time task. More...
 
void rtdm_task_destroy (rtdm_task_t *task)
 Destroy a real-time task. 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...
 
void rtdm_task_join_nrt (rtdm_task_t *task, unsigned int poll_delay)
 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

Maximum and minimum task priorities

#define RTDM_TASK_LOWEST_PRIORITY   XNSCHED_LOW_PRIO
 
#define RTDM_TASK_HIGHEST_PRIORITY   XNSCHED_HIGH_PRIO
 

Task Priority Modification

Raise or lower task priorities by one level

#define RTDM_TASK_RAISE_PRIORITY   (+1)
 
#define RTDM_TASK_LOWER_PRIORITY   (-1)
 

Detailed Description

Typedef Documentation

typedef void(* rtdm_task_proc_t) (void *arg)

Real-time task procedure.

Parameters
[in,out]argargument as passed to rtdm_task_init()

Function Documentation

void rtdm_task_busy_sleep ( nanosecs_rel_t  delay)

Busy-wait a specified amount of time.

Parameters
[in]delayDelay in nanoseconds. Note that a zero delay does not have the meaning of RTDM_TIMEOUT_INFINITE here.
Note
The caller must not be migratable to different CPUs while executing this service. Otherwise, the actual delay will be undefined.

Environments:

This service can be called from:

  • Kernel module initialization/cleanup code
  • Interrupt service routine (should be avoided or kept short)
  • Kernel-based task
  • User-space task (RT, non-RT)

Rescheduling: never (except due to external interruptions).

rtdm_task_t* rtdm_task_current ( void  )

Get current real-time task.

Returns
Pointer to task handle

Environments:

This service can be called from:

  • Kernel-based task
  • User-space task (RT, non-RT)

Rescheduling: never.

void rtdm_task_destroy ( rtdm_task_t *  task)

Destroy a real-time task.

Parameters
[in,out]taskTask handle as returned by rtdm_task_init()
Note
Passing the same task handle to RTDM services after the completion of this function is not allowed.

Environments:

This service can be called from:

  • Kernel module initialization/cleanup code
  • Kernel-based task
  • User-space task (RT, non-RT)

Rescheduling: never.

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 
)

Intialise 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_nrt() was invoked.

Parameters
[in,out]taskTask handle
[in]nameOptional task name
[in]task_procProcedure to be executed by the task
[in]argCustom argument passed to task_proc() on entry
[in]priorityPriority of the task, see also Task Priority Range
[in]periodPeriod in nanoseconds of a cyclic task, 0 for non-cyclic mode
Returns
0 on success, otherwise negative error code

Environments:

This service can be called from:

  • Kernel module initialization/cleanup code
  • Kernel-based task
  • User-space task (RT, non-RT)

Rescheduling: possible.

References xnpod_delete_thread(), xnpod_init_thread(), xnpod_set_thread_periodic(), and xnpod_start_thread().

void rtdm_task_join_nrt ( rtdm_task_t *  task,
unsigned int  poll_delay 
)

Wait on a real-time task to terminate.

Parameters
[in,out]taskTask handle as returned by rtdm_task_init()
[in]poll_delayDelay in milliseconds between periodic tests for the state of the real-time task. This parameter is ignored if the termination is internally realised without polling.
Note
Passing the same task handle to RTDM services after the completion of this function is not allowed.
This service does not trigger the termination of the targeted task. The user has to take of this, otherwise rtdm_task_join_nrt() will never return.

Environments:

This service can be called from:

  • Kernel module initialization/cleanup code
  • User-space task (non-RT)

Rescheduling: possible.

References XNZOMBIE.

int rtdm_task_set_period ( rtdm_task_t *  task,
nanosecs_rel_t  period 
)

Adjust real-time task period.

Parameters
[in,out]taskTask handle as returned by rtdm_task_init()
[in]periodNew period in nanoseconds of a cyclic task, 0 for non-cyclic mode

Environments:

This service can be called from:

  • Kernel module initialization/cleanup code
  • Interrupt service routine
  • Kernel-based task
  • User-space task (RT, non-RT)

Rescheduling: possible.

void rtdm_task_set_priority ( rtdm_task_t *  task,
int  priority 
)

Adjust real-time task priority.

Parameters
[in,out]taskTask handle as returned by rtdm_task_init()
[in]priorityNew priority of the task, see also Task Priority Range

Environments:

This service can be called from:

  • Kernel module initialization/cleanup code
  • Interrupt service routine
  • Kernel-based task
  • User-space task (RT, non-RT)

Rescheduling: possible.

int rtdm_task_sleep ( nanosecs_rel_t  delay)

Sleep a specified amount of time.

Parameters
[in]delayDelay in nanoseconds, see RTDM_TIMEOUT_xxx for special values.
Returns
0 on success, otherwise:
  • -EINTR is returned if calling task has been unblock by a signal or explicitly via rtdm_task_unblock().
  • -EPERM may be returned if an illegal invocation environment is detected.

Environments:

This service can be called from:

  • Kernel-based task
  • User-space task (RT)

Rescheduling: always.

int rtdm_task_sleep_abs ( nanosecs_abs_t  wakeup_time,
enum rtdm_timer_mode  mode 
)

Sleep until a specified absolute time.

Parameters
[in]wakeup_timeAbsolute timeout in nanoseconds
[in]modeSelects the timer mode, see RTDM_TIMERMODE_xxx for details
Returns
0 on success, otherwise:
  • -EINTR is returned if calling task has been unblock by a signal or explicitly via rtdm_task_unblock().
  • -EPERM may be returned if an illegal invocation environment is detected.
  • -EINVAL is returned if an invalid parameter was passed.

Environments:

This service can be called from:

  • Kernel-based task
  • User-space task (RT)

Rescheduling: always, unless the specified time already passed.

int rtdm_task_sleep_until ( nanosecs_abs_t  wakeup_time)

Sleep until a specified absolute time.

Deprecated:
Use rtdm_task_sleep_abs instead!
Parameters
[in]wakeup_timeAbsolute timeout in nanoseconds
Returns
0 on success, otherwise:
  • -EINTR is returned if calling task has been unblock by a signal or explicitly via rtdm_task_unblock().
  • -EPERM may be returned if an illegal invocation environment is detected.

Environments:

This service can be called from:

  • Kernel-based task
  • User-space task (RT)

Rescheduling: always, unless the specified time already passed.

int rtdm_task_unblock ( rtdm_task_t *  task)

Activate a blocked real-time task.

Returns
Non-zero is returned if the task was actually unblocked from a pending wait state, 0 otherwise.

Environments:

This service can be called from:

  • Kernel module initialization/cleanup code
  • Interrupt service routine
  • Kernel-based task
  • User-space task (RT, non-RT)

Rescheduling: possible.

int rtdm_task_wait_period ( void  )

Wait on next real-time task period.

Returns
0 on success, otherwise:
  • -EINVAL is returned if calling task is not in periodic mode.
  • -ETIMEDOUT is returned if a timer overrun occurred, which indicates that a previous release point has been missed by the calling task.

Environments:

This service can be called from:

  • Kernel-based task
  • User-space task (RT)

Rescheduling: always, unless a timer overrun occured.