|
FreeRTOS-Cpp
|
Class that encapsulates the functionality of a FreeRTOS recursive mutex. More...
#include <FreeRTOS/Mutex.hpp>


Public Member Functions | |
| StaticRecursiveMutex () | |
Construct a new StaticRecursiveMutex object by calling SemaphoreHandle_t xSemaphoreCreateRecursiveMutexStatic(
StaticSemaphore_t *pxMutexBuffer ) | |
| StaticRecursiveMutex (const StaticRecursiveMutex &)=delete | |
| StaticRecursiveMutex & | operator= (const StaticRecursiveMutex &)=delete |
| StaticRecursiveMutex (StaticRecursiveMutex &&) noexcept=default | |
| StaticRecursiveMutex & | operator= (StaticRecursiveMutex &&) noexcept=default |
Public Member Functions inherited from FreeRTOS::RecursiveMutexBase | |
| RecursiveMutexBase (const RecursiveMutexBase &)=delete | |
| RecursiveMutexBase & | operator= (const RecursiveMutexBase &)=delete |
| bool | lock (const TickType_t ticksToWait=portMAX_DELAY) const |
Function that calls xSemaphoreTakeRecursive( SemaphoreHandle_t
xMutex, TickType_t xTicksToWait ) | |
| bool | unlock () const |
Function that calls xSemaphoreGiveRecursive( SemaphoreHandle_t
xSemaphore ) | |
Public Member Functions inherited from FreeRTOS::MutexBase | |
| MutexBase (const MutexBase &)=delete | |
| MutexBase & | operator= (const MutexBase &)=delete |
| bool | isValid () const |
| Function that checks if the underlying semaphore handle is not NULL. This should be used to ensure a semaphore has been created correctly. | |
| bool | lock (const TickType_t ticksToWait=portMAX_DELAY) const |
Function that calls xSemaphoreTake( SemaphoreHandle_t
xSemaphore, TickType_t xTicksToWait ) | |
| bool | lockFromISR (bool &higherPriorityTaskWoken) const |
Function that calls xSemaphoreTakeFromISR ( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken ) | |
| bool | lockFromISR () const |
Function that calls xSemaphoreTakeFromISR ( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken ) | |
| bool | unlock () const |
Function that calls xSemaphoreGive( SemaphoreHandle_t xSemaphore
) | |
Private Attributes | |
| StaticSemaphore_t | staticRecursiveMutex |
Additional Inherited Members | |
Static Public Member Functions inherited from FreeRTOS::RecursiveMutexBase | |
| static void * | operator new (size_t, void *) |
| static void * | operator new[] (size_t, void *) |
| static void * | operator new (size_t)=delete |
| static void * | operator new[] (size_t)=delete |
Static Public Member Functions inherited from FreeRTOS::MutexBase | |
| static void * | operator new (size_t)=delete |
| static void * | operator new[] (size_t)=delete |
| static void * | operator new (size_t, void *ptr) |
| static void * | operator new[] (size_t, void *ptr) |
Class that encapsulates the functionality of a FreeRTOS recursive mutex.
Each recursive mutex require a small amount of RAM that is used to hold the recursive mutex's state. If a mutex is created using FreeRTOS::RecursiveMutex then the required RAM is automatically allocated from the FreeRTOS heap. If a recursive mutex is created using FreeRTOS::StaticRecursiveMutex then the RAM is provided by the application writer, which requires an additional parameter, but allows the RAM to be statically allocated at compile time. See the Static Vs Dynamic allocation page for more information.
Contrary to non-recursive mutexes, a task can lock a recursive mutex multiple times, and the recursive mutex will only be returned after the holding task has unlocked the mutex the same number of times it locked the mutex.
Like non-recursive mutexes, recursive mutexes implement a priority inheritance algorithm. The priority of a task that locks a mutex will be temporarily raised if another task of higher priority attempts to obtain the same mutex. The task that owns the mutex 'inherits' the priority of the task attempting to lock the same mutex. This means the mutex must always be unlocked otherwise the higher priority task will never be able to obtain the mutex, and the lower priority task will never 'disinherit' the priority.
|
inline |
Construct a new StaticRecursiveMutex object by calling SemaphoreHandle_t xSemaphoreCreateRecursiveMutexStatic(
StaticSemaphore_t *pxMutexBuffer )
Example Usage