How does one know how many thread a process owns?
Anthony Ginepro
anthony.ginepro at laposte.net
Wed Apr 13 07:08:41 PDT 2005
On 04/13/05 21:40, David Xu wrote:
> Giorgos Keramidas wrote:
>
> >On 2005-04-13 17:15, Jiawei Ye <leafy7382 at gmail.com> wrote:
> >
> >
> >>On 4/13/05, David Xu <davidxu at 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 . :)
> >>>
> >>>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.
More information about the freebsd-current
mailing list