[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Processor Load

William Halliburton wrote:
>         Is there an easy way to get/calculate information on the amount of time the
> system is spending in user/system/idle?

See the code in libmisc/cpuuse.  It is 100% portable across all RTEMS
targets and
accurate to within a clock tick.  As mentioned by the numerous replies,
based on a clock tick is not 100% accurate.  There are cases that cloud
such as:

  + tasks that run less than a clock tick
  + tasks that start between ticks N and N+1 and end between N+1 and

The code in cpuuse takes a simple approach.  Starting to execute is
as "1 tick".  Each time a clock tick occurs, the per task counter is
This is a reasonably accurate after things run even a short while.  We
made the
decision that something had to be recorded each time a task executed. 
if a task completely executes between two clock ticks, it would have
recorded as 0.

The most accurate solution is to have a counter/time that is checked
each time
a task switch occurs.  Then the outgoing task is "charged" for the time

Again anything based on a clock tick is just an approximation.  It can
be accurate
enough though to make VERY good system analysis and tuning decisions.

If your application uses rate monotonic periods, the libmisc/rtmonuse
code is
fabulously useful for tuning applications. :)
>         Thank you,
>         William

Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985