[net.sources.bugs] Size bug in top

bzs@bu-cs.UUCP (Barry Shein) (07/05/86)

>In top(1), where it prints out the size of the job and the resident
>size of the job, it assumes that clicks are 512 bytes.  It does a
>right shift by 1 to convert to K and then prints out the numbers.  The
>correct thing to do is to use the macro ctob() which is defined in
>param.h.  I don't have the context diff for this but it should be easy
>to find.  This only effects non-vax machines probably.
>
>Perry

Thanks for pointing this out, you're right, it's wrong, I think
the following fixes it: (slightly different than your suggestion)

-------------begin fix----------
/*
 *	BZS@BU-CS.BU.EDU 7/4/86
 *	 - fix suggested in net.sources.bugs, mostly for SUN
    (pp->p_tsize + pp->p_dsize + pp->p_ssize) >> 1,
    pp->p_rssize >> 1,
 */
#if PGSHIFT > 10
      (pp->p_tsize + pp->p_dsize + pp->p_ssize) << (PGSHIFT-10),
      pp->p_rssize << (PGSHIFT-10),
#else
      (pp->p_tsize + pp->p_dsize + pp->p_ssize) >> (10-PGSHIFT),
      pp->p_rssize >> (10-PGSHIFT),
#endif
------------end fix---------------

Note that the #if is necessitated by the fact that you can't
use a negative shift quantity on the SUN. I tried the above
fixed version on a VAX and it seemed fine. This should be as
portable as something like the above can be.

	-Barry Shein, Boston University

phil@rice.UUCP (07/12/86)

In article <895@bu-cs.UUCP>, bzs@bu-cs.UUCP (Barry Shein) writes:
> >In top(1), where it prints out the size of the job and the resident
> >size of the job, it assumes that clicks are 512 bytes.  It does a

Thank you for pointing the bug out.  It will be fixed in the new version.

> >right shift by 1 to convert to K and then prints out the numbers.  The
> >correct thing to do is to use the macro ctob() which is defined in
> >param.h.

Actually, this won't work on a pyramid, where ctob isn't defined.

> -------------begin fix----------
> /*
>  *	BZS@BU-CS.BU.EDU 7/4/86
>  *	 - fix suggested in net.sources.bugs, mostly for SUN
>     (pp->p_tsize + pp->p_dsize + pp->p_ssize) >> 1,
>     pp->p_rssize >> 1,
>  */
> #if PGSHIFT > 10
>       (pp->p_tsize + pp->p_dsize + pp->p_ssize) << (PGSHIFT-10),
>       pp->p_rssize << (PGSHIFT-10),
> #else
>       (pp->p_tsize + pp->p_dsize + pp->p_ssize) >> (10-PGSHIFT),
>       pp->p_rssize >> (10-PGSHIFT),
> #endif
> ------------end fix---------------

That's basically the gist of it.  I have something a little better that
I use in the new version.

I am currently in the process of finishing up version 2.0 of Top.
In it, I hope to incorporate all the changes and fixes that people
have sent to me.  There are also many other important differences.
For example, I have completely abandoned "curses".  It turns out that
not using curses results in the program starting up in about half the
time.  I have also added a small interactive mode, making it possible
to do redraws on demand, and to change the number of displayed processes
and the seconds delay while the program is running.

Watch for it......


-- 
			William LeFebvre
			Department of Computer Science
			Rice University
			<phil@Rice.edu>