Complete the code to create a mutex in FreeRTOS.
SemaphoreHandle_t xMutex = xSemaphoreCreate[1]();In FreeRTOS, a mutex is created using xSemaphoreCreateMutex().
Complete the code to take a binary semaphore in FreeRTOS.
if(xSemaphoreTake(xBinarySemaphore, [1])) { // Critical section }
Using portMAX_DELAY makes the task wait indefinitely to take the semaphore.
Fix the error in the code to release a mutex in FreeRTOS.
xSemaphore[1](xMutex);To release a mutex, use xSemaphoreGive().
Fill both blanks to create and take a binary semaphore.
SemaphoreHandle_t xBinarySemaphore = xSemaphoreCreate[1](); if(xSemaphore[2](xBinarySemaphore, portMAX_DELAY)) { // Access shared resource }
Binary semaphore is created with xSemaphoreCreateBinary() and taken with xSemaphoreTake().
Fill all three blanks to create a mutex, take it, and then give it back.
SemaphoreHandle_t xMutex = xSemaphoreCreate[1](); if(xSemaphore[2](xMutex, portMAX_DELAY)) { // Critical section xSemaphore[3](xMutex); }
Create a mutex with xSemaphoreCreateMutex(), take it with xSemaphoreTake(), and release it with xSemaphoreGive().
