From owner-freebsd-current@FreeBSD.ORG Wed Apr 13 14:08:41 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 6DACA16A4CE; Wed, 13 Apr 2005 14:08:41 +0000 (GMT) Received: from renaissance.homeip.net (m197.net81-67-151.noos.fr [81.67.151.197]) by mx1.FreeBSD.org (Postfix) with ESMTP id 57DB143D46; Wed, 13 Apr 2005 14:08:40 +0000 (GMT) (envelope-from anthony.ginepro@laposte.net) Received: from renaissance.homeip.net (localhost [127.0.0.1]) by renaissance.homeip.net (Postfix) with ESMTP id 3358821F4; Wed, 13 Apr 2005 16:08:39 +0200 (CEST) Received: (from rapiere@localhost) by renaissance.homeip.net (8.13.3/8.13.1/Submit) id j3DE8crq077228; Wed, 13 Apr 2005 16:08:38 +0200 (CEST) (envelope-from anthony.ginepro@laposte.net) X-Authentication-Warning: renaissance.homeip.net: rapiere set sender to anthony.ginepro@laposte.net using -f Date: Wed, 13 Apr 2005 16:08:38 +0200 From: Anthony Ginepro To: David Xu Message-ID: <20050413140838.GA77217@renaissance.homeip.net> References: <425CC7F8.3030803@samsco.org> <425CD009.6040208@freebsd.org> <20050413132603.GA39006@orion.daedalusnetworks.priv> <425D2163.4090603@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <425D2163.4090603@freebsd.org> X-Operating-System: FreeBSD 5.4-STABLE i386 User-Agent: Mutt/1.5.9i cc: freebsd-current@freebsd.org cc: Giorgos Keramidas 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 14:08:41 -0000 On 04/13/05 21:40, David Xu wrote: > 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. :-) Except for WCPU it looks like SunOS' top.