xSemaphoreTakeFromISR function

I read the documentation of the xSemaphoreTakeFromISR function(I couldn’t post the link…).

It was a little confusing. If I understood correctly calling this function from the ISR will not block the task, if the semaphore wasn’t available the function will return false and will not block. Am I correct?

Another question is regarding the last paragraph:
From FreeRTOS V7.3.0 pxHigherPriorityTaskWoken is an optional parameter and can be set to NULL.

I don’t understand what will happen if the second argument will be null and what was the difference if it was a non-null value.



Look at the description in the docs, eg here:

The difference is that in connection with …yieldfromISR(), this mechanism allows you to prematurely terminate the time slice of the task currently interrupted and schedule the task to be woken immediately after all pending interrupts have completed. The default is that the context switch is deferred until the time slice has expired.

An ISR is not a task, so can’t ‘block’. It can see if it was able to take the semaphore, but can’t ‘wait’ for it, as the task can’t run until the ISR ends.

If the wasWoken parameter is NULL, then it just means the ISR doesn’t know if a task switch is needed, so can either ‘waste’ time by always running the scheduler, or not run the scheduler and wait till it naturally happens.

The one case this makes sense is if you application is running non-preemptive, and only switching tasks at defined execution points, but otherwise doesn’t normally make sense.