RTEMS: Mutex Handler

| RTEMS 5.4-rc2

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

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.
RTEMS_INLINE_ROUTINE void | _CORE_mutex_Destroy (CORE_mutex_Control *the_mutex)
| Destroys the mutex.
RTEMS_INLINE_ROUTINE void | _CORE_mutex_Acquire_critical (CORE_mutex_Control *the_mutex, Thread_queue_Context *queue_context)
| Acquires the mutex critical.
RTEMS_INLINE_ROUTINE void | _CORE_mutex_Release (CORE_mutex_Control *the_mutex, Thread_queue_Context *queue_context)
| Releases the mutex.
RTEMS_INLINE_ROUTINE Thread_Control * | _CORE_mutex_Get_owner (const CORE_mutex_Control *the_mutex)
| Gets the owner of the mutex.
RTEMS_INLINE_ROUTINE bool | _CORE_mutex_Is_locked (const CORE_mutex_Control *the_mutex)
| Checks if the mutex is locked.
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.
RTEMS_INLINE_ROUTINE void | _CORE_mutex_Set_owner (CORE_mutex_Control *the_mutex, Thread_Control *owner)
| Sets the owner of the mutex.
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.
RTEMS_INLINE_ROUTINE void | _CORE_recursive_mutex_Initialize (CORE_recursive_mutex_Control *the_mutex)
| Initializes a recursive mutex.
RTEMS_INLINE_ROUTINE Status_Control | _CORE_recursive_mutex_Seize_nested (CORE_recursive_mutex_Control *the_mutex)
| Seizes the recursive mutex nested.
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.
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.
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.
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.
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.
RTEMS_INLINE_ROUTINE Priority_Control | _CORE_ceiling_mutex_Get_priority (const CORE_ceiling_mutex_Control *the_mutex)
| Gets the priority of the ceiling mutex.
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.
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.
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.

## 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_mutex | The 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_mutex | The 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_mutex | The ceiling mutex to initialize.
  | scheduler | The scheduler for the new ceiling mutex. Only needed if RTEMS_SMP is defined
  | priority_ceiling | The 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_mutex | The mutex to seize.
  | executing | The executing thread.
  | wait | Indicates whether the calling thread is willing to wait.
  | nested | Function that returns the status of the recursive mutex
  | queue_context | The thread queue context.

Return values

  STATUS_SUCCESSFUL | The owner of the mutex was changed successfully.
  STATUS_NOT_DEFINED | If the scheduler of the executing thread is not equal to the owner of the_mutex .
  STATUS_MUTEX_CEILING_VIOLATED | The owners wait priority is smaller than the priority of the ceiling mutex.
  other | Return 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_mutex | The mutex to set the owner of.
  | owner | The new owner of the_mutex.
  | queue_context | The thread queue context.

Return values

  STATUS_SUCCESSFUL | The owner of the mutex was changed successfully.
  STATUS_MUTEX_CEILING_VIOLATED | The 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_mutex | The ceiling mutex to set the priority of.
  | priority_ceiling | The new priority ceiling of the mutex.
  | queue_context | The 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_mutex | The ceiling mutex to surrender.
  | executing | The executing thread.
  | queue_context | The thread queue context.

Return values

  STATUS_SUCCESSFUL | The ceiling mutex was successfullysurrendered.
  STATUS_NOT_OWNER | The 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_mutex | The mutex to acquire critical.
  | queue_context | The queue context.

## ◆ _CORE_mutex_Destroy()

RTEMS_INLINE_ROUTINE void _CORE_mutex_Destroy | ( | CORE_mutex_Control * | the_mutex | ) |

Destroys the mutex.

Parameters

  [out] | the_mutex | the 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_mutex | The 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_mutex | The 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_mutex | The mutex to check if it is locked.

Return values

  true | The mutex is locked.
  false | The 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_mutex | The mutex to check the owner of.
  the_thread | The thread to check if it is the owner of the_mutex.

Return values

  true | the_thread is the owner of the_mutex.
  false | the_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_mutex | The mutex to release.
  | queue_context | The 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_mutex | The mutex to seize.
  | operations | The thread queue operations.
  | executing | The calling thread.
  | wait | Indicates whether the calling thread is willing to wait.
  | queue_context | The thread queue context.

Return values

  _Thread_Wait_get_status | The status of the executing thread.
  STATUS_UNAVAILABLE | The 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_mutex | The mutex to set the owner from.
  | owner | The 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_mutex | The 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_mutex | The recursive mutex to seize.
  | operations | The thread queue operations.
  [out] | executing | The executing thread.
  | wait | Indicates whether the calling thread is willing to wait.
  | nested | Returns the status of a recursive mutex.
  | queue_context | The thread queue context.

Return values

  STATUS_SUCCESSFUL | The owner of the mutex was NULL, successful seizing of the mutex.
  _Thread_Wait_get_status | The status of the executing thread.
  STATUS_UNAVAILABLE | The 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_mutex | The 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_mutex | The recursive mutex to surrender.
  | operations | The thread queue operations.
  | executing | The executing thread.
  | queue_context | the thread queue context.

Return values

  STATUS_SUCCESSFUL | the_mutex is successfully surrendered.
  STATUS_NOT_OWNER | The executing thread does not own the_mutex.