This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Free RTOS Task CPU usage monitoring

Hello all,
I have been reading through the rtos manual and am interested in tracking the time (whether in seconds (or sub seconds) or in ticks) that each task is in the ready/running state. In other words I would like to track the cpu usage that each task takes up. I realize that there are inherent functions in the RTOS that will allow such troubleshooting to be done. The vTaskGetRunTimeStats() looks like a promising direction to take. I have two questions for those with more embedded software design experience. Firstly, what is the best way to track the task cpu time allocation? Secondly, where would you implement such a function as vTaskGetRunTimeStats()? I am using the Ez430 Rf2560 sdk with IAR. Thanks in advance for the advice...

~MJ

  • The place where to put time-measurement code would be the task scheduler. Only there is known when a task is executed. CPU control is move to the task and returns to the scheduler when the task has exedded its time-slice, is waiting for a resource or goes to sleep. However, time spend inside ISRs needs to be measured inside the ISRs and subtracted, as the scheduler doesn't know when the task is interrupted by an interrupt other than the schedulers own interrupt.
    However, you'll need a ratehr high-frequency counter to get any useful result resolution.

    But I don't have any knowledge about your RTOS, so I don't know how much of this is already available. This is not a question generic to mbedded programming, it is rather a problem generic to multitasking OS programming. And the basic ideas are more or less the same for PCs and embedded systems (well, some 'embedded systems' actually use PCs, so it's better to talk about 'microcontroller programming')

  • Jens-Michael,

    Thanks for the advice. I guess where I am failing is to really understand the organization of the 50 plus file sdk. I am new to real time operating systems and as such am trying to wade through the enormous amount of api's available with FreeRTOS. The sdk has so much shoved into it for possible application development where both bluetooth and freeRtos functions are wrapped in sdk_() functions which may make it easier for those with bluetooth and real time operating system experience but has created quite daunting a task to figure out whats really going on if you're a novice. For my project I really need very little in order to read the accelerometer and send raw data continuously, which I have been able to figure out. At this point I just want to make sure rtos task structure is fast enough to sample reliable accelerometer data for signal reconstruction, or in other words try to find the sweet spot between payload size and task cpu timing. Anyway , where is the scheduler and task code located so that I can insert the previously mentioned get resource function? Thanks in advance. 

  • Links that might be useful:

    http://www.freertos.org/rtos-run-time-stats.html

    http://www.freertos.org/trace (may not be suitable for MSP430).

    Which SDK has FreeRTOS in it?

  • Mark Joseph said:
    I guess where I am failing is to really understand the organization of the 50 plus file sdk.

    Well, understanding a complete OS (or at least its API) is a huge task. Best approach is to switch everythign off, then enable one functionality at a time while reading through its documentation.

    I have the advantage that I built my own RTOS - only the parts I needed so far for projects. So while it might be not as well documented as it could be (I try, but fast results are usually more pressing than a good documentation), I already know how to ise it because I did concept and coding myself. :)

    But I have no idea about the inner workings of any other RTOS for MSP. So I can't help you there.

  • Which OS are we talking about here?  I thought it was FreeRTOS - which has 3 core files, plus one or two portable layer files?

  • the ez430-rf2560 sdk from TI

**Attention** This is a public forum