Re: How to find the CPU usage of a process

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

 



Irfan Habib <[email protected]> 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

It is accounted in seconds in usermode and kernelmode (io processing), not
in slicess.

You can use the result wof wait3(2) if you are the parent:

/usr/bin/time -v sleep 3
        Command being timed: "sleep 3"
        User time (seconds): 0.00
        System time (seconds): 0.00
        Percent of CPU this job got: 0%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:03.00
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 0
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 175
        Voluntary context switches: 2
        Involuntary context switches: 0
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

You could maybe also use BSD Job Accounting.

At runtime, the /proc interface is for you. See libproc for the data you can
query. /usr/include/proc/readroc.h:

    utime,          // stat            user-mode CPU time accumulated by proces 
    stime,          // stat            kernel-mode CPU time accumulated by process

Gruss
Bernd
-
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/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux