Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Apr 2005 21:40:51 +0800
From:      David Xu <davidxu@freebsd.org>
To:        Giorgos Keramidas <keramida@freebsd.org>
Cc:        Jiawei Ye <leafy7382@gmail.com>
Subject:   Re: How does one know how many thread a process owns?
Message-ID:  <425D2163.4090603@freebsd.org>
In-Reply-To: <20050413132603.GA39006@orion.daedalusnetworks.priv>
References:  <c21e92e20504122232f568545@mail.gmail.com> <425CC7F8.3030803@samsco.org> <425CD009.6040208@freebsd.org> <c21e92e205041302152c9cbaaf@mail.gmail.com> <20050413132603.GA39006@orion.daedalusnetworks.priv>

next in thread | previous in thread | raw e-mail | index | archive | help
Giorgos Keramidas wrote:

>On 2005-04-13 17:15, Jiawei Ye <leafy7382@gmail.com> wrote:
>  
>
>>On 4/13/05, David Xu <davidxu@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. :-)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?425D2163.4090603>