Xenomai  3.0.5
Collaboration diagram for Semaphore Services:

Functions

void rtdm_sem_init (rtdm_sem_t *sem, unsigned long value)
 Initialise a semaphore. More...
 
void rtdm_sem_destroy (rtdm_sem_t *sem)
 Destroy a semaphore. More...
 
int rtdm_sem_down (rtdm_sem_t *sem)
 Decrement a semaphore. More...
 
int rtdm_sem_timeddown (rtdm_sem_t *sem, nanosecs_rel_t timeout, rtdm_toseq_t *timeout_seq)
 Decrement a semaphore with timeout. More...
 
void rtdm_sem_up (rtdm_sem_t *sem)
 Increment a semaphore. More...
 
int rtdm_sem_select (rtdm_sem_t *sem, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned int fd_index)
 Bind a selector to a semaphore. More...
 

Detailed Description

Function Documentation

◆ rtdm_sem_destroy()

void rtdm_sem_destroy ( rtdm_sem_t *  sem)

Destroy a semaphore.

Parameters
[in,out]semSemaphore handle as returned by rtdm_sem_init()
Tags
task-unrestricted, might-switch

References XNRMID, and xnselect_destroy().

◆ rtdm_sem_down()

int rtdm_sem_down ( rtdm_sem_t *  sem)

Decrement a semaphore.

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

Parameters
[in,out]semSemaphore handle as returned by rtdm_sem_init()
Returns
0 on success, otherwise:
  • -EINTR is returned if calling task has been unblock by a signal or explicitly via rtdm_task_unblock().
  • -EIDRM is returned if sem has been destroyed.
  • -EPERM may be returned if an illegal invocation environment is detected.
Tags
primary-only, might-switch

References rtdm_sem_timeddown().

◆ rtdm_sem_init()

void rtdm_sem_init ( rtdm_sem_t *  sem,
unsigned long  value 
)

Initialise a semaphore.

Parameters
[in,out]semSemaphore handle
[in]valueInitial value of the semaphore
Tags
task-unrestricted

◆ rtdm_sem_select()

int rtdm_sem_select ( rtdm_sem_t *  sem,
rtdm_selector_t *  selector,
enum rtdm_selecttype  type,
unsigned int  fd_index 
)

Bind a selector to a semaphore.

This functions binds the given selector to the semaphore so that the former is notified when the semaphore state changes. Typically the select binding handler will invoke this service.

Parameters
[in,out]semSemaphore handle as returned by rtdm_sem_init()
[in,out]selectorSelector as passed to the select binding handler
[in]typeType of the bound event as passed to the select binding handler
[in]fd_indexFile descriptor index as passed to the select binding handler
Returns
0 on success, otherwise:
  • -ENOMEM is returned if there is insufficient memory to establish the dynamic binding.
  • -EINVAL is returned if type or fd_index are invalid.
Tags
task-unrestricted

◆ rtdm_sem_timeddown()

int rtdm_sem_timeddown ( rtdm_sem_t *  sem,
nanosecs_rel_t  timeout,
rtdm_toseq_t *  timeout_seq 
)

Decrement a semaphore with timeout.

This function tries to decrement the given semphore's value if it is positive on entry. If not, the caller is blocked unless non-blocking operation was selected.

Parameters
[in,out]semSemaphore handle as returned by rtdm_sem_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.
  • -EINTR is returned if calling task has been unblock by a signal or explicitly via rtdm_task_unblock().
  • -EIDRM is returned if sem has been destroyed.
  • -EPERM may be returned if an illegal invocation environment is detected.
Tags
primary-timed, might-switch

Referenced by rtdm_sem_down().

◆ rtdm_sem_up()

void rtdm_sem_up ( rtdm_sem_t *  sem)

Increment a semaphore.

This function increments the given semphore's value, waking up a potential waiter which was blocked upon rtdm_sem_down().

Parameters
[in,out]semSemaphore handle as returned by rtdm_sem_init()
Tags
unrestricted, might-switch