heinbali01 wrote on Monday, May 07, 2018:
You have called xTimerCreateTimerTask()
, which will start-up the timer task. Your timer functions will be called from this task sequentially. The call-back takes place in prvProcessReceivedCommands()
, by calling the user function pxCallbackFunction
.
The timer task is sleeping most of the time. It runs at a configurable task priority of configTIMER_TASK_PRIORITY
.
It runs alot of code, no sleep stuf that I know of.
“no sleep stuf” ? It should have sleeps!
Roughly spoken in a multitasking system, a task-switch will only take place if:
- Another task has a higher priority
- Another task has the same priority and time-slicing is enabled
Pre-emption is also important: if enabled a task can loose the CPU at any moment, also before it yields.
Sleeping means that a task doesn’t eat up CPU time. Sleeping is very important, except for tasks that have the lowest priority.
Now suppose that you have a task that spins without sleeping, and suppose that configTIMER_TASK_PRIORITY
is low, then the timer-task wil starve, it won’t get CPU time anymore.
So a timer has always a higher priority as a task?
Do you mean the timer task prvTimerTask
in timers.c
?
That is your design decision, you may or you may not.
What happens when a second timer calls the CPU?
As you have seen, the timer task will call your handlers in a sequential way. I would advice to keep the code short and not have it block.
Will it first finish the earlier timer task?
It is not really a task but a application hook. And yes, hook 2 will only be called once hook 1 has returned.