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.

A custom CPU load measurement

Other Parts Discussed in Thread: SYSBIOS

 

Hello,

I use a built-in feature in the TMS570 which give-me the exact number of instructions between 2 points (2 calls: start and end). It is called CPU performance.

I can use many of these channels to get multi-measurements in «parallel».

I want to use this feature in the BIOS to get a more precise measurement of my CPU load (and at run-time) for every thread.

My question:

Can I edit the kernel source code and where can I put these calls to have a measure for every thread?

Is there any hook that can I use?

Simon

CCS5.1, TMS570,  xdc 3.20.8.88

 

  • Simon,

    Yes, there is a task context switch hook you could use for this. SYS/BIOS uses this in the Load module to track "per task" CPU usage, accessed via Load_getTaskLoad(), so you could look at the source code for the Load module as an example. Otherwise, see the SYS/BIOS User's Guide, Sec. 3.5.5 (Task Hooks) and the Task module documentation.

    Mark

  • Hi Mark,

    I read before about hook functions but I did'nt find any benchmark about it.

    What overhead is added by using those functions ? Our system having high CPU usage, we have to take consideration of this overhead before using it.

    Marco.

     

  • Marco,

    We do not have an explicit benchmark that measures this, but perhaps looking at the code would be good enough? The typical pattern looks like:

    #ifndef ti_sysbios_knl_Task_DISABLE_ALL_HOOKS

                for (i = 0; i < Task_hooks.length; i++) {

                    if (Task_hooks.elem[i].switchFxn != NULL) {

                        Task_hooks.elem[i].switchFxn(prevTask, curTask);

                    }

                }

    #endif

    This is for the context switch function for Task (see packages/ti/sysbios/knl/Task.c). So, the overhead is basically the cost of a for-loop, if-test, and a function call. This varies with the ISA, but will still be relatively small compared to the overall cost of a context switch. For other hooks, the percentage overhead will be different, of course.
    Mark