This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Measuring CPU utlization

Hello,

I wish to measure the CPU utlization for a cortex processor running an RTOS (keil RTX). Without an RTOS, i can measure the idle time to come to some conclusion. But with RTOS, can someone guide me how to measure CPU utlization?

Thanks & Best Regards
Vivek

Parents
  • vivek,

    Sorry I meant software variable acting just as counter.

    I use a software integer variable that I just increment in the idle loop for a known period, this period can be set by a timer interrupt. Say once a second - although the period doesn't matter much, as long as its relatively constant and the software variable counter doesn't overflow. Each period the software variable counter is reset to 0;

    If you measure the number that the software variable counter reaches when no tasks are running. This is the equivalent to 100% unused processor time during this period - lets call it max_counts

    Now once tasks are running the processor will spend less time in the idle loop and so the software variable counter will reach a lower number for the same timer period. Lets call this current_counts.

    So unused processor % during this period is given by

    unused_cpu_percentage=(current_counts*100)/max_counts

    and used processor % during this period is given by

    used_cpu_percentage=100-unused_cpu_percentage

    Hope that helps,

    Stuart

Reply
  • vivek,

    Sorry I meant software variable acting just as counter.

    I use a software integer variable that I just increment in the idle loop for a known period, this period can be set by a timer interrupt. Say once a second - although the period doesn't matter much, as long as its relatively constant and the software variable counter doesn't overflow. Each period the software variable counter is reset to 0;

    If you measure the number that the software variable counter reaches when no tasks are running. This is the equivalent to 100% unused processor time during this period - lets call it max_counts

    Now once tasks are running the processor will spend less time in the idle loop and so the software variable counter will reach a lower number for the same timer period. Lets call this current_counts.

    So unused processor % during this period is given by

    unused_cpu_percentage=(current_counts*100)/max_counts

    and used processor % during this period is given by

    used_cpu_percentage=100-unused_cpu_percentage

    Hope that helps,

    Stuart

Children