From owner-freebsd-current@FreeBSD.ORG Wed Apr 13 07:22:32 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 EDF3616A4CE for ; Wed, 13 Apr 2005 07:22:32 +0000 (GMT) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 48F1F43D4C for ; Wed, 13 Apr 2005 07:22:32 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [192.168.254.11] (junior-wifi.samsco.home [192.168.254.11]) (authenticated bits=0) by pooker.samsco.org (8.13.1/8.13.1) with ESMTP id j3D7PhDl042879; Wed, 13 Apr 2005 01:25:44 -0600 (MDT) (envelope-from scottl@samsco.org) Message-ID: <425CC7F8.3030803@samsco.org> Date: Wed, 13 Apr 2005 01:19:20 -0600 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.5) Gecko/20050218 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jiawei Ye References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=3.8 tests=ALL_TRUSTED autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on pooker.samsco.org cc: freebsd-current@freebsd.org 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 07:22:33 -0000 Jiawei Ye wrote: >>From top in pkgsrc, one can know that a certain process has some > number of LWP in it. > load averages: 1.89, 1.72, 1.68; up 119+05:28:10 13:30:48 > 154 processes: 152 sleeping, 1 running, 1 on cpu > CPU states: % idle, % user, % kernel, % iowait, % swap > Memory: 1024M real, 414M free, 841M swap in use, 1956M swap free > > PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND > 21891 bond 1 4 2 19M 1864K run 31.7H 77.04% upd_twd_15min > 17153 bond 1 50 2 82M 6164K sleep 37:37 12.98% dataserver.tsk > 17151 bond 1 53 2 82M 81M sleep 41:57 0.96% dataserver.tsk > 13742 otc 1 53 2 30M 21M sleep 3:31 0.89% dataserver.tsk > 17204 mtrs 1 53 2 82M 6144K sleep 2:47 0.67% dataserver.tsk > 17321 mtrs 1 53 2 25M 7908K sleep 2:21 0.49% otcmgr.tsk > 16250 root 1 59 0 4136K 2224K sleep 0:00 0.47% sshd > 13745 otc 1 53 2 30M 2496K sleep 2:55 0.36% dataserver.tsk > 3821 jessica 1 59 0 31M 4816K sleep 6:25 0.34% dataserver.tsk > 17227 bond 1 53 2 25M 7908K sleep 2:46 0.31% otcmgr.tsk > 17553 otc 1 53 2 17M 1208K sleep 0:46 0.18% icbc_pricing > 16269 leafy 1 45 0 3360K 1688K sleep 0:00 0.13% bash > 17202 mtrs 1 53 2 82M 19M sleep 1:08 0.12% dataserver.tsk > 17154 bond 1 53 2 82M 8004K sleep 0:35 0.12% dataserver.tsk > 13746 otc 1 53 2 30M 5136K sleep 0:37 0.11% dataserver.tsk > > In our top, show threads does not tell you how many threads exactly > exists in a process, is there any way to imitate the other top's > behaviour? > > Jiawei With KSE threads (the default libpthread.so library), the kernel doesn't know about all of the process-scope threads that are alive it only knows about the ones that are running currently or are blocked within the kernel. These are not the same as LWP, since they are scheduled in userland and thus are somewhat invisible to the kernel. There are various ways to set libpthread to create only process-scope threads that look a little more like LWP, or you can switch to the libthr.so library that exclusively creates 1:1 threads that are always visible to the kernel. Scott