Xenomai API
2.5.6.1
|
Files | |
file | cond.c |
This file is part of the Xenomai project. | |
Functions | |
int | rt_cond_create (RT_COND *cond, const char *name) |
Create a condition variable. | |
int | rt_cond_delete (RT_COND *cond) |
Delete a condition variable. | |
int | rt_cond_signal (RT_COND *cond) |
Signal a condition variable. | |
int | rt_cond_broadcast (RT_COND *cond) |
Broadcast a condition variable. | |
int | rt_cond_wait (RT_COND *cond, RT_MUTEX *mutex, RTIME timeout) |
Wait on a condition. | |
int | rt_cond_wait_until (RT_COND *cond, RT_MUTEX *mutex, RTIME timeout) |
Wait on a condition (with absolute timeout date). | |
int | rt_cond_inquire (RT_COND *cond, RT_COND_INFO *info) |
Inquire about a condition variable. | |
int | rt_cond_bind (RT_COND *cond, const char *name, RTIME timeout) |
Bind to a condition variable. | |
static int | rt_cond_unbind (RT_COND *cond) |
Unbind from a condition variable. |
Condition variable services.
A condition variable is a synchronization object which allows tasks to suspend execution until some predicate on shared data is satisfied. The basic operations on conditions are: signal the condition (when the predicate becomes true), and wait for the condition, blocking the task execution until another task signals the condition. A condition variable must always be associated with a mutex, to avoid a well-known race condition where a task prepares to wait on a condition variable and another task signals the condition just before the first task actually waits on it.
int rt_cond_bind | ( | RT_COND * | cond, |
const char * | name, | ||
RTIME | timeout | ||
) |
Bind to a condition variable.
This user-space only service retrieves the uniform descriptor of a given Xenomai condition variable identified by its symbolic name. If the condition variable does not exist on entry, this service blocks the caller until a condition variable of the given name is created.
name | A valid NULL-terminated name which identifies the condition variable to bind to. |
cond | The address of a condition variable descriptor retrieved by the operation. Contents of this memory is undefined upon failure. |
timeout | The number of clock ticks to wait for the registration to occur (see note). Passing TM_INFINITE causes the caller to block indefinitely until the object is registered. Passing TM_NONBLOCK causes the service to return immediately without waiting if the object is not registered on entry. |
Environments:
This service can be called from:
Rescheduling: always unless the request is immediately satisfied or timeout specifies a non-blocking operation.
int rt_cond_broadcast | ( | RT_COND * | cond | ) |
Broadcast a condition variable.
If the condition variable is pended, all tasks currently waiting on it are immediately unblocked.
cond | The descriptor address of the affected condition variable. |
Environments:
This service can be called from:
Rescheduling: possible.
References xnpod_schedule(), and xnsynch_flush().
int rt_cond_create | ( | RT_COND * | cond, |
const char * | name | ||
) |
Create a condition variable.
Create a synchronization object that allows tasks to suspend execution until some predicate on shared data is satisfied.
cond | The address of a condition variable descriptor Xenomai will use to store the variable-related data. This descriptor must always be valid while the variable is active therefore it must be allocated in permanent memory. |
name | An ASCII string standing for the symbolic name of the condition variable. When non-NULL and non-empty, this string is copied to a safe place into the descriptor, and passed to the registry package if enabled for indexing the created variable. |
Environments:
This service can be called from:
Rescheduling: possible.
References rt_cond_delete(), xnregistry_enter(), and xnsynch_init().
int rt_cond_delete | ( | RT_COND * | cond | ) |
Delete a condition variable.
Destroy a condition variable and release all the tasks currently pending on it. A condition variable exists in the system since rt_cond_create() has been called to create it, so this service must be called in order to destroy it afterwards.
cond | The descriptor address of the affected condition variable. |
Environments:
This service can be called from:
Rescheduling: possible.
References xnpod_schedule(), and xnregistry_remove().
Referenced by rt_cond_create().
int rt_cond_inquire | ( | RT_COND * | cond, |
RT_COND_INFO * | info | ||
) |
Inquire about a condition variable.
Return various information about the status of a given condition variable.
cond | The descriptor address of the inquired condition variable. |
info | The address of a structure the condition variable information will be written to. |
Environments:
This service can be called from:
Rescheduling: never.
int rt_cond_signal | ( | RT_COND * | cond | ) |
Signal a condition variable.
If the condition variable is pended, the first waiting task (by queuing priority order) is immediately unblocked.
cond | The descriptor address of the affected condition variable. |
Environments:
This service can be called from:
Rescheduling: possible.
References xnpod_schedule(), and xnsynch_wakeup_one_sleeper().
int rt_cond_unbind | ( | RT_COND * | cond | ) | [inline, static] |
Unbind from a condition variable.
This user-space only service unbinds the calling task from the condition variable object previously retrieved by a call to rt_cond_bind().
cond | The address of a condition variable descriptor to unbind from. |
This service can be called from:
Rescheduling: never.
int rt_cond_wait | ( | RT_COND * | cond, |
RT_MUTEX * | mutex, | ||
RTIME | timeout | ||
) |
Wait on a condition.
This service atomically release the mutex and causes the calling task to block on the specified condition variable. The caller will be unblocked when the variable is signaled, and the mutex re-acquired before returning from this service.
Tasks pend on condition variables by priority order.
cond | The descriptor address of the affected condition variable. |
mutex | The descriptor address of the mutex protecting the condition variable. |
timeout | The number of clock ticks to wait for the condition variable to be signaled (see note). Passing TM_INFINITE causes the caller to block indefinitely until the condition variable is signaled. |
Environments:
This service can be called from:
Rescheduling: always unless the request is immediately satisfied or timeout specifies a non-blocking operation.
References pthread_cleanup_pop(), pthread_cleanup_push(), pthread_setcanceltype(), and pthread_testcancel().
int rt_cond_wait_until | ( | RT_COND * | cond, |
RT_MUTEX * | mutex, | ||
RTIME | timeout | ||
) |
Wait on a condition (with absolute timeout date).
This service atomically release the mutex and causes the calling task to block on the specified condition variable. The caller will be unblocked when the variable is signaled, and the mutex re-acquired before returning from this service.
Tasks pend on condition variables by priority order.
cond | The descriptor address of the affected condition variable. |
mutex | The descriptor address of the mutex protecting the condition variable. |
timeout | The absolute date specifying a time limit to wait for the condition variable to be signaled (see note). Passing TM_INFINITE causes the caller to block indefinitely until the condition variable is signaled. |
Environments:
This service can be called from:
Rescheduling: always unless the request is immediately satisfied or timeout specifies a non-blocking operation.
References pthread_cleanup_pop(), pthread_cleanup_push(), pthread_setcanceltype(), and pthread_testcancel().