Nonblocking mutex take from ISR

fazjaxton wrote on Wednesday, November 14, 2012:

I understand that ISRs cannot block waiting on mutexes.  However, I would like to take a mutex in an ISR only if it is available, and not otherwise.  This is equivalent to pthread_mutex_trylock in posix threads.  Is it safe to call xSemaphoreTake with a timeout of 0 from an ISR in all cases?  I’m not sure why this wouldn’t work, but the API reference says it doesn’t.  Is there another way to handle this?  Or is this operation unsupported by FreeRTOS?

Thank you,
Kevin

edwards3 wrote on Wednesday, November 14, 2012:

FreeRTOS V7.2.0 (it is not on 7.3.0) added an xSemaphoreTakeFromISR() function. Use with caution on a mutex type sempahore as I don’t know the implications on priority inheritance. It might be ok, I don’t know. Richard?