Measuring CPU Idle time

  • Follow


Hi group,

How can I measure the CPU idle time ? Does it make sense to measure it
per process ?

Can anyone tell me how to do it programatically using system calls
(else I need to resort to system and sar).

Thanks.

P.S. - I am on Redhat Linux 7.3

0
Reply km_jr_usenet (66) 3/1/2005 9:52:41 AM

Kelvin Moss <km_jr_usenet@yahoo.com> wrote:
>How can I measure the CPU idle time?

The answer is system-specific, and depends a LOT on why you want this
information.  Most apps are better off not trying to mess with changing
themselves based on CPU info, but you probably know that.

>Does it make sense to measure it per process ?

Explain what you mean by this.  Why would you need to?

>Can anyone tell me how to do it programatically using system calls
>(else I need to resort to system and sar).
>P.S. - I am on Redhat Linux 7.3

Easier than system calls will be to read files in /proc.  /proc/stat is likely
the best place to start.
--
Mark Rafn    dagon@dagon.net    <http://www.dagon.net/>  
0
Reply dagon 3/1/2005 2:08:00 PM



Kelvin Moss wrote:
> Hi group,
> 
> How can I measure the CPU idle time ? Does it make sense to measure it
> per process ?

    I can't think of a per-process measurement that would
make much sense.  Suppose Algernon, Basil, and Cuthbert
share a pizza: Algernon eats one slice, Basil eats two,
Cuthbert eats three, and two slices remain uneaten.  How
many slices are "uneaten" by each of the three friends?

    In a one-minute interval, fifty automobiles drive
across Big Bridge.  Traffic engineers calculate that Big
Bridge can handle seventy automobiles per minute.  How
much of the unused capacity is your Humvee responsible for?

    A 50000-seat arena hosts the Stupor Bowl, but only
49000 fans turn up.  The seat just in front of you is one
of the empties; is its emptiness attributable to you, or
to the group of six drunken louts beside you?

-- 
Eric.Sosman@sun.com

0
Reply Eric 3/1/2005 4:26:45 PM

"Kelvin Moss" <km_jr_usenet@yahoo.com> wrote in message 
news:1109670761.691172.39370@o13g2000cwo.googlegroups.com...

> How can I measure the CPU idle time ?

    /proc/stat

> Does it make sense to measure it
> per process ?

    I don't think so.

> Can anyone tell me how to do it programatically using system calls
> (else I need to resort to system and sar).

    Read the man page for 'proc'. The /proc/stat file has the information 
you are looking for, I think.

    What exactly are you trying to do?

    DS


0
Reply David 3/1/2005 10:04:55 PM

David Schwartz wrote:


>     What exactly are you trying to do?

For SNMP statistics, we need to report the CPU Idle time after each
process completes its work in our requirements. It did not make sense
to me as to how we could measure it per process. From the replies I
have got, I conclude that it doesn't make sense per process and I can
get overall CPU idle time from /proc/stat file.

Thanks, everyone, for the replies.

0
Reply Kelvin 3/2/2005 5:07:08 AM

Kelvin Moss wrote:
> Hi group,
>
> How can I measure the CPU idle time ? Does it make sense to measure
it
> per process ?
>
  You can measure per process CPU idle time :), but you need to write
your own.
  Try implementing a watchdog timer (s/w) for all the pid entries in
/proc
  by having a data structure with the things you need.
  Then finally having a display function to show the processes cpu you
could
  display all entries as in /proc at that moment.

- Roopa

> Can anyone tell me how to do it programatically using system calls
> (else I need to resort to system and sar).
> 
> Thanks.
> 
> P.S. - I am on Redhat Linux 7.3

0
Reply Roopa 3/2/2005 6:01:43 AM

5 Replies
410 Views

(page loaded in 0.088 seconds)

Similiar Articles:













7/26/2012 2:11:55 PM


Reply: