Poll binary mutex

jonas1978 wrote on Friday, November 05, 2010:

The documentation says that is possible to poll the state of a semaphore: “A block time of zero can be used to poll the semaphore” in the xSemaphoreTake section.
I have a hard time making this work.
Polling a semaphore should not change it in any way, or am I confused by the idea of “polling” and “peeking”?

I can see in semphr.h that the xSemaphore cannot set the “just peeking” boolean to true.

#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueGenericReceive( ( xQueueHandle ) xSemaphore, NULL, xBlockTime, pdFALSE )

Please enlighten me…

BR,
Jonas, DK

davedoors wrote on Friday, November 05, 2010:

Polling the semaphore will change its state if the semaphore is available, yes you are confused between polling and peeking.

jonas1978 wrote on Friday, November 05, 2010:

Thank you for a quick reply :slight_smile:
BR, Jonas