Re: Getting some information inside task_struct from a user application?

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

 



Hi,

Le Thu, 20 Jul 2006 19:36:37 +0800,
"Hsin-An Chen@NTHU" <g946301@xxxxxxxxxxxxxx> a écrit :

> I am doing some timing analysis in kernel 2.6.15.
> I want to collect the 'utime' and 'stime' information inside
> task_struct from a user space application.

What about using:

 $ time your_command

 ?

It gives an output such as:

0.00user 0.00system 0:00.04elapsed 11%CPU
(0avgtext+0avgdata0maxresident)k 
0inputs+0outputs (1major+263minor)pagefaults 0swaps

Or if you don't want to do it from the shell, you can use the times(2)
function.

$ man 2 times
[...]
NAME
       times - get process times
[...]
DESCRIPTION
       The  times()  function  stores  the  current  process  times in
       the struct tms that buf points to.  The struct tms is as defined
       in <sys/times.h>:

       struct tms {
              clock_t tms_utime;  /* user time */
              clock_t tms_stime;  /* system time */
              clock_t tms_cutime; /* user time of dead children */
              clock_t tms_cstime; /* system time of dead children */
       };

       The tms_utime field contains the CPU time spent executing
       instructions of the calling process.  The tms_stime field con-
       tains the  CPU  time  spent in the system while executing tasks
       on behalf of the calling process.  The tms_cutime field contains
       the sum of the tms_utime and tms_cutime values for all waited-for
       terminated children.   The  tms_cstime  field contains the sum of
       the tms_stime and tms_cstime values for all waited-for
       terminated children.
[...]

Sincerly,

Thomas
-- 
Thomas Petazzoni - thomas.petazzoni@xxxxxxxx
http://{thomas,sos,kos}.enix.org - http://www.toulibre.org
http://www.{livret,agenda}dulibre.org

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux