Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jul 2003 15:55:01 -0400
From:      Jung-uk Kim <jkim@niksun.com>
To:        Jeremy Messenger <mezz7@cox.net>
Cc:        freebsd-threads@freebsd.org
Subject:   Re: [PATCH] Re: Threads in top
Message-ID:  <200307171555.01584.jkim@niksun.com>
In-Reply-To: <oprsgzz1sb8ckrg5@smtp.central.cox.net>
References:  <003401c34bc5$104dcac0$0400a8c0@dread> <200307171545.18232.jkim@niksun.com> <oprsgzz1sb8ckrg5@smtp.central.cox.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 17 July 2003 03:49 pm, Jeremy Messenger wrote:
> On Thu, 17 Jul 2003 15:45:18 -0400, Jung-uk Kim <jkim@niksun.com> wrote:
> > The patch adds command line option "-H" and interactive command
> > "H".
>
> I think, you have forgotten to attach your patch. ;-)

I haven't. :-/ Mailman is always cutting my attachment.  This time I
inlined it.  Sorry for the inconvenience.

Jung-uk Kim

> Cheers,
> Mezz
>
> > Enjoy,
> >
> > Jung-uk Kim
> >
> > On Thursday 17 July 2003 01:49 am, Terry Lambert wrote:
> >> Kai Mosebach wrote:
> >> > is it somehow possible to hide the threads in top / only see
> >> > the master process ?
> >>
> >> The ps program does this by not showing threads unless invoked
> >> with the "-H" option.  Probably someone who wants to hide the
> >> threads in top (hint hint) should do what ps does in order to
> >> make top act the same way (Darwin uses "-M" instead of "-H",
> >> but FreeBSD uses this for system dump image files).
> >>
> >> FWIW, the implementation detail is that everything is returned,
> >> and the filtering occurs on display.
> >>
> >> -- Terry
------ 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,10 @@
     int show_command;
 
     
-    pbase = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nproc);
+    if (sel->thread)
+	pbase = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nproc);
+    else
+	pbase = kvm_getprocs(kd, KERN_PROC_PROC, 0, &nproc);
     if (nproc > onproc)
 	pref = (struct kinfo_proc **) realloc(pref, sizeof(struct kinfo_proc *)
 		* (onproc = nproc));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200307171555.01584.jkim>