2006-02-18 17:42:30

by Irfan Habib

[permalink] [raw]
Subject: How to find the CPU usage of a process

Hi,

I'm a research student, working on self-organizing
grids.
I wanted to ask how can I find the cpu usage of a
process, as opposed to runtime, with cpu usage I mean
actually how many time slices were awarded to a
specific process, like the runtime of job may be 4 s,
but this also includes time it was suspended by some
interrupt, or had to wait for the scheduler etc..

What is the easiest way to do that? is their any
userlevel tool for it?
Thanks in advance

Irfan Habib

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


2006-02-19 19:06:44

by Chris Wedgwood

[permalink] [raw]
Subject: Re: How to find the CPU usage of a process

On Sat, Feb 18, 2006 at 09:42:29AM -0800, Irfan Habib wrote:

> I wanted to ask how can I find the cpu usage of a process, as
> opposed to runtime, with cpu usage I mean actually how many time
> slices were awarded to a specific process, like the runtime of job
> may be 4 s, but this also includes time it was suspended by some
> interrupt, or had to wait for the scheduler etc..

getrusage(2) or if it's not a child then grovel through /proc (i think
there is an argument for a better interface)

2006-02-20 00:42:17

by Irfan Habib

[permalink] [raw]
Subject: Re: How to find the CPU usage of a process

thank you very much for every one who replied.
It really helped me big times :)

On 2/20/06, Chris Wedgwood <[email protected]> wrote:
> On Sat, Feb 18, 2006 at 09:42:29AM -0800, Irfan Habib wrote:
>
> > I wanted to ask how can I find the cpu usage of a process, as
> > opposed to runtime, with cpu usage I mean actually how many time
> > slices were awarded to a specific process, like the runtime of job
> > may be 4 s, but this also includes time it was suspended by some
> > interrupt, or had to wait for the scheduler etc..
>
> getrusage(2) or if it's not a child then grovel through /proc (i think
> there is an argument for a better interface)
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>