xSemaphoreGiveFromISR from context of a task

jstoezel wrote on Friday, March 20, 2009:


Sorry if this post appears twice, my first attempt seems to have failed.

I need to write that piece of code that is generic enough that it allows giving a semaphore from the context of either an ISR or a task. Since an ISR must use xSemaphoreGiveFromISR to give semaphores, is it possible to use xSemaphoreGiveFromISR in the context of a task?

If so, any cons with doing this?


rtel wrote on Friday, March 20, 2009:

You can use xQueueGenericSendFromISR() from a task but need to take care of critical sections.  The ISR version uses portSET_INTERRUPT_MASK_FROM_ISR() which is only defined for ports that use interrupt nesting.  You would need to implement an equivalent for your port if it were not already defined.