High Priority Tasks Not Waking When Expected

I’ve seen this twice now in two different project and using different calls. What I’m seeing is that tasks are not waking when they should. Here’s my two examples. Both are on ARM Coretex-M processors. My system tick is set at 1kHz. No tickless idle right now.

  1. I was using event bits to wake a task from an ISR. The task was waking about 40 ms later than expected, after the system woke for another task. I changed to using task bits and the problem went away.
  2. (My current problem) I have a timing loop where I have a realtime task (no other realtime tasks in the program) that I’m trying to use to keep something firing periodically with an accuracy of a few ms. I’m using vTaskDelay() to set the timing. I’ve had this work very well in other projects, but things may be off by 100 ms when they actually fire.

I’m really perplexed here. Any hints on how to troubleshoot this? Thanks in advance.

Have you gone through all the suggestions on this page?

If so, then can you remove pieces of your application until you have the smallest amount of code that exhibits the problem, then post the relevant bits of code here. Just going through that process may reveal the issue.

You can also use a trace tool like tracealizer.

One thought about the event bits from ISR, as I remember, that sends a message to the Timer/Service task, which is normally a very high priority task. Could you have that set too low and it is getting held off by higher priority tasks running?

For long term accuracy for a real time task, you normally use vTaskDelayUntil() to keep the repeat rate constant, with vTaskDelay you keep a constant delay from the END of the one run to the start of the next. That can add up over time.

To follow up, after looking through a lot of things and tracing through the code to see what was causing it, we had a debug log point setup in our debugger that caused the timing to slip 7 to 20 ms every time it was hit. Removing that cleaned up the lost ticks.

Thank you for taking time to report back.