Xenomai  3.0.8
Collaboration diagram for Mutex services:

Functions

void rtdm_mutex_init (rtdm_mutex_t *mutex)
 Initialise a mutex. More...
 
void rtdm_mutex_destroy (rtdm_mutex_t *mutex)
 Destroy a mutex. More...
 
void rtdm_mutex_unlock (rtdm_mutex_t *mutex)
 Release a mutex. More...
 
int rtdm_mutex_lock (rtdm_mutex_t *mutex)
 Request a mutex. More...
 
int rtdm_mutex_timedlock (rtdm_mutex_t *mutex, nanosecs_rel_t timeout, rtdm_toseq_t *timeout_seq)
 Request a mutex with timeout. More...
 

Detailed Description

Function Documentation

◆ rtdm_mutex_destroy()

void rtdm_mutex_destroy ( rtdm_mutex_t *  mutex)

Destroy a mutex.

Parameters
[in,out]mutexMutex handle as returned by rtdm_mutex_init()
Tags cobalt-core-tags "task-unrestricted, might-switch"

References XNRMID.

◆ rtdm_mutex_init()

void rtdm_mutex_init ( rtdm_mutex_t *  mutex)

Initialise a mutex.

This function initalises a basic mutex with priority inversion protection. "Basic", as it does not allow a mutex owner to recursively lock the same mutex again.

Parameters
[in,out]mutexMutex handle
Tags cobalt-core-tags "task-unrestricted"

◆ rtdm_mutex_lock()

int rtdm_mutex_lock ( rtdm_mutex_t *  mutex)

Request a mutex.

This is the light-weight version of rtdm_mutex_timedlock(), implying an infinite timeout.

Parameters
[in,out]mutexMutex handle as returned by rtdm_mutex_init()
Returns
0 on success, otherwise:
  • -EIDRM is returned if mutex has been destroyed.
  • -EPERM may be returned if an illegal invocation environment is detected.
Tags cobalt-core-tags "primary-only, might-switch"

References rtdm_mutex_timedlock().

◆ rtdm_mutex_timedlock()

int rtdm_mutex_timedlock ( rtdm_mutex_t *  mutex,
nanosecs_rel_t  timeout,
rtdm_toseq_t *  timeout_seq 
)

Request a mutex with timeout.

This function tries to acquire the given mutex. If it is not available, the caller is blocked unless non-blocking operation was selected.

Parameters
[in,out]mutexMutex handle as returned by rtdm_mutex_init()
[in]timeoutRelative timeout in nanoseconds, see RTDM_TIMEOUT_xxx for special values
[in,out]timeout_seqHandle of a timeout sequence as returned by rtdm_toseq_init() or NULL
Returns
0 on success, otherwise:
  • -ETIMEDOUT is returned if the if the request has not been satisfied within the specified amount of time.
  • -EWOULDBLOCK is returned if timeout is negative and the semaphore value is currently not positive.
  • -EIDRM is returned if mutex has been destroyed.
  • -EPERM may be returned if an illegal invocation environment is detected.
Tags cobalt-core-tags "primary-only, might-switch"

Referenced by rtdm_mutex_lock().

◆ rtdm_mutex_unlock()

void rtdm_mutex_unlock ( rtdm_mutex_t *  mutex)

Release a mutex.

This function releases the given mutex, waking up a potential waiter which was blocked upon rtdm_mutex_lock() or rtdm_mutex_timedlock().

Parameters
[in,out]mutexMutex handle as returned by rtdm_mutex_init()
Tags cobalt-core-tags "primary-only, might-switch"