Date: Wed, 20 Feb 2002 21:13:47 -0800 (PST) From: Matthew Dillon <dillon@apollo.backplane.com> To: John Baldwin <jhb@FreeBSD.org> Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: RE: cvs commit: src/bin/ps print.c Message-ID: <200202210513.g1L5DlS93001@apollo.backplane.com> References: <XFMail.020220234746.jhb@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
:> It's a lot easier to just have ps axl show it, since the wchan :> field is otherwise unused. Alternatively we could create a :> synthesize field 'mwchan' which replaces the default 'wchan' for :> ps output that does this combo. : :Sounds good to me. I actually did something like this for top. In top I had :all mutex names start with a * to differentiate them from wait channel names, :can you do a similar thing for mwchan? : :John Baldwin <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/ :"Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ Hmm. I don't think it's necessary, because the process state is 'M' if it's blocked in a mutex, and I think I'd rather have the field width. In anycase, here is the patch. I'll throw this into the tree tomorrow if there are no objections. The only potential problem I can see is that the header will now be 'MWCHAN' instead of 'WCHAN'. If that turns out to be a problem we could make the header print as 'WCHAN'. -Matt Matthew Dillon <dillon@backplane.com> Index: extern.h =================================================================== RCS file: /home/ncvs/src/bin/ps/extern.h,v retrieving revision 1.17 diff -u -r1.17 extern.h --- extern.h 3 Feb 2002 14:43:04 -0000 1.17 +++ extern.h 21 Feb 2002 05:02:51 -0000 @@ -77,5 +77,6 @@ int s_uname(KINFO *); void vsize(KINFO *, VARENT *); void wchan(KINFO *, VARENT *); +void mwchan(KINFO *, VARENT *); void lattr(KINFO *, VARENT *); __END_DECLS Index: keyword.c =================================================================== RCS file: /home/ncvs/src/bin/ps/keyword.c,v retrieving revision 1.37 diff -u -r1.37 keyword.c --- keyword.c 3 Feb 2002 14:43:04 -0000 1.37 +++ keyword.c 21 Feb 2002 05:10:49 -0000 @@ -119,6 +119,7 @@ LONG, "ld", 0}, {"mtxname", "MUTEX", NULL, LJUST, mtxname, NULL, 6, 0, CHAR, NULL, 0}, + {"mwchan", "MWCHAN", NULL, LJUST, mwchan, NULL, 6, 0, CHAR, NULL, 0}, {"ni", "", "nice", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, {"nice", "NI", NULL, 0, kvar, NULL, 2, KOFF(ki_nice), CHAR, "d", 0}, Index: print.c =================================================================== RCS file: /home/ncvs/src/bin/ps/print.c,v retrieving revision 1.57 diff -u -r1.57 print.c --- print.c 19 Feb 2002 00:05:56 -0000 1.57 +++ print.c 21 Feb 2002 05:03:13 -0000 @@ -409,6 +409,24 @@ else (void)printf("%-*lx", v->width, (long)k->ki_p->ki_wchan); + } else { + (void)printf("%-*s", v->width, "-"); + } +} + +void +mwchan(KINFO *k, VARENT *ve) +{ + VAR *v; + + v = ve->var; + if (k->ki_p->ki_wchan) { + if (k->ki_p->ki_wmesg[0] != 0) + (void)printf("%-*.*s", v->width, v->width, + k->ki_p->ki_wmesg); + else + (void)printf("%-*lx", v->width, + (long)k->ki_p->ki_wchan); } else if (k->ki_p->ki_kiflag & KI_MTXBLOCK) { (void)printf("%-*.*s", v->width, v->width, k->ki_p->ki_mtxname); } else { Index: ps.c =================================================================== RCS file: /home/ncvs/src/bin/ps/ps.c,v retrieving revision 1.48 diff -u -r1.48 ps.c --- ps.c 3 Feb 2002 14:43:04 -0000 1.48 +++ ps.c 21 Feb 2002 05:09:21 -0000 @@ -103,7 +103,7 @@ static char dfmt[] = "pid tt state time command"; static char jfmt[] = "user pid ppid pgid jobc state tt time command"; -static char lfmt[] = "uid pid ppid cpu pri nice vsz rss wchan state tt time command"; +static char lfmt[] = "uid pid ppid cpu pri nice vsz rss mwchan state tt time command"; static char o1[] = "pid"; static char o2[] = "tt state time command"; static char ufmt[] = "user pid %cpu %mem vsz rss tt state start time command"; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200202210513.g1L5DlS93001>