From owner-freebsd-current@FreeBSD.ORG Wed Apr 13 13:40:52 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1F0DD16A4CE; Wed, 13 Apr 2005 13:40:52 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id CD1E043D54; Wed, 13 Apr 2005 13:40:51 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from [127.0.0.1] (davidxu@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j3DDel1D058887; Wed, 13 Apr 2005 13:40:49 GMT (envelope-from davidxu@freebsd.org) Message-ID: <425D2163.4090603@freebsd.org> Date: Wed, 13 Apr 2005 21:40:51 +0800 From: David Xu User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.7.5) Gecko/20050402 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Giorgos Keramidas References: <425CC7F8.3030803@samsco.org> <425CD009.6040208@freebsd.org> <20050413132603.GA39006@orion.daedalusnetworks.priv> In-Reply-To: <20050413132603.GA39006@orion.daedalusnetworks.priv> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-current@freebsd.org cc: Jiawei Ye Subject: Re: How does one know how many thread a process owns? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Apr 2005 13:40:52 -0000 Giorgos Keramidas wrote: >On 2005-04-13 17:15, Jiawei Ye wrote: > > >>On 4/13/05, David Xu 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. :-)