diff options
author | julian <julian@FreeBSD.org> | 2003-07-17 23:56:40 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 2003-07-17 23:56:40 +0000 |
commit | 788547d4cf2856cc0d849f205d6384723345026b (patch) | |
tree | ae7325b9fe8cfe61e176452c39b5dd2b7846c026 | |
parent | ab57004058eee4b698f7d9cece99440ad9b49bbb (diff) | |
download | FreeBSD-src-788547d4cf2856cc0d849f205d6384723345026b.zip FreeBSD-src-788547d4cf2856cc0d849f205d6384723345026b.tar.gz |
Changes to allow top to decide whether or not to show multiple threads per
process. Option -H enables it and it is toggled at the interactive
screen by 'H'.
Submitted by: Jung-uk Kim <jkim@niksun.com>
-rw-r--r-- | contrib/top/commands.c | 1 | ||||
-rw-r--r-- | contrib/top/machine.h | 1 | ||||
-rw-r--r-- | contrib/top/top.c | 23 | ||||
-rw-r--r-- | usr.bin/top/machine.c | 3 | ||||
-rw-r--r-- | usr.bin/top/top.local.1 | 5 |
5 files changed, 27 insertions, 6 deletions
diff --git a/contrib/top/commands.c b/contrib/top/commands.c index 6af378bc..418dc16 100644 --- a/contrib/top/commands.c +++ b/contrib/top/commands.c @@ -71,6 +71,7 @@ sophisticated enough to handle those commands gracefully.\n\n", stdout); d - change number of displays to show\n\ e - list errors generated by last \"kill\" or \"renice\" command\n\ i - toggle the displaying of idle processes\n\ +H - toggle the displaying of threads\n\ I - same as 'i'\n\ k - kill processes; send a signal to a list of processes\n\ n or # - change number of processes to display\n", stdout); diff --git a/contrib/top/machine.h b/contrib/top/machine.h index 4f4f6af..62b321c 100644 --- a/contrib/top/machine.h +++ b/contrib/top/machine.h @@ -59,6 +59,7 @@ struct process_select 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) */ }; diff --git a/contrib/top/top.c b/contrib/top/top.c index 1b88041..5d30e66 100644 --- a/contrib/top/top.c +++ b/contrib/top/top.c @@ -192,9 +192,9 @@ char *argv[]; 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 @@ char *argv[]; #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 @@ char *argv[]; ps.self = -1; ps.system = No; ps.uid = -1; + ps.thread = No; ps.command = NULL; /* get preset options from the environment */ @@ -270,7 +272,7 @@ char *argv[]; 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) { @@ -365,10 +367,14 @@ char *argv[]; 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,13 @@ restart: } 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, diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index fd5a993..c998081 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -414,7 +414,8 @@ int (*compare)(); 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)); diff --git a/usr.bin/top/top.local.1 b/usr.bin/top/top.local.1 index 6033b29..75489b7 100644 --- a/usr.bin/top/top.local.1 +++ b/usr.bin/top/top.local.1 @@ -1,5 +1,10 @@ +.\" $FreeBSD$ .SH "FreeBSD NOTES" +.SH DISPLAY OF THREADS +The '-H' option will toggle the display of kernel visible thread contexts. +At runtime the 'H' key will toggle this mode. The default is OFF. + .SH DESCRIPTION OF MEMORY Mem: 9220K Active, 1032K Inact, 3284K Wired, 1MB Cache, 2M Buf, 1320K Free Swap: 91M Total, 79M Free, 13% Inuse, 80K In, 104 K Out |