Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Apr 2005 15:57:56 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc:        cvs-src@FreeBSD.org
Subject:   Re: cvs commit: src/usr.bin/top machine.c
Message-ID:  <20050418153905.L1289@epsplex.bde.org>
In-Reply-To: <20050417135844.GA792@gothmog.gr>
References:  <200504161543.j3GFhclO075103@repoman.freebsd.org> <86acnyd2k7.fsf@xps.des.no> <20050416191436.G68941@fledge.watson.org> <863btq4k9m.fsf@xps.des.no> <20050417110321.GA78636@gothmog.gr> <20050417222313.K946@epsplex.bde.org> <20050417135844.GA792@gothmog.gr>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 17 Apr 2005, Giorgos Keramidas wrote:

> On 2005-04-17 23:01, Bruce Evans <bde@zeta.org.au> wrote:
>> Just removing the CPU column doesn't seem right.  ps has a -C flag to
>> switch between WCPU and CPU.
>
> We can add a new toggle command to top, i.e. 'C', that toggles between
> displaying WCPU or CPU.  This should regain us a lot of the space lost
> from COMMAND after I added THR.

I like that.

> Index: contrib/top/commands.c
> ===================================================================
> RCS file: /home/ncvs/src/contrib/top/commands.c,v
> retrieving revision 1.11
> diff -u -r1.11 commands.c
> --- contrib/top/commands.c	14 Apr 2005 15:02:03 -0000	1.11
> +++ contrib/top/commands.c	17 Apr 2005 13:53:19 -0000
> @@ -71,6 +71,7 @@
> 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\
> +C       - toggle the displaying of weighted CPU percentage\n\
> H       - toggle the displaying of threads\n\
> k       - kill processes; send a signal to a list of processes\n\
> m       - toggle the display between 'cpu' and 'io' modes\n\

Further unsorting of a sorted list.  The list was previously unsorted by
adding H after I.

> Index: contrib/top/machine.h
> ===================================================================
> RCS file: /home/ncvs/src/contrib/top/machine.h,v
> retrieving revision 1.6
> diff -u -r1.6 machine.h
> --- contrib/top/machine.h	17 Jul 2003 23:56:40 -0000	1.6
> +++ contrib/top/machine.h	17 Apr 2005 13:37:40 -0000
> @@ -60,6 +60,7 @@
>     int self;		/* show self */
>     int system;		/* show system processes */
>     int thread;		/* show threads */
> +    int wcpu;		/* show weighted cpu */
>     int uid;		/* only this uid (unless uid == -1) */
>     char *command;	/* only this command (unless == NULL) */
> };

More unsorting of a sorted list.

My mail program doesn't corrupt whitespace.  Something apparently corrupted
it before it got here.

> Index: contrib/top/top.c
> ===================================================================
> RCS file: /home/ncvs/src/contrib/top/top.c,v
> retrieving revision 1.16
> diff -u -r1.16 top.c
> --- contrib/top/top.c	14 Apr 2005 15:02:03 -0000	1.16
> +++ contrib/top/top.c	17 Apr 2005 13:43:26 -0000
> @@ -193,9 +193,9 @@
>     fd_set readfds;
>
> #ifdef ORDER
> -    static char command_chars[] = "\f qh?en#sdkriIutHmSo";
> +    static char command_chars[] = "\f qh?en#sdkriIutHCmSo";
> #else
> -    static char command_chars[] = "\f qh?en#sdkriIutHmS";
> +    static char command_chars[] = "\f qh?en#sdkriIutHCmS";
> #endif

Unsorting of unsorted lists.

> /* these defines enumerate the "strchr"s of the commands in command_chars */
> #define CMD_redraw	0
> @@ -216,10 +216,11 @@
> #define CMD_user	14
> #define CMD_selftog	15
> #define CMD_thrtog	16
> -#define CMD_viewtog	17
> -#define CMD_viewsys	18
> +#define	CMD_wcputog	17
> +#define CMD_viewtog	18
> +#define CMD_viewsys	19
> #ifdef ORDER
> -#define CMD_order       19
> +#define CMD_order       20
> #endif
>
>     /* set the buffer for stdout */

Adding at the end of this list would be acceptable, to avoid renumbering
everything.  But iterations of that is apparently how the order of
command_chars[] became random (historical).

No comment on other unsortings.

> Index: usr.bin/top/machine.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/top/machine.c,v
> retrieving revision 1.71
> diff -u -r1.71 machine.c
> --- usr.bin/top/machine.c	16 Apr 2005 15:43:38 -0000	1.71
> +++ usr.bin/top/machine.c	17 Apr 2005 13:51:12 -0000

I thought that you would have to change the sorting method to switch
between WCPU and CPU, but the existing sorting is only on CPU.  It is
just more bogus to sort on CPU while only displaying WCPU.

> @@ -780,8 +780,7 @@
> 	    status,
> 	    smpmode ? pp->ki_lastcpu : 0,
> 	    format_time(cputime),
> -	    100.0 * weighted_cpu(pct, pp),
> -	    100.0 * pct,
> +	    ps.wcpu ? (100.0 * weighted_cpu(pct, pp)) : (100.0 * pct),

Excessive parentheses.

Bruce



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