Can TaskYIELD() be interrupted by an interrupt mid-way?

As described in the title, lets say task A is running on a core and is in the process of yielding via a call to taskYIELD(), is it safe for an interrupt to come in during the yield? Especially if the YIELD is currently calling something like portSAVE_CONTEXT? For more context I have a a GIC configured that sends particular interrupts at random times. When there are no interrupts, I just have a basic task that runs and then calls taskYIELD at the end in a loop. Is taskYIELD allowed to be interrupted mid context save?

You can safely assume that the FreeRTOS API can be used with interrupts enabled.

1 Like

taskYIELD raises a software interrupt and the context save and restore is done in the software interrupt ISR. There are two possibilities -

  1. The port support interrupt nesting - In this case, software interrupt ISR can be interrupted and the port code will ensure that no data corruption happens.
  2. The port does not support interrupt nesting - In this case, software interrupt ISR can be interrupted.

In both the cases, calling taskYIELD from a task is safe.

1 Like