roundoff bug in MON and iostat

Dave Johnson ddj at brunix.UUCP
Sat Jan 19 18:11:40 AEST 1985


This is a minor bug I noticed in mon.  When the system has been up for
a couple days, the first idle time percentage often is printed as a
negative value, and the other percentages are incorrectly computed.
This was caused by integer truncation before a floating divide in
vm.c.   The first set of percentages, by the way, is the average
over the period since the system was booted.

This error was inherited from iostat.c, and can be fixed there just
as easily... there was a bug report in the MtXinu/USENIX bug list,
but no fix indication -- I've included the change to its offending
line at the end of this message.

	Dave Johnson
	Brown University Computer Science
	ddj at brown.csnet
	{allegra,decvax,linus,ihnp4}!brunix!ddj

afterthought:  Now that mon has been pretty stable for a few weeks,
it might be nice to post a complete shar distribution again with
all the fixes together.  A few people have mentioned having trouble
getting all the diffs from various contributors to run properly.
I have tried to keep up with the changes (though we missed about
two weeks of news in the last month for various reasons).
Have there been any further changes after these two?
    -----
    Message-ID: <220 at unc.UUCP>
    From: sherouse at unc.UUCP (George W. Sherouse) Mon Dec 17 16:38:57 1984
    added user count
    -----
    Message-ID: <1552 at ittvax.UUCP>
    From: long at ittvax.UUCP (H. Morrow Long) Thu Dec 20 21:40:41 1984
    added screen dump commands
    -----

NOTE: it is very important to do a clean make from source if you change
the include file, mon.h, while adding any of the patches floating around.
-------------------------
Fix for mon sources (Line numbers may vary due to individual patching habits)
diff vm.c.old vm.c:
129c129
<                 mvprintw(TIMEY+1,x,"%3.0f", 100 * s.cp_time[i]/t);
---
>                 mvprintw(TIMEY+1,x,"%3.0f", 100. * s.cp_time[i]/t);
132c132
< 	                mvprintw(TIMEY+1,x+27,"%3.0f", 100 * s.cp_time2[i]/t2);
---
> 	                mvprintw(TIMEY+1,x+27,"%3.0f", 100. * s.cp_time2[i]/t2);

Fix for 4.2 iostat.c:

diff /usr/src/usr.bin/iostat.c iostat.c:
210c210
< 	printf("%3.0f", 100*s.cp_time[o]/time);
---
> 	printf("%3.0f", 100.*s.cp_time[o]/time); /* ddj -- was missing '.' */



More information about the Comp.bugs.4bsd.ucb-fixes mailing list