Re: How does one know how many thread a process owns?

From: David Xu <davidxu_at_freebsd.org>
Date: Wed, 13 Apr 2005 21:40:51 +0800
Giorgos Keramidas wrote:

>On 2005-04-13 17:15, Jiawei Ye <leafy7382_at_gmail.com> wrote:
>  
>
>>On 4/13/05, David Xu <davidxu_at_freebsd.org> wrote:
>>    
>>
>>>I believe he wants to see total threads number in a process. add a column
>>>to top to display total kernel threads in per-process, p_numthreads in proc
>>>structure is what you need . :)
>>>
>>>David Xu
>>>      
>>>
>>Exactly what I want. Is is possible to modify our top?
>>    
>>
>
>Can you try the following patch?
>
>I've added a THR column when top displays only one line per process.
>So when the "display each thread separately" mode is off, you should see
>something like this:
>
>% last pid: 39064;  load averages:  0.08,  0.05,  0.32     up 0+02:00:58  16:22:00
>% 69 processes:  1 running, 65 sleeping, 3 stopped
>% CPU states:     % user,     % nice,     % system,     % interrupt,     % idle
>% Mem: 117M Active, 211M Inact, 77M Wired, 14M Cache, 54M Buf, 11M Free
>% Swap: 1535M Total, 4K Used, 1535M Free
>%
>%   PID USERNAME THR PRI NICE   SIZE    RES STATE    TIME   WCPU    CPU COMMAND
>%   662 keramida   1  96    0 84584K 29864K select   1:08  0.00%  0.00% Xorg
>% 16554 keramida   4  20    0 50136K 38240K kserel   0:40  0.00%  0.00% mozilla-bin
>%   700 keramida   1  96    0  6012K  4440K select   0:25  0.00%  0.00% xterm-static
>%   711 root       1  96    0  3368K  2864K select   0:13  0.00%  0.00% screen
>%   718 keramida   1  96    0  5348K  3772K select   0:10  0.00%  0.00% xterm-static
>%   691 keramida   1  96    0  6896K  4920K select   0:09  0.00%  0.00% wmaker
>
>The sprintf() calls near the end of format_next_process() are duplicated,
>which is ugly as hell, but I couldn't find a good way to avoid the code
>duplication.  If people don't have a problem with constantly displaying this
>column, even when no threads are used, this will be even easier to do without
>the extra clutter.  Then, we can add a sort function to order by number of
>threads and then I think we're pretty much done :-)
>  
>
I am using the patch, it works fine, the screen output is attractive. :-)
Received on Wed Apr 13 2005 - 11:40:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:32 UTC