RTEMS CPU Kit with SuperCore  4.10.99.0
Data Structures | Functions | Variables
Semaphores
RTEMS Classic API

This include file contains all the constants and structures associated with the Semaphore Manager. More...

Collaboration diagram for Semaphores:

Data Structures

struct  Semaphore_Control
 The following defines the control block used to manage each semaphore. More...

Functions

void _Semaphore_Manager_initialization (void)
 Semaphore Manager Initialization.
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
rtems_status_code rtems_semaphore_ident (rtems_name name, uint32_t node, rtems_id *id)
 RTEMS Semaphore Name to Id.
rtems_status_code rtems_semaphore_delete (rtems_id id)
 RTEMS Delete Semaphore.
rtems_status_code rtems_semaphore_obtain (rtems_id id, rtems_option option_set, rtems_interval timeout)
 RTEMS Obtain Semaphore.
rtems_status_code rtems_semaphore_release (rtems_id id)
 RTEMS Semaphore Release.
rtems_status_code rtems_semaphore_flush (rtems_id id)
 RTEMS Semaphore Flush.
bool _Semaphore_Seize (Semaphore_Control *the_semaphore, uint32_t option_set)
 _Semaphore_Seize
rtems_status_code _Semaphore_Translate_core_mutex_return_code (uint32_t the_mutex_status)
 Semaphore Translate Core Mutex Return Code.
rtems_status_code _Semaphore_Translate_core_semaphore_return_code (uint32_t the_mutex_status)
 Semaphore Translate Core Semaphore Return Code.
RTEMS_INLINE_ROUTINE
Semaphore_Control
_Semaphore_Allocate (void)
 Allocates a semaphore control block from the inactive chain of free semaphore control blocks.
RTEMS_INLINE_ROUTINE void _Semaphore_Free (Semaphore_Control *the_semaphore)
 Frees a semaphore control block to the inactive chain of free semaphore control blocks.
RTEMS_INLINE_ROUTINE
Semaphore_Control
_Semaphore_Get (Objects_Id id, Objects_Locations *location)
 Maps semaphore IDs to semaphore control blocks.
RTEMS_INLINE_ROUTINE
Semaphore_Control
_Semaphore_Get_interrupt_disable (Objects_Id id, Objects_Locations *location, ISR_Level *level)
 Maps semaphore IDs to semaphore control blocks.
RTEMS_INLINE_ROUTINE bool _Semaphore_Is_null (Semaphore_Control *the_semaphore)
 Checks if the_semaphore is NULL.

Variables

RTEMS_SEM_EXTERN
Objects_Information 
_Semaphore_Information
 The following defines the information control block used to manage this class of objects.

Detailed Description

This include file contains all the constants and structures associated with the Semaphore Manager.

This encapsulates functionality related to the Classic API Semaphore Manager.

This manager utilizes standard Dijkstra counting semaphores to provide synchronization and mutual exclusion capabilities.

Directives provided are:


Function Documentation

RTEMS_INLINE_ROUTINE Semaphore_Control* _Semaphore_Allocate ( void  )

Allocates a semaphore control block from the inactive chain of free semaphore control blocks.

This function allocates a semaphore control block from the inactive chain of free semaphore control blocks.

References _Objects_Allocate(), and _Semaphore_Information.

RTEMS_INLINE_ROUTINE void _Semaphore_Free ( Semaphore_Control the_semaphore)

Frees a semaphore control block to the inactive chain of free semaphore control blocks.

This routine frees a semaphore control block to the inactive chain of free semaphore control blocks.

References _Objects_Free(), _Semaphore_Information, and Semaphore_Control::Object.

RTEMS_INLINE_ROUTINE Semaphore_Control* _Semaphore_Get ( Objects_Id  id,
Objects_Locations location 
)

Maps semaphore IDs to semaphore control blocks.

This function maps semaphore IDs to semaphore control blocks. If ID corresponds to a local semaphore, then it returns the_semaphore control pointer which maps to ID and location is set to OBJECTS_LOCAL. if the semaphore ID is global and resides on a remote node, then location is set to OBJECTS_REMOTE, and the_semaphore is undefined. Otherwise, location is set to OBJECTS_ERROR and the_semaphore is undefined.

References _Objects_Get(), and _Semaphore_Information.

RTEMS_INLINE_ROUTINE Semaphore_Control* _Semaphore_Get_interrupt_disable ( Objects_Id  id,
Objects_Locations location,
ISR_Level level 
)

Maps semaphore IDs to semaphore control blocks.

This function maps semaphore IDs to semaphore control blocks. If ID corresponds to a local semaphore, then it returns the_semaphore control pointer which maps to ID and location is set to OBJECTS_LOCAL. if the semaphore ID is global and resides on a remote node, then location is set to OBJECTS_REMOTE, and the_semaphore is undefined. Otherwise, location is set to OBJECTS_ERROR and the_semaphore is undefined.

References _Objects_Get_isr_disable(), and _Semaphore_Information.

RTEMS_INLINE_ROUTINE bool _Semaphore_Is_null ( Semaphore_Control the_semaphore)

Checks if the_semaphore is NULL.

This function returns TRUE if the_semaphore is NULL and FALSE otherwise.

void _Semaphore_Manager_initialization ( void  )

Semaphore Manager Initialization.

This routine performs the initialization necessary for this manager.

bool _Semaphore_Seize ( Semaphore_Control the_semaphore,
uint32_t  option_set 
)

_Semaphore_Seize

This routine attempts to receive a unit from the_semaphore. If a unit is available or if the RTEMS_NO_WAIT option is enabled in option_set, then the routine returns. Otherwise, the calling task is blocked until a unit becomes available.

rtems_status_code _Semaphore_Translate_core_mutex_return_code ( uint32_t  the_mutex_status)

Semaphore Translate Core Mutex Return Code.

This function returns a RTEMS status code based on the mutex status code specified.

Parameters:
[in]the_mutex_statusis the mutex status code to translate
Return values:
translatedRTEMS status code
rtems_status_code _Semaphore_Translate_core_semaphore_return_code ( uint32_t  the_mutex_status)

Semaphore Translate Core Semaphore Return Code.

This function returns a RTEMS status code based on the semaphore status code specified.

Parameters:
[in]the_mutex_statusis the semaphore status code to translate
Return values:
translatedRTEMS status code
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.

Semaphore Manager

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_status_code rtems_semaphore_flush ( rtems_id  id)

RTEMS Semaphore Flush.

DESCRIPTION: This package 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_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_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_status_code rtems_semaphore_release ( rtems_id  id)

RTEMS Semaphore Release.

Semaphore Manager

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.