RTEMS
Files | Classes | Macros | Functions
Semaphore Handler

Semaphore Handler. More...

Files

file  coresem.h
 Data Associated with the Counting Semaphore Handler.
 
file  coresemimpl.h
 Inlined Routines Associated with the SuperCore Semaphore.
 
file  semaphoreimpl.h
 Semaphore Implementation.
 
file  coresem.c
 Core Semaphore Initialize.
 

Classes

struct  CORE_semaphore_Control
 
struct  Sem_Control
 

Macros

#define SEMAPHORE_TQ_OPERATIONS   &_Thread_queue_Operations_priority
 

Functions

void _CORE_semaphore_Initialize (CORE_semaphore_Control *the_semaphore, uint32_t initial_value)
 Initializes the semaphore based on the parameters passed. More...
 
static __inline__ void _CORE_semaphore_Acquire_critical (CORE_semaphore_Control *the_semaphore, Thread_queue_Context *queue_context)
 Acquires the semaphore critical. More...
 
static __inline__ void _CORE_semaphore_Release (CORE_semaphore_Control *the_semaphore, Thread_queue_Context *queue_context)
 Releases the semaphore. More...
 
static __inline__ void _CORE_semaphore_Destroy (CORE_semaphore_Control *the_semaphore, const Thread_queue_Operations *operations, Thread_queue_Context *queue_context)
 Destroys the semaphore. More...
 
static __inline__ Status_Control _CORE_semaphore_Surrender (CORE_semaphore_Control *the_semaphore, const Thread_queue_Operations *operations, uint32_t maximum_count, Thread_queue_Context *queue_context)
 Surrenders a unit to the semaphore. More...
 
static __inline__ uint32_t _CORE_semaphore_Get_count (const CORE_semaphore_Control *the_semaphore)
 Returns the current count associated with the semaphore. More...
 
static __inline__ Status_Control _CORE_semaphore_Seize (CORE_semaphore_Control *the_semaphore, const Thread_queue_Operations *operations, Thread_Control *executing, bool wait, Thread_queue_Context *queue_context)
 Seizes the semaphore. More...
 
static Sem_Control_Sem_Get (struct _Semaphore_Control *_sem)
 Gets the Sem_Control * of the semaphore. More...
 
static Thread_Control_Sem_Queue_acquire_critical (Sem_Control *sem, Thread_queue_Context *queue_context)
 Acquires the semaphore queue critical. More...
 
static void _Sem_Queue_release (Sem_Control *sem, ISR_Level level, Thread_queue_Context *queue_context)
 Releases the semaphore queue. More...
 

Detailed Description

Semaphore Handler.

This handler encapsulates functionality which provides the foundation Semaphore services used in all of the APIs supported by RTEMS.

Function Documentation

◆ _CORE_semaphore_Acquire_critical()

static __inline__ void _CORE_semaphore_Acquire_critical ( CORE_semaphore_Control the_semaphore,
Thread_queue_Context queue_context 
)
static

Acquires the semaphore critical.

This routine acquires the semaphore.

Parameters
[in,out]the_semaphoreThe semaphore to acquire.
queue_contextThe thread queue context.

Definition at line 67 of file coresemimpl.h.

◆ _CORE_semaphore_Destroy()

static __inline__ void _CORE_semaphore_Destroy ( CORE_semaphore_Control the_semaphore,
const Thread_queue_Operations operations,
Thread_queue_Context queue_context 
)
static

Destroys the semaphore.

This routine destroys the semaphore.

Parameters
[out]the_semaphoreThe semaphore to destroy.
operationsThe thread queue operations.
queue_contextThe thread queue context.

Definition at line 100 of file coresemimpl.h.

◆ _CORE_semaphore_Get_count()

static __inline__ uint32_t _CORE_semaphore_Get_count ( const CORE_semaphore_Control the_semaphore)
static

Returns the current count associated with the semaphore.

Parameters
the_semaphoreThe semaphore to obtain the count of.
Returns
the current count of this semaphore.

Definition at line 175 of file coresemimpl.h.

◆ _CORE_semaphore_Initialize()

void _CORE_semaphore_Initialize ( CORE_semaphore_Control the_semaphore,
uint32_t  initial_value 
)

Initializes the semaphore based on the parameters passed.

This package is the implementation of the CORE Semaphore Handler. This core object utilizes standard Dijkstra counting semaphores to provide synchronization and mutual exclusion capabilities.

This routine initializes the semaphore based on the parameters passed.

Parameters
[out]the_semaphoreThe semaphore to initialize.
initial_valueThe initial count of the semaphore.

Definition at line 23 of file coresem.c.

◆ _CORE_semaphore_Release()

static __inline__ void _CORE_semaphore_Release ( CORE_semaphore_Control the_semaphore,
Thread_queue_Context queue_context 
)
static

Releases the semaphore.

This routine releases the semaphore.

Parameters
[in,out]the_semaphoreThe semaphore to release.
queue_contextThe thread queue context.

Definition at line 83 of file coresemimpl.h.

◆ _CORE_semaphore_Seize()

static __inline__ Status_Control _CORE_semaphore_Seize ( CORE_semaphore_Control the_semaphore,
const Thread_queue_Operations operations,
Thread_Control executing,
bool  wait,
Thread_queue_Context queue_context 
)
static

Seizes the semaphore.

This routine attempts to receive a unit from the_semaphore. If a unit is available or if the wait flag is false, then the routine returns. Otherwise, the calling task is blocked until a unit becomes available.

Parameters
[in,out]the_semaphoreThe semaphore to obtain.
operationsThe thread queue operations.
executingThe currently executing thread.
waitIndicates whether the calling thread is willing to wait.
queue_contextis a temporary variable used to contain the ISR disable level cookie.
Return values
STATUS_SUCCESSFULThe semaphore was successfully seized.
STATUS_UNSATISFIEDThe semaphore is currently not free and the calling thread not willing to wait.
STATUS_TIMEOUTA timeout occured.

Definition at line 202 of file coresemimpl.h.

◆ _CORE_semaphore_Surrender()

static __inline__ Status_Control _CORE_semaphore_Surrender ( CORE_semaphore_Control the_semaphore,
const Thread_queue_Operations operations,
uint32_t  maximum_count,
Thread_queue_Context queue_context 
)
static

Surrenders a unit to the semaphore.

This routine frees a unit to the semaphore. 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.

Parameters
[in,out]the_semaphoreis the semaphore to surrender
operationsThe thread queue operations.
maximum_countThe maximum number of units in the semaphore.
queue_contextis a temporary variable used to contain the ISR disable level cookie.
Return values
STATUS_SUCCESSFULThe unit was successfully freed to the semaphore.
STATUS_MAXIMUM_COUNT_EXCEEDEDThe maximum number of units was exceeded.

Definition at line 131 of file coresemimpl.h.

◆ _Sem_Get()

static Sem_Control* _Sem_Get ( struct _Semaphore_Control *  _sem)
inlinestatic

Gets the Sem_Control * of the semaphore.

Parameters
semThe Semaphore_Control * to cast to Sem_Control *.
Returns
sem cast to Sem_Control *.

Definition at line 55 of file semaphoreimpl.h.

◆ _Sem_Queue_acquire_critical()

static Thread_Control* _Sem_Queue_acquire_critical ( Sem_Control sem,
Thread_queue_Context queue_context 
)
inlinestatic

Acquires the semaphore queue critical.

This routine acquires the semaphore.

Parameters
[in,out]semThe semaphore to acquire the queue of.
queue_contextThe thread queue context.
Returns
The executing thread.

Definition at line 70 of file semaphoreimpl.h.

◆ _Sem_Queue_release()

static void _Sem_Queue_release ( Sem_Control sem,
ISR_Level  level,
Thread_queue_Context queue_context 
)
inlinestatic

Releases the semaphore queue.

Parameters
[in,out]semThe semaphore to release the queue of.
levelThe interrupt level value to restore the interrupt status on the processor.
queue_contextThe thread queue context.

Definition at line 94 of file semaphoreimpl.h.