RTEMS  5.1
Files | Data Structures | Macros | Functions
Mutex Handler

Mutex Handler. More...

Files

file  coremutex.h
 CORE Mutex API.
 
file  coremuteximpl.h
 CORE Mutex Implementation.
 
file  coremutexseize.c
 Seize Mutex with Blocking.
 

Data Structures

struct  CORE_mutex_Control
 Control block used to manage each mutex. More...
 
struct  CORE_recursive_mutex_Control
 The recursive mutex control. More...
 
struct  CORE_ceiling_mutex_Control
 The recursive mutex control with priority ceiling protocol support. More...
 

Macros

#define CORE_MUTEX_TQ_OPERATIONS   &_Thread_queue_Operations_priority
 
#define CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS   &_Thread_queue_Operations_priority_inherit
 

Functions

RTEMS_INLINE_ROUTINE void _CORE_mutex_Initialize (CORE_mutex_Control *the_mutex)
 Initializes the mutex. More...
 
RTEMS_INLINE_ROUTINE void _CORE_mutex_Destroy (CORE_mutex_Control *the_mutex)
 Destroys the mutex. More...
 
RTEMS_INLINE_ROUTINE void _CORE_mutex_Acquire_critical (CORE_mutex_Control *the_mutex, Thread_queue_Context *queue_context)
 Acquires the mutex critical. More...
 
RTEMS_INLINE_ROUTINE void _CORE_mutex_Release (CORE_mutex_Control *the_mutex, Thread_queue_Context *queue_context)
 Releases the mutex. More...
 
RTEMS_INLINE_ROUTINE Thread_Control_CORE_mutex_Get_owner (const CORE_mutex_Control *the_mutex)
 Gets the owner of the mutex. More...
 
RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_locked (const CORE_mutex_Control *the_mutex)
 Checks if the mutex is locked. More...
 
Status_Control _CORE_mutex_Seize_slow (CORE_mutex_Control *the_mutex, const Thread_queue_Operations *operations, Thread_Control *executing, bool wait, Thread_queue_Context *queue_context)
 Seize the mutex slowly. More...
 
RTEMS_INLINE_ROUTINE void _CORE_mutex_Set_owner (CORE_mutex_Control *the_mutex, Thread_Control *owner)
 Sets the owner of the mutex. More...
 
RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_owner (const CORE_mutex_Control *the_mutex, const Thread_Control *the_thread)
 Checks if the the thread is the owner of the mutex. More...
 
RTEMS_INLINE_ROUTINE void _CORE_recursive_mutex_Initialize (CORE_recursive_mutex_Control *the_mutex)
 Initializes a recursive mutex. More...
 
RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_nested (CORE_recursive_mutex_Control *the_mutex)
 Seizes the recursive mutex nested. More...
 
RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize (CORE_recursive_mutex_Control *the_mutex, const Thread_queue_Operations *operations, Thread_Control *executing, bool wait, Status_Control(*nested)(CORE_recursive_mutex_Control *), Thread_queue_Context *queue_context)
 Seizes the recursive mutex. More...
 
RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Surrender (CORE_recursive_mutex_Control *the_mutex, const Thread_queue_Operations *operations, Thread_Control *executing, Thread_queue_Context *queue_context)
 Surrenders the recursive mutex. More...
 
RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Initialize (CORE_ceiling_mutex_Control *the_mutex, const Scheduler_Control *scheduler, Priority_Control priority_ceiling)
 initializes a ceiling mutex. More...
 
RTEMS_INLINE_ROUTINE const Scheduler_Control_CORE_ceiling_mutex_Get_scheduler (const CORE_ceiling_mutex_Control *the_mutex)
 Gets the scheduler of the ceiling mutex. More...
 
RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Set_priority (CORE_ceiling_mutex_Control *the_mutex, Priority_Control priority_ceiling, Thread_queue_Context *queue_context)
 Sets the priority of the ceiling mutex. More...
 
RTEMS_INLINE_ROUTINE Priority_Control _CORE_ceiling_mutex_Get_priority (const CORE_ceiling_mutex_Control *the_mutex)
 Gets the priority of the ceiling mutex. More...
 
RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Set_owner (CORE_ceiling_mutex_Control *the_mutex, Thread_Control *owner, Thread_queue_Context *queue_context)
 Sets the owner of the ceiling mutex. More...
 
RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize (CORE_ceiling_mutex_Control *the_mutex, Thread_Control *executing, bool wait, Status_Control(*nested)(CORE_recursive_mutex_Control *), Thread_queue_Context *queue_context)
 Seizes the ceiling mutex. More...
 
RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Surrender (CORE_ceiling_mutex_Control *the_mutex, Thread_Control *executing, Thread_queue_Context *queue_context)
 Surrenders the ceiling mutex. More...
 

Detailed Description

Mutex Handler.

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

Function Documentation

◆ _CORE_ceiling_mutex_Get_priority()

RTEMS_INLINE_ROUTINE Priority_Control _CORE_ceiling_mutex_Get_priority ( const CORE_ceiling_mutex_Control the_mutex)

Gets the priority of the ceiling mutex.

Parameters
the_mutexThe mutex to get the priority from.
Returns
The priority ceiling of the_mutex.

◆ _CORE_ceiling_mutex_Get_scheduler()

RTEMS_INLINE_ROUTINE const Scheduler_Control* _CORE_ceiling_mutex_Get_scheduler ( const CORE_ceiling_mutex_Control the_mutex)

Gets the scheduler of the ceiling mutex.

Parameters
the_mutexThe ceiling mutex to get the scheduler from.
Returns
The scheduler of the mutex. If RTEMS_SMP is not defined, the first entry of the _Scheduler_Table is returned.

◆ _CORE_ceiling_mutex_Initialize()

RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Initialize ( CORE_ceiling_mutex_Control the_mutex,
const Scheduler_Control scheduler,
Priority_Control  priority_ceiling 
)

initializes a ceiling mutex.

Parameters
[out]the_mutexThe ceiling mutex to initialize.
schedulerThe scheduler for the new ceiling mutex. Only needed if RTEMS_SMP is defined
priority_ceilingThe priority ceiling for the initialized mutex.

◆ _CORE_ceiling_mutex_Seize()

RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize ( CORE_ceiling_mutex_Control the_mutex,
Thread_Control executing,
bool  wait,
Status_Control(*)(CORE_recursive_mutex_Control *)  nested,
Thread_queue_Context queue_context 
)

Seizes the ceiling mutex.

Parameters
[in,out]the_mutexThe mutex to seize.
executingThe executing thread.
waitIndicates whether the calling thread is willing to wait.
nestedFunction that returns the status of the recursive mutex
queue_contextThe thread queue context.
Return values
STATUS_SUCCESSFULThe owner of the mutex was changed successfully.
STATUS_NOT_DEFINEDIf the scheduler of the executing thread is not equal to the owner of the_mutex .
STATUS_MUTEX_CEILING_VIOLATEDThe owners wait priority is smaller than the priority of the ceiling mutex.
otherReturn value of nested.

◆ _CORE_ceiling_mutex_Set_owner()

RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Set_owner ( CORE_ceiling_mutex_Control the_mutex,
Thread_Control owner,
Thread_queue_Context queue_context 
)

Sets the owner of the ceiling mutex.

Parameters
[in,out]the_mutexThe mutex to set the owner of.
ownerThe new owner of the_mutex.
queue_contextThe thread queue context.
Return values
STATUS_SUCCESSFULThe owner of the mutex was changed successfully.
STATUS_MUTEX_CEILING_VIOLATEDThe owners wait priority is smaller than the priority of the ceiling mutex.

◆ _CORE_ceiling_mutex_Set_priority()

RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Set_priority ( CORE_ceiling_mutex_Control the_mutex,
Priority_Control  priority_ceiling,
Thread_queue_Context queue_context 
)

Sets the priority of the ceiling mutex.

Parameters
[out]the_mutexThe ceiling mutex to set the priority of.
priority_ceilingThe new priority ceiling of the mutex.
queue_contextThe thread queue context.

◆ _CORE_ceiling_mutex_Surrender()

RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Surrender ( CORE_ceiling_mutex_Control the_mutex,
Thread_Control executing,
Thread_queue_Context queue_context 
)

Surrenders the ceiling mutex.

Parameters
[in,out]the_mutexThe ceiling mutex to surrender.
executingThe executing thread.
queue_contextThe thread queue context.
Return values
STATUS_SUCCESSFULThe ceiling mutex was successfullysurrendered.
STATUS_NOT_OWNERThe executing thread is not the owner of the_mutex.

◆ _CORE_mutex_Acquire_critical()

RTEMS_INLINE_ROUTINE void _CORE_mutex_Acquire_critical ( CORE_mutex_Control the_mutex,
Thread_queue_Context queue_context 
)

Acquires the mutex critical.

Parameters
[in,out]the_mutexThe mutex to acquire critical.
queue_contextThe queue context.

◆ _CORE_mutex_Destroy()

RTEMS_INLINE_ROUTINE void _CORE_mutex_Destroy ( CORE_mutex_Control the_mutex)

Destroys the mutex.

Parameters
[out]the_mutexthe mutex to destroy.

◆ _CORE_mutex_Get_owner()

RTEMS_INLINE_ROUTINE Thread_Control* _CORE_mutex_Get_owner ( const CORE_mutex_Control the_mutex)

Gets the owner of the mutex.

Parameters
the_mutexThe mutex to get the owner from.
Returns
The owner of the mutex.

◆ _CORE_mutex_Initialize()

RTEMS_INLINE_ROUTINE void _CORE_mutex_Initialize ( CORE_mutex_Control the_mutex)

Initializes the mutex.

Parameters
[out]the_mutexThe mutex to initialize.

◆ _CORE_mutex_Is_locked()

RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_locked ( const CORE_mutex_Control the_mutex)

Checks if the mutex is locked.

This routine returns true if the specified mutex is locked and false otherwise.

Parameters
the_mutexThe mutex to check if it is locked.
Return values
trueThe mutex is locked.
falseThe mutex is not locked.

◆ _CORE_mutex_Is_owner()

RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_owner ( const CORE_mutex_Control the_mutex,
const Thread_Control the_thread 
)

Checks if the the thread is the owner of the mutex.

Parameters
the_mutexThe mutex to check the owner of.
the_threadThe thread to check if it is the owner of the_mutex.
Return values
truethe_thread is the owner of the_mutex.
falsethe_thread is not the owner of the_mutex.

◆ _CORE_mutex_Release()

RTEMS_INLINE_ROUTINE void _CORE_mutex_Release ( CORE_mutex_Control the_mutex,
Thread_queue_Context queue_context 
)

Releases the mutex.

Parameters
[in,out]the_mutexThe mutex to release.
queue_contextThe queue context.

◆ _CORE_mutex_Seize_slow()

Status_Control _CORE_mutex_Seize_slow ( CORE_mutex_Control the_mutex,
const Thread_queue_Operations operations,
Thread_Control executing,
bool  wait,
Thread_queue_Context queue_context 
)

Seize the mutex slowly.

Parameters
[in,out]the_mutexThe mutex to seize.
operationsThe thread queue operations.
executingThe calling thread.
waitIndicates whether the calling thread is willing to wait.
queue_contextThe thread queue context.
Return values
_Thread_Wait_get_statusThe status of the executing thread.
STATUS_UNAVAILABLEThe calling thread is not willing to wait.

◆ _CORE_mutex_Set_owner()

RTEMS_INLINE_ROUTINE void _CORE_mutex_Set_owner ( CORE_mutex_Control the_mutex,
Thread_Control owner 
)

Sets the owner of the mutex.

Parameters
[out]the_mutexThe mutex to set the owner from.
ownerThe new owner of the mutex.

◆ _CORE_recursive_mutex_Initialize()

RTEMS_INLINE_ROUTINE void _CORE_recursive_mutex_Initialize ( CORE_recursive_mutex_Control the_mutex)

Initializes a recursive mutex.

Parameters
[out]the_mutexThe recursive mutex to initialize.

◆ _CORE_recursive_mutex_Seize()

RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize ( CORE_recursive_mutex_Control the_mutex,
const Thread_queue_Operations operations,
Thread_Control executing,
bool  wait,
Status_Control(*)(CORE_recursive_mutex_Control *)  nested,
Thread_queue_Context queue_context 
)

Seizes the recursive mutex.

Parameters
[in,out]the_mutexThe recursive mutex to seize.
operationsThe thread queue operations.
[out]executingThe executing thread.
waitIndicates whether the calling thread is willing to wait.
nestedReturns the status of a recursive mutex.
queue_contextThe thread queue context.
Return values
STATUS_SUCCESSFULThe owner of the mutex was NULL, successful seizing of the mutex.
_Thread_Wait_get_statusThe status of the executing thread.
STATUS_UNAVAILABLEThe calling thread is not willing to wait.

◆ _CORE_recursive_mutex_Seize_nested()

RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_nested ( CORE_recursive_mutex_Control the_mutex)

Seizes the recursive mutex nested.

Parameters
[out]the_mutexThe recursive mutex to seize nested.
Returns
STATUS_SUCCESSFUL, this method is always successful.

◆ _CORE_recursive_mutex_Surrender()

RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Surrender ( CORE_recursive_mutex_Control the_mutex,
const Thread_queue_Operations operations,
Thread_Control executing,
Thread_queue_Context queue_context 
)

Surrenders the recursive mutex.

Parameters
[in,out]the_mutexThe recursive mutex to surrender.
operationsThe thread queue operations.
executingThe executing thread.
queue_contextthe thread queue context.
Return values
STATUS_SUCCESSFULthe_mutex is successfully surrendered.
STATUS_NOT_OWNERThe executing thread does not own the_mutex.