Skip to content

Group xSemaphoreGiveRecursive

Modules > xSemaphoreGiveRecursive


Detailed Description

semphr. h

Macro to recursively release, or 'give', a mutex type semaphore. The mutex must have previously been created using a call to xSemaphoreCreateRecursiveMutex();

configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this macro to be available.

This macro must not be used on mutexes created using xSemaphoreCreateMutex().

A mutex used recursively can be 'taken' repeatedly by the owner. The mutex doesn't become available again until the owner has called xSemaphoreGiveRecursive() for each successful 'take' request. For example, if a task successfully 'takes' the same mutex 5 times then the mutex will not be available to any other task until it has also 'given' the mutex back exactly five times.


  • xMutex A handle to the mutex being released, or 'given'. This is the handle returned by xSemaphoreCreateMutex();


pdTRUE if the semaphore was given.

Example usage: