I understand we should not block the timer callbacks. But I have an operation to be performed which is time consuming and might block the callback. So I am thinking of spawning a worker task when timer callback hits to perform the time consuming work and kill the task once done
Is this method suitable or notifying a parallel dormant task through the timer callback is a better option?
I’d prefer the second option which is also the common approach. It’s less heavy and reliable. You simply can’t run into trouble resp. out of resources dynamically creating and deleting tasks especially in resource constrained embedded systems. It’s also far more responsive because creating a task requires quite a bit of internal setup until your code runs to deal with the causing (timer) event.
I agree, unless there is a real need to be dynamically changing the task configuration, it is best to just initially create all the needed tasks and just have them block until they are needed.