From: "J.A. Magallon" <jamagallon@able.es>
To: Rik van Riel <riel@conectiva.com.br>
Cc: procps-list@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [ANNOUNCE] procps 2.0.10
Date: Tue, 8 Oct 2002 17:31:30 +0200 [thread overview]
Message-ID: <20021008153130.GG1560@werewolf.able.es> (raw)
In-Reply-To: <Pine.LNX.4.44L.0210081135290.1909-100000@duckman.distro.conectiva>; from riel@conectiva.com.br on Tue, Oct 08, 2002 at 16:38:36 +0200
On 2002.10.08 Rik van Riel wrote:
>On Tue, 8 Oct 2002, J.A. Magallon wrote:
>
>> It also kills the 'states' part, things are beginning to spread past 80
>> columns...is it very important ?
>
>Yes, things should stay within 80 lines.
>
>> I am gettin also strange outputs sometimes, with a ton of digits in
>> decimal parts.
>
>Wait... I remember fixing that bug. On 2.4 kernels iowait
>should always be 0.0% and it always is 0.0% here.
>
>I have no idea why it's displaying a wrong value on your
>system, unless you somehow managed to run against a wrong
>libproc.so (shouldn't happen).
>
Perhaps it is the percentage-mod plays. With this (calculate percentage in
0.1% units and then /10 and %10, I do not get that strange output). Perhaps
it was gcc-3.2 optimizing things, and it eats this better. It also guarantees
that decimal part never has more than 1 digit (%10 thing):
--- top.c.orig 2002-10-08 15:28:10.000000000 +0200
+++ top.c 2002-10-08 17:21:24.000000000 +0200
@@ -1691,6 +1691,8 @@
i, __LINE__);
break;
} else {
+ int u_delta, s_delta, n_delta, io_delta, i_delta, un_delta;
+
t_ticks = (u_ticks + s_ticks + i_ticks + n_ticks + io_ticks)
- (u_ticks_o[i] + s_ticks_o[i] + i_ticks_o[i] + n_ticks_o[i] + io_ticks_o[i]);
if (Irixmode)
@@ -1699,25 +1701,21 @@
cpumap =
cpu_mapping
[i];
+ u_delta = (trimzero(u_ticks - u_ticks_o[i])*1000)/t_ticks;
+ s_delta = (trimzero(s_ticks - s_ticks_o[i])*1000)/t_ticks;
+ n_delta = (trimzero(n_ticks - n_ticks_o[i])*1000)/t_ticks;
+ io_delta = (trimzero(io_ticks - io_ticks_o[i])*1000)/t_ticks;
+ i_delta = (trimzero(i_ticks - i_ticks_o[i])*1000)/t_ticks;
+ un_delta = (trimzero(u_ticks - u_ticks_o[i]+n_ticks - n_ticks_o[i])*1000)/t_ticks;
printf
- ("CPU%d states: %2d%s%-d%% user, %2d%s%-d%% system,"
- " %2d%s%-d%% nice, %2d%s%-d%% iowait, %2d%s%-d%% idle",
+ ("CPU%d: %3d%s%-d%% user %3d%s%-d%% system"
+ " %3d%s%-d%% nice %3d%s%-d%% iowait %3d%s%-d%% idle",
cpumap,
- trimzero(u_ticks - u_ticks_o [i] + n_ticks - n_ticks_o [i]) * 100 / t_ticks,
- decimal_point,
- trimzero(u_ticks - u_ticks_o [i]) * 100 % t_ticks / 100,
- trimzero(s_ticks - s_ticks_o [i]) * 100 / t_ticks,
- decimal_point,
- trimzero(s_ticks - s_ticks_o [i]) * 100 % t_ticks / 100,
- trimzero(n_ticks - n_ticks_o [i]) * 100 / t_ticks,
- decimal_point,
- trimzero(n_ticks - n_ticks_o [i]) * 100 % t_ticks / 100,
- trimzero(io_ticks - io_ticks_o [i]) * 100 / t_ticks,
- decimal_point,
- trimzero(io_ticks - io_ticks_o [i]) * 100 % t_ticks / 100,
- trimzero(i_ticks - i_ticks_o [i]) * 100 / t_ticks,
- decimal_point,
- trimzero(i_ticks - i_ticks_o [i]) * 100 % t_ticks / 100);
+ un_delta/ 10, decimal_point, un_delta% 10,
+ s_delta / 10, decimal_point, s_delta % 10,
+ n_delta / 10, decimal_point, n_delta % 10,
+ io_delta/ 10, decimal_point, io_delta% 10,
+ i_delta / 10, decimal_point, i_delta % 10);
s_ticks_o[i] = s_ticks;
u_ticks_o[i] = u_ticks;
n_ticks_o[i] = n_ticks;
And looks cleaner...;)
--
J.A. Magallon <jamagallon@able.es> \ Software is like sex:
werewolf.able.es \ It's better when it's free
Mandrake Linux release 9.0 (dolphin) for i586
Linux 2.4.20-pre9-jam1 (gcc 3.2 (Mandrake Linux 9.0 3.2-1mdk))
next prev parent reply other threads:[~2002-10-08 15:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-08 13:35 Rik van Riel
2002-10-08 14:31 ` J.A. Magallon
2002-10-08 14:38 ` Rik van Riel
2002-10-08 14:43 ` J.A. Magallon
2002-10-08 16:19 ` venom
2002-10-08 14:53 ` J.A. Magallon
2002-10-08 15:05 ` Rik van Riel
2002-10-08 16:02 ` J.A. Magallon
2002-10-08 16:46 ` Rik van Riel
2002-10-08 15:31 ` J.A. Magallon [this message]
2002-10-11 3:50 ` Brandon Low
2002-10-11 4:04 ` Alexander Viro
2002-10-11 13:54 ` Rik van Riel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021008153130.GG1560@werewolf.able.es \
--to=jamagallon@able.es \
--cc=linux-kernel@vger.kernel.org \
--cc=procps-list@redhat.com \
--cc=riel@conectiva.com.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®