portYIELD_FROM_ISR question

koseng1 wrote on Thursday, April 26, 2018:

Hello,

I understand portYIELD_FROM_ISR may trigger a context switch (task activated for deferred processing), but what happens after that deferred task has completed? Does the scheduler switch back to the ISR until the ISR finishes? Or is the deferred task only called after the ISR finishes? In other words for example:

void ISRHandler() {
// … code portion A
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
// … code portion B
} // end of ISRHandler

Assume higher priority task woken. Will the execution of code look like?

  1. code portion A … higher priority task … code portion B
  2. code portion A … code portion B … higher priority task
  3. code portion A … higher priority task … something else (B is skipped)

Thanks

1 Like

rtel wrote on Thursday, April 26, 2018:

Tasks only ever run when an interrupt is not running - that is
controlled by hardware - we could not have a task run in the middle of
an interrupt even if we wanted. So tasks will only execute after all
[potentially nested] interrupts have existed.

If a task is unblocked by an interrupt, then it will not run until after
all interrupts have completed.

1 Like

koseng1 wrote on Thursday, April 26, 2018:

So (2) (after the ISR has finished). I understand now. The portYIELD preps the scheduler to resume running the higher priority task once the ISR finishes.

Thanks for the quick reply!

1 Like