Date: Wed, 13 Apr 2005 17:13:25 +0300 From: Giorgos Keramidas <keramida@freebsd.org> To: David Xu <davidxu@freebsd.org> Cc: Jiawei Ye <leafy7382@gmail.com> Subject: Re: How does one know how many thread a process owns? Message-ID: <20050413141325.GA40387@orion.daedalusnetworks.priv> In-Reply-To: <425D2163.4090603@freebsd.org> References: <c21e92e20504122232f568545@mail.gmail.com> <425CC7F8.3030803@samsco.org> <425CD009.6040208@freebsd.org> <c21e92e205041302152c9cbaaf@mail.gmail.com> <20050413132603.GA39006@orion.daedalusnetworks.priv> <425D2163.4090603@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2005-04-13 21:40, David Xu <davidxu@freebsd.org> wrote: >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 . :) >>> >>> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050413141325.GA40387>