Complete the code to create a mutex semaphore.
SemaphoreHandle_t mutex = [1]();The xSemaphoreCreateMutex() function creates a mutex semaphore.
Complete the code to take the mutex semaphore with a block time of 100 ticks.
if (xSemaphoreTake(mutex, [1]) == pdTRUE) { // Critical section }
The second parameter of xSemaphoreTake() is the block time in ticks. Here, 100 ticks is used.
Fix the error in the code to correctly give back the mutex semaphore.
xSemaphore[1](mutex);The function xSemaphoreGive() releases the mutex semaphore.
Fill both blanks to create a mutex and check if creation was successful.
SemaphoreHandle_t mutex = [1](); if (mutex == [2]) { // Handle error }
xSemaphoreCreateMutex() creates the mutex. If it returns NULL, creation failed.
Fill all three blanks to create a mutex, take it with no wait, and then give it back.
SemaphoreHandle_t mutex = [1](); if (xSemaphoreTake(mutex, [2]) == pdTRUE) { xSemaphore[3](mutex); }
First, create the mutex with xSemaphoreCreateMutex(). Then take it with zero wait time (0). Finally, give it back with xSemaphoreGive().
