diff options
author | keramida <keramida@FreeBSD.org> | 2005-05-18 13:30:08 +0000 |
---|---|---|
committer | keramida <keramida@FreeBSD.org> | 2005-05-18 13:30:08 +0000 |
commit | 0f9725e09b1113e803b8655641b23fbe9c5e7719 (patch) | |
tree | 42f2b2a54bba39dc0ab8b8514eefae075556a375 /contrib/top | |
parent | 4bf80fbbcff1c8b9d5088dd0d5195293ee0f09da (diff) | |
download | FreeBSD-src-0f9725e09b1113e803b8655641b23fbe9c5e7719.zip FreeBSD-src-0f9725e09b1113e803b8655641b23fbe9c5e7719.tar.gz |
Merge the CPU and WCPU columns in a single %6.2f column, add a new 'C'
command that toggles between the two and update the ORDER_PCTCPU()
macro to sort correctly by the visible "cpu" value.
This saves 6 more columns in 80-column terminals, making things a lot
better for the COMMAND column.
Tested on: i386, sparc64 (panther), amd64 (sledge)
Approved by: davidxu (in principle)
Diffstat (limited to 'contrib/top')
-rw-r--r-- | contrib/top/commands.c | 1 | ||||
-rw-r--r-- | contrib/top/machine.h | 1 | ||||
-rw-r--r-- | contrib/top/top.c | 29 |
3 files changed, 24 insertions, 7 deletions
diff --git a/contrib/top/commands.c b/contrib/top/commands.c index 8d7f331..200f0cc 100644 --- a/contrib/top/commands.c +++ b/contrib/top/commands.c @@ -68,6 +68,7 @@ sophisticated enough to handle those commands gracefully.\n\n", stdout); else { fputs("\ +C - toggle the displaying of weighted CPU percentage\n\ d - change number of displays to show\n\ e - list errors generated by last \"kill\" or \"renice\" command\n\ i or I - toggle the displaying of idle processes\n\ diff --git a/contrib/top/machine.h b/contrib/top/machine.h index 62b321c..17e48cd 100644 --- a/contrib/top/machine.h +++ b/contrib/top/machine.h @@ -61,6 +61,7 @@ struct process_select int system; /* show system processes */ int thread; /* show threads */ int uid; /* only this uid (unless uid == -1) */ + int wcpu; /* show weighted cpu */ char *command; /* only this command (unless == NULL) */ }; diff --git a/contrib/top/top.c b/contrib/top/top.c index 2f7fa2f..00acd85 100644 --- a/contrib/top/top.c +++ b/contrib/top/top.c @@ -193,9 +193,9 @@ char *argv[]; fd_set readfds; #ifdef ORDER - static char command_chars[] = "\f qh?en#sdkriIutHmSo"; + static char command_chars[] = "\f qh?en#sdkriIutHmSCo"; #else - static char command_chars[] = "\f qh?en#sdkriIutHmS"; + static char command_chars[] = "\f qh?en#sdkriIutHmSC"; #endif /* these defines enumerate the "strchr"s of the commands in command_chars */ #define CMD_redraw 0 @@ -218,8 +218,9 @@ char *argv[]; #define CMD_thrtog 16 #define CMD_viewtog 17 #define CMD_viewsys 18 +#define CMD_wcputog 19 #ifdef ORDER -#define CMD_order 19 +#define CMD_order 20 #endif /* set the buffer for stdout */ @@ -250,6 +251,7 @@ char *argv[]; ps.system = No; ps.uid = -1; ps.thread = No; + ps.wcpu = 1; ps.command = NULL; /* get preset options from the environment */ @@ -275,7 +277,7 @@ char *argv[]; optind = 1; } - while ((i = getopt(ac, av, "SIHbinquvs:d:U:m:o:t")) != EOF) + while ((i = getopt(ac, av, "CSIHbinquvs:d:U:m:o:t")) != EOF) { switch(i) { @@ -383,15 +385,19 @@ char *argv[]; case 't': ps.self = (ps.self == -1) ? getpid() : -1; break; - + + case 'C': + ps.wcpu = !ps.wcpu; + break; + case 'H': ps.thread = !ps.thread; break; - + default: fprintf(stderr, "\ Top version %s\n\ -Usage: %s [-HISbinqut] [-d x] [-s x] [-o field] [-U username] [number]\n", +Usage: %s [-CHISbinqut] [-d x] [-s x] [-o field] [-U username] [number]\n", version_string(), myname); exit(1); } @@ -993,6 +999,15 @@ restart: reset_display(); putchar('\r'); break; + case CMD_wcputog: + ps.wcpu = !ps.wcpu; + new_message(MT_standout | MT_delayed, + "Displaying %sCPU", + ps.wcpu ? "W" : ""); + header_text = format_header(uname_field); + reset_display(); + putchar('\r'); + break; case CMD_viewtog: if (++displaymode == DISP_MAX) displaymode = 0; |