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>
This commit is contained in:
julian 2003-07-17 23:56:40 +00:00
parent ab57004058
commit 788547d4cf
5 changed files with 27 additions and 6 deletions

View File

@ -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);

View File

@ -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) */
};

View File

@ -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,

View File

@ -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));

View File

@ -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