From owner-freebsd-current@FreeBSD.ORG Wed Apr 13 14:13:28 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 B5F3416A4CE; Wed, 13 Apr 2005 14:13:28 +0000 (GMT) Received: from rosebud.otenet.gr (rosebud.otenet.gr [195.170.0.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id E0C7343D3F; Wed, 13 Apr 2005 14:13:27 +0000 (GMT) (envelope-from keramida@freebsd.org) Received: from orion.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226])j3DECQu4012511; Wed, 13 Apr 2005 17:12:26 +0300 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) j3DEDPw7040474; Wed, 13 Apr 2005 17:13:25 +0300 (EEST) (envelope-from keramida@freebsd.org) Received: (from keramida@localhost)j3DEDPPT040473; Wed, 13 Apr 2005 17:13:25 +0300 (EEST) (envelope-from keramida@freebsd.org) Date: Wed, 13 Apr 2005 17:13:25 +0300 From: Giorgos Keramidas To: David Xu Message-ID: <20050413141325.GA40387@orion.daedalusnetworks.priv> 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> 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 14:13:28 -0000 On 2005-04-13 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 . :) >>> >>> Exactly what I want. Is is possible to modify our top? >> >>Can you try the following patch? >>[snip] > > I am using the patch, it works fine, the screen output is attractive. :-) Would it be ok if I modified it to constantly display the THR column in process-mode, to avoid duplicating the large sprintf() part of format_next_process? I really dislike having to include virtually the same sprintf() block twice, just to change a single field. Constantly displaying THR, even when there are no multithreaded programs running on a system is not optimal either, but it's better IMO. Ideally, the displayed fields and their width could be dynamically adjustable, with contrib/top code formatting the displayed "screen" in a string buffer and using something like: struct top_field { int tf_enabled; int tf_width; int tf_precision; char *tf_fmt; char *tf_header; }; struct top_field top_fields[] = { { 1, 5, 0, "s", "PID", }, { 1, 8, 0, "s", "USERNAME", }, { 0, 5, 0, "ld", "UID", }, { 1, 3, 0, "ld", "PRI", } ... }; and the field formatting code could iterate through an array of fields, printing or ignoring some fields based on the current flags of top (thread mode, smp mode, etc), but this requires huge changes to the way contrib/top is written and I don't think I have so much time right now.