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.

To read out CPU load from source code

Other Parts Discussed in Thread: SYSBIOS

Hi Champs,

I added the load module to the project. Now I want to read out during runtime. What is the best code to do so?

Is the following something you would recommend? It's from wiki SMP CPU Load.

Any other example you would refer to?

Measure the idle task load on each core and subtract it from 100. This will give the CPU Load on a given core.

    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/utils/Load.h>
    #include <xdc/runtime/System.h>
 
    func() {
        UInt load;
        Load_stat stat;
        Task_Handle idlTskHandle;
 
        idleTskHandle = Task_getIdleTaskHandle(coreId);
        Load_getTaskLoad(idlTskHandle, &stat);
        load = Load_calculateLoad(&stat);
        System_printf("Load = %d\n", (100-load));
    }

  • Hi Thorsten,

    What device are you using, and are you using SMP support?

    I searched a bit and didn’t find any detailed example code using the Load module to point you to.

    But there is description of the Load module in the SYS/BIOS User’s Guide, and in the online documentation (in the ‘docs’ subdirectory of the SYS/BIOS installation, click on Bios_APIs.html and navigate to the ti.sysbios.utils.Load description).  Have you seen those descriptions?

    Also, have you tried what is shown in the example snippet shown on the wiki?

    Thanks,
    Scott

  • Hi Scott,
    I use the IPU0 M4 core of the TDA2x Vayu device. I don't use SMP. Just single core BIOs.
    Thanks for the link. Yes I found the description. I'll try the code snippet.
    So this is what we may have to describe the use right?

    1. The link to the doc "ti.sysbios.utils.load"
    2. The code snippet

    Thank you
  • Hi Thorsten,

    Yes, that is the right documentation.  Let me know if you have any issues…

    Regards,
    Scott