I'm trying to find where ~10% of the time are spent, this is how I'm looking:
I'm using TICKLESS mode by setting configUSETICKLESSIDLE=1.
Then i use the PRE/POSTSLEEPPROCESSING hooks to take the time spent in sleep mode. I measure the number of ms from the PRE call to the POST call using the RTC of the STM32F4 MCU.
Every 10 seconds, i.e. when the RTC have passed 10000 ms since the last report, I print a report saying how much time I have spent in the sleep state and the exact number of ms passed since the last report. This number is very often ~10% lower than the total amount of ms passed.
I have also added a snippet to log the task status, or rather the diff of the task time compared to the last report. Then I always get the IDLE task at the top, but according to RTOS, the IDLE has always used up very close to the total time. I usually also see some other tasks that have spent a couple of ms each, but nowhere near the missing 10% (1 second per 10 seconds).
However, sometimes I do see a very close correlation between the time spent in sleep mode, the total and the IDLE time, so it's not a problem with the RTC being 10% skewed compared to the clock used for the RTOS ticks.
I also tried to add debug logs in all? IRQ functions but didn't see that any was used at the time.
Anybody got any ideas?
Integer rounding errors? They will always round down.
Try without the sleep mode. Make sure the idle task is the only task running at 0 priority and use the run time stats to see how much cpu it gets.
It might be a set of closed source 3pp tasks I have running. If I disable that stack (a BT stack), the problem goes away, so my guess is they get many very short slices which are normally shorter than the ~4ms which is the RTC resolution (not an ideal behaviour). I need to verify this more closely, but that's my working theory right now.
Thanks for your input, I'll try without the sleep mode.