Subject: Re: Problems with time(1)
To: Mika Nystroem <mika@cs.caltech.edu>
From: Brian Baird <brb@exp.com>
List: current-users
Date: 03/20/1997 16:35:23
This was a bug in NetBSD 1.1 that was fixed last May and is fixed NetBSD
1.2.  The PR about it was kern/2496.  You can upgrade to 1.2 or apply
the following diffs to 1.1's /sys/kern/kern_resource.c to solve the
problem.

*** kern_resource.c.11     Fri Oct 13 19:41:16 1995
--- kern_resource.c     Fri May 31 17:45:09 1996
***************
*** 365,371 ****
                sec += tv.tv_sec - runtime.tv_sec;
                usec += tv.tv_usec - runtime.tv_usec;
        }
!       u = sec * 1000000 + usec;
        st = (u * st) / tot;
        sp->tv_sec = st / 1000000;
        sp->tv_usec = st % 1000000;
--- 365,371 ----
                sec += tv.tv_sec - runtime.tv_sec;
                usec += tv.tv_usec - runtime.tv_usec;
        }
!       u = (u_quad_t)sec * 1000000 + usec;
        st = (u * st) / tot;
        sp->tv_sec = st / 1000000;
        sp->tv_usec = st % 1000000;

> I just noticed something weird on my NetBSD PCs---time(1) doesn't work
> right.  I was using the Cornell tcsh time to measure the cpu time spent
> by some long-running combinatorial search programs, and it seems that
> the time measured stops increasing after about an hour of use---possibly
> a counter overflow because sometimes I see 1000 seconds charged, sometimes
> 500, for a program that has obviously run for ten hours or more.  It's 
> just a bit tedious to debug!  I'm not really "-current"---running 1.1B,
> mostly, so perhaps the bug has been fixed, and perhaps it's not
> i386-specific, either.  It *does* show up with both tcsh time and
> /usr/bin/time (they read almost exactly the same numbers, both wildly
> off the mark) (and curiously, OSF/1 / Digital UNIX V4.0 has a problem
> with the %cpu computation, but that's another story).

--Brian;