Chaining the higherPriorityTaskWoken variable

paulgcoleman wrote on Wednesday, March 14, 2012:

I have a situation where I’m responding to a number of GPIO interrupts with one ISR and I just want to clarify that I’m using the correct method of dealing with the situation whereby a higher priority task will be woken as a result of this interrupt.

Looking at the source code for xSemaphoreGiveFromISR() it looks as though it’s okay to chain the use of the variable higherPriorityTaskWoken as shown below as opposed to creating separate variables for each call to xSemaphoreGiveFromISR and then bitwise oring them together to create the final return value which is passed into the portEND_SWITCHING_ISR macro e.g.

ISR {
portBASE_TYPE higherPriorityTaskWoken = pdFALSE;      // only set its initial value once

if(some event)
xSemaphoreGiveFromISR(semA, &higherPriorityTaskWoken);         // using the variable here

if(some other event)
xSemaphoreGiveFromISR(semB, &higherPriorityTaskWoken); // and the same one here again

if(some other event)
xSemaphoreGiveFromISR(semC, &higherPriorityTaskWoken); // and here again

portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}

I would be grateful if somebody could just clarify that the above is correct.

Many thanks, Paul.

rtel wrote on Wednesday, March 14, 2012:

Yes your code is fine.

_

Regards._

paulgcoleman wrote on Wednesday, March 14, 2012:

Okay thanks for the clarification, it makes the code a lot cleaner than having separate variables and I’m all for that :slight_smile:

Regards, Paul.