Processor Load

Joel Sherrill joel.sherrill at OARcorp.com
Tue Sep 26 14:41:49 UTC 2000



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,
anything
based on a clock tick is not 100% accurate.  There are cases that cloud
things
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
N+2.

The code in cpuuse takes a simple approach.  Starting to execute is
recorded
as "1 tick".  Each time a clock tick occurs, the per task counter is
incremented.
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. 
Otherwise,
if a task completely executes between two clock ticks, it would have
been 
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
spent
executing.  

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



More information about the users mailing list