Can uxSemaphoreGetCount() be used to determine whether a mutex is available or not?

Hi,

Is that possible to use the function uxSemaphoreGetCount() to determine whether a mutex is available? There is also the function xSemaphoreGetMutexHolder(), but I found it to obscure and I don’t think it is what I need:

Returns:
The handle of the task that holds the mutex specified by the xMutex parameter. NULL is returned if the semaphore passed in the xMutex parameter is not a mutex type semaphore, or if the mutex is available and so not held by any task.

By the way, unrelated to the question, but too important: One needs to set configUSE_MUTEXES to 1 in order to use mutex’es, but nowhere in the official documentation is mentioned. Just saying :slight_smile:

Thank you!

Yes you can useuxSemaphoreGetCount().

1 Like