Skip to contentSkip to conversation

Cpu utilization per thread

DISCUSSION N Chandra Shekhar REDDY 3 participants 4 messages Jun 21, 2005 – Jun 23, 2005

lore
Share & tools
lore
#0 lore raw

Hi all,
Can any body tell me
How to find cpu utilization per thread excluding wait times and sleep times? Regards
ncs

#1 lore raw
Quoted 6 lines · N Chandra Shekhar REDDY

Hi all,
Can any body tell me
How to find cpu utilization per thread excluding wait times and sleep times? Regards
ncs

man getrusage.

Pay special attention to the RUSAGE_SELF or RUSAGE_CHILDREN flag, but I think current linux kernel does not perform a correct account for threads rusage in the parent. Probably you will have to account each thread, return info to the parent and sum or average (sum cpu times, average elapsed times...)

--
J.A. Magallon <jamagallon()able!es> \ Software is like sex:
werewolf!able!es \ It's better when it's free
Mandriva Linux release 2006.0 (Cooker) for i586
Linux 2.6.12-jam1 (gcc 4.0.1 (4.0.1-0.2mdk for Mandriva Linux release 2006.0))

#2 lore raw

Thanks for the reply.
I have tried with getrusage it is giving zero as the result.
I have found one more method(using setitimer(ITIMER_PROF,&enc_timer,NULL); and signal SIGPROF) which will give the user and system time of a process. Is it applicable for the thread?
Does this method give the expected results for thread?
--ncs

-----Original Message-----
From: J.A. Magallon [mailto:[email protected]]
Sent: Wednesday, June 22, 2005 7:01 AM
To: N Chandra Shekhar REDDY
Cc: [email protected]
Subject: Re: Cpu utilization per thread

Quoted 3 lines · N Chandra Shekhar REDDY

Hi all,
Can any body tell me
How to find cpu utilization per thread excluding wait times and sleep

times?

Quoted 3 lines

Regards
ncs

man getrusage.

Pay special attention to the RUSAGE_SELF or RUSAGE_CHILDREN flag, but I think current linux kernel does not perform a correct account for threads rusage in the parent. Probably you will have to account each thread, return info to the parent and sum or average (sum cpu times, average elapsed times...)

--
J.A. Magallon <jamagallon()able!es> \ Software is like
sex:
werewolf!able!es \ It's better when it's
free
Mandriva Linux release 2006.0 (Cooker) for i586
Linux 2.6.12-jam1 (gcc 4.0.1 (4.0.1-0.2mdk for Mandriva Linux release 2006.0))

#3 lore raw
In reply to N Chandra Shekhar REDDY
Quoted 5 lines · N Chandra Shekhar REDDY

Hi all,
Can any body tell me How to find cpu utilization per thread excluding wait times and sleep times? Regards
ncs

man 5 proc

The thread stuff is in the /proc/<pid>/tasks subdirectory but I think the status is process specific not thread specific.

--
Joe Seigh