RTEMS: Semaphore Handler

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Files | Data Structures | Macros | Functions
Semaphore Handler
Internal » SuperCore

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.

## Data Structures
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.
RTEMS_INLINE_ROUTINE void | _CORE_semaphore_Acquire_critical (CORE_semaphore_Control *the_semaphore, Thread_queue_Context *queue_context)
| Acquires the semaphore critical.
RTEMS_INLINE_ROUTINE void | _CORE_semaphore_Release (CORE_semaphore_Control *the_semaphore, Thread_queue_Context *queue_context)
| Releases the semaphore.
RTEMS_INLINE_ROUTINE void | _CORE_semaphore_Destroy (CORE_semaphore_Control *the_semaphore, const Thread_queue_Operations *operations, Thread_queue_Context *queue_context)
| Destroys the semaphore.
RTEMS_INLINE_ROUTINE 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.
RTEMS_INLINE_ROUTINE uint32_t | _CORE_semaphore_Get_count (const CORE_semaphore_Control *the_semaphore)
| Returns the current count associated with the semaphore.
RTEMS_INLINE_ROUTINE 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.

## 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()

RTEMS_INLINE_ROUTINE void _CORE_semaphore_Acquire_critical | ( | CORE_semaphore_Control * | the_semaphore,
|  | Thread_queue_Context * | queue_context
| ) |  |

Acquires the semaphore critical.

This routine acquires the semaphore.

Parameters

  [in,out] | the_semaphore | The semaphore to acquire.
  | queue_context | The thread queue context.

## ◆ _CORE_semaphore_Destroy()

RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy | ( | CORE_semaphore_Control * | the_semaphore,
|  | const Thread_queue_Operations * | operations,
|  | Thread_queue_Context * | queue_context
| ) |  |

Destroys the semaphore.

This routine destroys the semaphore.

Parameters

  [out] | the_semaphore | The semaphore to destroy.
  | operations | The thread queue operations.
  | queue_context | The thread queue context.

## ◆ _CORE_semaphore_Get_count()

RTEMS_INLINE_ROUTINE uint32_t _CORE_semaphore_Get_count | ( | const CORE_semaphore_Control * | the_semaphore | ) |

Returns the current count associated with the semaphore.

Parameters

  the_semaphore | The semaphore to obtain the count of.

Returns
  the current count of this semaphore.

## ◆ _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_semaphore | The semaphore to initialize.
  | initial_value | The initial count of the semaphore.

## ◆ _CORE_semaphore_Release()

RTEMS_INLINE_ROUTINE void _CORE_semaphore_Release | ( | CORE_semaphore_Control * | the_semaphore,
|  | Thread_queue_Context * | queue_context
| ) |  |

Releases the semaphore.

This routine releases the semaphore.

Parameters

  [in,out] | the_semaphore | The semaphore to release.
  | queue_context | The thread queue context.

## ◆ _CORE_semaphore_Seize()

RTEMS_INLINE_ROUTINE 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.

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_semaphore | The semaphore to obtain.
  | operations | The thread queue operations.
  | executing | The currently executing thread.
  | wait | Indicates whether the calling thread is willing to wait.
  | queue_context | is a temporary variable used to contain the ISR disable level cookie.

Return values

  STATUS_SUCCESSFUL | The semaphore was successfully seized.
  STATUS_UNSATISFIED | The semaphore is currently not free and the calling thread not willing to wait.
  STATUS_TIMEOUT | A timeout occured.

## ◆ _CORE_semaphore_Surrender()

RTEMS_INLINE_ROUTINE 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.

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_semaphore | is the semaphore to surrender
  | operations | The thread queue operations.
  | maximum_count | The maximum number of units in the semaphore.
  | queue_context | is a temporary variable used to contain the ISR disable level cookie.

Return values

  STATUS_SUCCESSFUL | The unit was successfully freed to the semaphore.
  STATUS_MAXIMUM_COUNT_EXCEEDED | The maximum number of units was exceeded.