FreeRTOS kernel overhead

bertino wrote on Monday, March 17, 2014:


It’s no so long since I started with FreeRTOS, running on cortex M3 (more specifically I’m on a STM32L151xB).

Following common sense, the conditions under which I expect advantage in using the FreeRTOS real time scheduler is that the average scheduler run time should be much less than the period between two consecutive sysTicks interrupts (leaving enough of the time slice to tasks). In my own mindset the only way I can currently think of to perform such an assessment is to measure duration of the xPortSysTickHandler(), for example starting a timer at the beginning of it and stopping it at the end in order to read out the duration. Does this make any sense? Or, is there anything else you would recommend as quick check or as rule of thumb?


rtel wrote on Monday, March 17, 2014:

Systick only increments the tick interrupt and most non-RTOS systems have some kind of tick interrupt so that is not much of an increment in the overhead. Systick does not not perform the context switch. The context switch time is stated on cycles on the following page of the FAQ:

However, the main time advantage of using an RTOS is in the ability to make a system completely event driven, and therefore not polling anything and not using any processing time unless there is something to process. Normally the time spent context switching or incrementing the tick is a tiny fraction of the time spent within a time slice, and you can make the time slice really long or turn it off altogether.

If you want to do something repetitive at a fast rate then it is possible you are better off doing it from a timer interrupt, rather than a task, or using the peripheral interrupt to buffer data (preferably using a DMA) for minimum overhead.