taskfreertosirq

FreeRtos calling vTaskDelete from IRQ


I spent some time but I can't find any info if it's allowed to call vTaskDelete from IRQ handler? I know some methods have specialized version for usage in IRQ routines however I can't find anything related to vTaskDelete. Currently it works but I don't want to do some hard to discover bug just because I didn't found info.


Solution

  • If you are calling a callback from the IRQ then it is still in the IRQ context. Calling vTaskDelete() with a NULL parameter would delete the task that was running before the interrupt was entered, so the interrupt would then try to return to a task that was no longer running. Even if that were not the case then the rule of thumb is not to use API functions that do not end in "FromISR" from an interrupt (the separate API ensures fewer decision points in the function, faster and standard interrupt entry as it doesn't need to keep an interrupt nesting variable, no need to pass parameters that don't make sense in an interrupt context [like a block time] into an interrupt function, etc.).