FreeRTOS + 0/1 examples
CodeScope will show references to xSemaphoreGive from the following samples and libraries:
Libraries
 
Symbols
loading...
Files
loading...

xSemaphoreGive macro

Macro to release a semaphore. The semaphore must have previously been created with a call to xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or xSemaphoreCreateCounting(). and obtained using sSemaphoreTake(). This macro must not be used from an ISR. See xSemaphoreGiveFromISR () for an alternative which can be used from an ISR. This macro must also not be used on semaphores created using xSemaphoreCreateRecursiveMutex(). Example usage:
SemaphoreHandle_t xSemaphore = NULL; void vATask( void * pvParameters ) { // Create the semaphore to guard a shared resource. xSemaphore = vSemaphoreCreateBinary(); if( xSemaphore != NULL ) { if( xSemaphoreGive( xSemaphore ) != pdTRUE ) { // We would expect this call to fail because we cannot give // a semaphore without first "taking" it! } // Obtain the semaphore - don't block if the semaphore is not // immediately available. if( xSemaphoreTake( xSemaphore, ( TickType_t ) 0 ) ) { // We now have the semaphore and can access the shared resource. // ... // We have finished accessing the shared resource so can free the // semaphore. if( xSemaphoreGive( xSemaphore ) != pdTRUE ) { // We would not expect this call to fail because we must have // obtained the semaphore to get here. } } } }

Syntax

#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )

Arguments

xSemaphore

A handle to the semaphore being released. This is the handle returned when the semaphore was created.

Return value

pdTRUE if the semaphore was released. pdFALSE if an error occurred. Semaphores are implemented using queues. An error can occur if there is no space on the queue to post a message - indicating that the semaphore was not first obtained correctly.

Examples

xSemaphoreGive is referenced by 1 libraries and example projects.

References

LocationText
semphr.h:447
#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )
cmsis_os.c:677
else if (xSemaphoreGive(mutex_id) != pdTRUE)
cmsis_os.c:832
if (xSemaphoreGive(semaphore_id) != pdTRUE) {
semphr.h:99
( void ) xSemaphoreGive( ( xSemaphore ) ); \