summaryrefslogtreecommitdiffstats
path: root/contrib/top
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2011-05-31 15:11:23 +0000
committerjhb <jhb@FreeBSD.org>2011-05-31 15:11:23 +0000
commit3e43795a7a21a21ba53f04ea258e3e79a7a34e9d (patch)
tree8efe55a81b9744430f38ee8729ed55f893ffa78d /contrib/top
parent90dbe667c5ed0f8123234e0f8b196f31befc4cf7 (diff)
downloadFreeBSD-src-3e43795a7a21a21ba53f04ea258e3e79a7a34e9d.zip
FreeBSD-src-3e43795a7a21a21ba53f04ea258e3e79a7a34e9d.tar.gz
Add a new option to toggle the display of the system idle process (per-CPU
idle threads). The process is displayed by default (subject to whether or not system processes are displayed) to preserve existing behavior. The system idle process can be hidden via the '-z' command line argument or the 'z' key while top is running. When it is hidden, top more closely matches the behavior of FreeBSD <= 4.x where idle time was not accounted to any process. MFC after: 2 weeks
Diffstat (limited to 'contrib/top')
-rw-r--r--contrib/top/commands.c1
-rw-r--r--contrib/top/machine.h1
-rw-r--r--contrib/top/top.X8
-rw-r--r--contrib/top/top.c24
4 files changed, 27 insertions, 7 deletions
diff --git a/contrib/top/commands.c b/contrib/top/commands.c
index 47f4a2e..7891068 100644
--- a/contrib/top/commands.c
+++ b/contrib/top/commands.c
@@ -94,6 +94,7 @@ S - toggle the displaying of system processes\n\
a - toggle the displaying of process titles\n\
t - toggle the display of this process\n\
u - display processes for only one user (+ selects all users)\n\
+z - toggle the displaying of the system idle process\n\
\n\
\n", stdout);
}
diff --git a/contrib/top/machine.h b/contrib/top/machine.h
index a09424c..3e1af16 100644
--- a/contrib/top/machine.h
+++ b/contrib/top/machine.h
@@ -65,6 +65,7 @@ struct process_select
int uid; /* only this uid (unless uid == -1) */
int wcpu; /* show weighted cpu */
int jail; /* show jail ID */
+ int kidle; /* show per-CPU idle threads */
char *command; /* only this command (unless == NULL) */
};
diff --git a/contrib/top/top.X b/contrib/top/top.X
index 830e50d..b70ce7e 100644
--- a/contrib/top/top.X
+++ b/contrib/top/top.X
@@ -10,7 +10,7 @@ top \- display and update information about the top cpu processes
.SH SYNOPSIS
.B top
[
-.B \-abCHIijnPqStuv
+.B \-abCHIijnPqStuvz
] [
.BI \-d count
] [
@@ -142,6 +142,9 @@ Write version number information to stderr then exit immediately.
No other processing takes place when this option is used. To see current
revision information while top is running, use the help command \*(lq?\*(rq.
.TP
+.B \-z
+Do not display the system idle process.
+.TP
.BI \-d count
Show only
.I count
@@ -303,6 +306,9 @@ ID.
Toggle the display of the
.I top
process.
+.TP
+.B z
+Toggle the display of the system idle process.
.SH "THE DISPLAY"
The actual display varies depending on the specific variant of Unix
that the machine is running. This description may not exactly match
diff --git a/contrib/top/top.c b/contrib/top/top.c
index 762efaa..6673a27 100644
--- a/contrib/top/top.c
+++ b/contrib/top/top.c
@@ -196,9 +196,9 @@ char *argv[];
fd_set readfds;
#ifdef ORDER
- static char command_chars[] = "\f qh?en#sdkriIutHmSCajo";
+ static char command_chars[] = "\f qh?en#sdkriIutHmSCajzo";
#else
- static char command_chars[] = "\f qh?en#sdkriIutHmSCaj";
+ static char command_chars[] = "\f qh?en#sdkriIutHmSCajz";
#endif
/* these defines enumerate the "strchr"s of the commands in command_chars */
#define CMD_redraw 0
@@ -224,8 +224,9 @@ char *argv[];
#define CMD_wcputog 19
#define CMD_showargs 20
#define CMD_jidtog 21
+#define CMD_kidletog 22
#ifdef ORDER
-#define CMD_order 22
+#define CMD_order 23
#endif
/* set the buffer for stdout */
@@ -258,6 +259,7 @@ char *argv[];
ps.thread = No;
ps.wcpu = 1;
ps.jail = No;
+ ps.kidle = Yes;
ps.command = NULL;
/* get preset options from the environment */
@@ -283,7 +285,7 @@ char *argv[];
optind = 1;
}
- while ((i = getopt(ac, av, "CSIHPabijnquvs:d:U:m:o:t")) != EOF)
+ while ((i = getopt(ac, av, "CSIHPabijnquvzs:d:U:m:o:t")) != EOF)
{
switch(i)
{
@@ -412,10 +414,14 @@ char *argv[];
pcpu_stats = Yes;
break;
+ case 'z':
+ ps.kidle = !ps.kidle;
+ break;
+
default:
fprintf(stderr,
"Top version %s\n"
-"Usage: %s [-abCHIijnPqStuv] [-d count] [-m io | cpu] [-o field] [-s time]\n"
+"Usage: %s [-abCHIijnPqStuvz] [-d count] [-m io | cpu] [-o field] [-s time]\n"
" [-U username] [number]\n",
version_string(), myname);
exit(1);
@@ -1075,7 +1081,13 @@ restart:
reset_display();
putchar('\r');
break;
-
+ case CMD_kidletog:
+ ps.kidle = !ps.kidle;
+ new_message(MT_standout | MT_delayed,
+ " %sisplaying system idle process.",
+ ps.kidle ? "D" : "Not d");
+ putchar('\r');
+ break;
default:
new_message(MT_standout, " BAD CASE IN SWITCH!");
putchar('\r');
OpenPOWER on IntegriCloud