RTEMS  5.1
Files | Functions
Semaphores

Files

file  sem.h
 Classic Semaphores Manager API.
 
file  sem.c
 Classic Semaphore Information with Zero Objects.
 
file  semcreate.c
 rtems_semaphore_create
 
file  semdelete.c
 RTEMS Delete Semaphore.
 
file  semflush.c
 RTEMS Semaphore Flush.
 
file  semident.c
 RTEMS Semaphore Name to Id.
 
file  semobtain.c
 RTEMS Obtain Semaphore.
 
file  semrelease.c
 RTEMS Semaphore Release.
 

Functions

rtems_status_code rtems_semaphore_create (rtems_name name, uint32_t count, rtems_attribute attribute_set, rtems_task_priority priority_ceiling, rtems_id *id)
 rtems_semaphore_create More...
 
rtems_status_code rtems_semaphore_ident (rtems_name name, uint32_t node, rtems_id *id)
 RTEMS Semaphore Name to Id. More...
 
rtems_status_code rtems_semaphore_delete (rtems_id id)
 RTEMS Delete Semaphore. More...
 
rtems_status_code rtems_semaphore_obtain (rtems_id id, rtems_option option_set, rtems_interval timeout)
 RTEMS Obtain Semaphore. More...
 
rtems_status_code rtems_semaphore_release (rtems_id id)
 RTEMS Semaphore Release. More...
 
rtems_status_code rtems_semaphore_flush (rtems_id id)
 RTEMS Semaphore Flush. More...
 
rtems_status_code rtems_semaphore_set_priority (rtems_id semaphore_id, rtems_id scheduler_id, rtems_task_priority new_priority, rtems_task_priority *old_priority)
 Sets the priority value with respect to the specified scheduler of a semaphore. More...
 

Detailed Description

This encapsulates functionality related to the Classic API Semaphore Manager.

Function Documentation

◆ rtems_semaphore_create()

rtems_status_code rtems_semaphore_create ( rtems_name  name,
uint32_t  count,
rtems_attribute  attribute_set,
rtems_task_priority  priority_ceiling,
rtems_id id 
)

rtems_semaphore_create

This routine implements the rtems_semaphore_create directive. The semaphore will have the name name. The starting count for the semaphore is count. The attribute_set determines if the semaphore is global or local and the thread queue discipline. It returns the id of the created semaphore in ID.

◆ rtems_semaphore_delete()

rtems_status_code rtems_semaphore_delete ( rtems_id  id)

RTEMS Delete Semaphore.

This routine implements the rtems_semaphore_delete directive. The semaphore indicated by ID is deleted.

Parameters
[in]idis the semaphore id
Return values
Thismethod returns RTEMS_SUCCESSFUL if there was not an error. Otherwise, a status code is returned indicating the source of the error.

◆ rtems_semaphore_flush()

rtems_status_code rtems_semaphore_flush ( rtems_id  id)

RTEMS Semaphore Flush.

This method is the implementation of the flush directive of the Semaphore Manager.

This directive allows a thread to flush the threads pending on the semaphore.

Parameters
[in]idis the semaphore id
Return values
RTEMS_SUCCESSFULif successful or error code if unsuccessful

◆ rtems_semaphore_ident()

rtems_status_code rtems_semaphore_ident ( rtems_name  name,
uint32_t  node,
rtems_id id 
)

RTEMS Semaphore Name to Id.

This routine implements the rtems_semaphore_ident directive. This directive returns the semaphore ID associated with name. If more than one semaphore is named name, then the semaphore to which the ID belongs is arbitrary. node indicates the extent of the search for the ID of the semaphore named name. The search can be limited to a particular node or allowed to encompass all nodes.

Parameters
[in]nameis the user defined semaphore name
[in]nodeis(are) the node(s) to be searched
[in]idis the pointer to semaphore id
Return values
RTEMS_SUCCESSFULif successful or error code if unsuccessful and *id filled in with the semaphore id

◆ rtems_semaphore_obtain()

rtems_status_code rtems_semaphore_obtain ( rtems_id  id,
rtems_option  option_set,
rtems_interval  timeout 
)

RTEMS Obtain Semaphore.

This routine implements the rtems_semaphore_obtain directive. It attempts to obtain a unit from the semaphore associated with ID. If a unit can be allocated, the calling task will return immediately. If no unit is available, then the task may return immediately or block waiting for a unit with an optional timeout of timeout clock ticks. Whether the task blocks or returns immediately is based on the RTEMS_NO_WAIT option in the option_set.

Parameters
[in]idis the semaphore id
[in]option_setis the wait option
[in]timeoutis the number of ticks to wait (0 means wait forever)
Return values
Thismethod returns RTEMS_SUCCESSFUL if there was not an error. Otherwise, a status code is returned indicating the source of the error.

◆ rtems_semaphore_release()

rtems_status_code rtems_semaphore_release ( rtems_id  id)

RTEMS Semaphore Release.

This routine implements the rtems_semaphore_release directive. It frees a unit to the semaphore associated with ID. If a task was blocked waiting for a unit from this semaphore, then that task will be readied and the unit given to that task. Otherwise, the unit will be returned to the semaphore.

◆ rtems_semaphore_set_priority()

rtems_status_code rtems_semaphore_set_priority ( rtems_id  semaphore_id,
rtems_id  scheduler_id,
rtems_task_priority  new_priority,
rtems_task_priority old_priority 
)

Sets the priority value with respect to the specified scheduler of a semaphore.

The special priority value RTEMS_CURRENT_PRIORITY can be used to get the current priority value without changing it.

The interpretation of the priority value depends on the protocol of the semaphore object.

  • The Multiprocessor Resource Sharing Protocol needs a ceiling priority per scheduler instance. This operation can be used to specify these priority values.
  • For the Priority Ceiling Protocol the ceiling priority is used with this operation.
  • For other protocols this operation is not defined.
Parameters
[in]semaphore_idIdentifier of the semaphore.
[in]scheduler_idIdentifier of the scheduler.
[in]new_priorityThe new priority value. Use RTEMS_CURRENT_PRIORITY to not set a new priority and only get the current priority.
[out]old_priorityReference to store the old priority value.
Return values
RTEMS_SUCCESSFULSuccessful operation.
RTEMS_INVALID_IDInvalid semaphore or scheduler identifier.
RTEMS_INVALID_ADDRESSThe old priority reference is NULL.
RTEMS_INVALID_PRIORITYThe new priority value is invalid.
RTEMS_NOT_DEFINEDThe set priority operation is not defined for the protocol of this semaphore object.
RTEMS_ILLEGAL_ON_REMOTE_OBJECTNot supported for remote semaphores.
See also
rtems_scheduler_ident() and rtems_task_set_priority().