From owner-freebsd-threads@FreeBSD.ORG Thu Jul 17 13:59:31 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1017037B401 for ; Thu, 17 Jul 2003 13:59:31 -0700 (PDT) Received: from anuket.mj.niksun.com (gwnew.niksun.com [65.115.46.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3969D43F93 for ; Thu, 17 Jul 2003 13:59:30 -0700 (PDT) (envelope-from jkim@niksun.com) Received: from daemon.mj.niksun.com (daemon.mj.niksun.com [10.70.0.244]) h6HKwglT082177; Thu, 17 Jul 2003 16:58:43 -0400 (EDT) (envelope-from jkim@niksun.com) X-RAV-AntiVirus: This e-mail has been scanned for viruses. From: Jung-uk Kim Organization: Niksun, Inc. To: freebsd-threads@freebsd.org Date: Thu, 17 Jul 2003 16:58:40 -0400 User-Agent: KMail/1.5.1 References: <003401c34bc5$104dcac0$0400a8c0@dread> <200307171545.18232.jkim@niksun.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200307171658.40674.jkim@niksun.com> cc: Kai Mosebach Subject: Re: [PATCH] Re: Threads in top X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jul 2003 20:59:31 -0000 This is revised version of the patch. The previous version was made in haste. It's actually one-line-style-change(TM) and functionally the same. ;-) Anyway, can anybody edit man page for this change, i.e., src/usr.bin/top/top.local.1? I am a terrible doc writer. Thanks, Jung-uk Kim --- src/contrib/top/commands.c Thu Jan 24 12:52:26 2002 +++ src/contrib/top.new/commands.c Thu Jul 17 15:02:32 2003 @@ -70,6 +70,7 @@ fputs("\ d - change number of displays to show\n\ e - list errors generated by last \"kill\" or \"renice\" command\n\ +H - toggle the displaying of threads\n\ i - toggle the displaying of idle processes\n\ I - same as 'i'\n\ k - kill processes; send a signal to a list of processes\n\ --- src/contrib/top/machine.h Thu Jan 24 12:58:42 2002 +++ src/contrib/top.new/machine.h Thu Jul 17 14:48:19 2003 @@ -59,6 +59,7 @@ int idle; /* show idle processes */ int self; /* show self */ int system; /* show system processes */ + int thread; /* show threads */ int uid; /* only this uid (unless uid == -1) */ char *command; /* only this command (unless == NULL) */ }; --- src/contrib/top/top.c Thu Jan 24 12:55:40 2002 +++ src/contrib/top.new/top.c Thu Jul 17 15:04:42 2003 @@ -192,9 +192,9 @@ fd_set readfds; #ifdef ORDER - static char command_chars[] = "\f qh?en#sdkriIuto"; + static char command_chars[] = "\f qh?en#sdkriIutHo"; #else - static char command_chars[] = "\f qh?en#sdkriIut"; + static char command_chars[] = "\f qh?en#sdkriIutH"; #endif /* these defines enumerate the "strchr"s of the commands in command_chars */ #define CMD_redraw 0 @@ -214,8 +214,9 @@ #define CMD_idletog2 13 #define CMD_user 14 #define CMD_selftog 15 +#define CMD_thrtog 16 #ifdef ORDER -#define CMD_order 16 +#define CMD_order 17 #endif /* set the buffer for stdout */ @@ -245,6 +246,7 @@ ps.self = -1; ps.system = No; ps.uid = -1; + ps.thread = Yes; ps.command = NULL; /* get preset options from the environment */ @@ -270,7 +272,7 @@ optind = 1; } - while ((i = getopt(ac, av, "SIbinquvs:d:U:o:t")) != EOF) + while ((i = getopt(ac, av, "SIHbinquvs:d:U:o:t")) != EOF) { switch(i) { @@ -364,11 +366,15 @@ case 't': ps.self = (ps.self == -1) ? getpid() : -1; break; - + + case 'H': + ps.thread = !ps.thread; + break; + default: fprintf(stderr, "\ Top version %s\n\ -Usage: %s [-ISbinqut] [-d x] [-s x] [-o field] [-U username] [number]\n", +Usage: %s [-HISbinqut] [-d x] [-s x] [-o field] [-U username] [number]\n", version_string(), myname); exit(1); } @@ -955,6 +961,14 @@ } break; + case CMD_thrtog: + ps.thread = !ps.thread; + new_message(MT_standout | MT_delayed, + " %sisplaying threads.", + ps.thread ? "D" : "Not d"); + putchar('\r'); + break; + #ifdef ORDER case CMD_order: new_message(MT_standout, @@ -979,7 +993,7 @@ } break; #endif - + default: new_message(MT_standout, " BAD CASE IN SWITCH!"); putchar('\r'); --- src/usr.bin/top/machine.c Sun Feb 16 09:09:52 2003 +++ src/usr.bin/top.new/machine.c Thu Jul 17 14:56:13 2003 @@ -414,7 +414,8 @@ int show_command; - pbase = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nproc); + pbase = kvm_getprocs(kd, sel->thread ? KERN_PROC_ALL : KERN_PROC_PROC, 0, + &nproc); if (nproc > onproc) pref = (struct kinfo_proc **) realloc(pref, sizeof(struct kinfo_proc *) * (onproc = nproc));