Xenomai  3.1
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
task-unrestricted, might-switch

◆ 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
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
primary-only, might-switch

◆ 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
primary-only, might-switch

◆ 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
primary-only, might-switch