eliminate floating point from the kernel (from forys@cs.utah.edu)
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 30 May 1989 05:04:38 +0000 (21:04 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 30 May 1989 05:04:38 +0000 (21:04 -0800)
SCCS-vsn: sys/conf/param.c 7.6
SCCS-vsn: sys/sys/dkstat.h 7.4
SCCS-vsn: sys/sys/kernel.h 7.2
SCCS-vsn: sys/sys/param.h 7.10
SCCS-vsn: sys/sys/proc.h 7.6
SCCS-vsn: sys/sys/types.h 7.6
SCCS-vsn: sys/kern/kern_synch.c 7.9
SCCS-vsn: sys/sys/kernel.h 7.2
SCCS-vsn: sys/vm/vm_meter.c 7.6
SCCS-vsn: sys/tahoe/tahoe/symbols.raw 7.2
SCCS-vsn: sys/vax/vax/symbols.raw 7.2
SCCS-vsn: sys/tahoe/vba/hd.c 7.5
SCCS-vsn: sys/tahoe/vba/vd.c 7.10
SCCS-vsn: sys/vax/bi/kdb.c 7.7
SCCS-vsn: sys/vax/mba/hp.c 7.17
SCCS-vsn: sys/vax/uba/idc.c 7.8
SCCS-vsn: sys/vax/uba/rk.c 7.7
SCCS-vsn: sys/vax/uba/rl.c 7.8
SCCS-vsn: sys/vax/uba/uda.c 7.23
SCCS-vsn: sys/vax/uba/up.c 7.8

19 files changed:
usr/src/sys/conf/param.c
usr/src/sys/kern/kern_synch.c
usr/src/sys/sys/dkstat.h
usr/src/sys/sys/kernel.h
usr/src/sys/sys/param.h
usr/src/sys/sys/proc.h
usr/src/sys/sys/types.h
usr/src/sys/tahoe/tahoe/symbols.raw
usr/src/sys/tahoe/vba/hd.c
usr/src/sys/tahoe/vba/vd.c
usr/src/sys/vax/bi/kdb.c
usr/src/sys/vax/mba/hp.c
usr/src/sys/vax/uba/idc.c
usr/src/sys/vax/uba/rk.c
usr/src/sys/vax/uba/rl.c
usr/src/sys/vax/uba/uda.c
usr/src/sys/vax/uba/up.c
usr/src/sys/vax/vax/symbols.raw
usr/src/sys/vm/vm_meter.c

index e83c6f9..a232fe7 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)param.c     7.5 (Berkeley) %G%
+ *     @(#)param.c     7.6 (Berkeley) %G%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -69,6 +69,7 @@ int     nmbclusters = NMBCLUSTERS;
 int    nquota = (MAXUSERS * 9) / 7 + 3;
 int    ndquot = NINODE + (MAXUSERS * NMOUNT) / 4;
 #endif
 int    nquota = (MAXUSERS * 9) / 7 + 3;
 int    ndquot = NINODE + (MAXUSERS * NMOUNT) / 4;
 #endif
+int    fscale = FSCALE;        /* kernel uses `FSCALE', user uses `fscale' */
 
 /*
  * These are initialized at bootstrap time
 
 /*
  * These are initialized at bootstrap time
index a98176a..a2aaa90 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)kern_synch.c        7.8 (Berkeley) %G%
+ *     @(#)kern_synch.c        7.9 (Berkeley) %G%
  */
 
 #include "machine/pte.h"
  */
 
 #include "machine/pte.h"
@@ -92,19 +92,36 @@ roundrobin()
  *      loadav: 1       2       3       4
  *      power:  5.68    10.32   14.94   19.55
  */
  *      loadav: 1       2       3       4
  *      power:  5.68    10.32   14.94   19.55
  */
-#define        filter(loadav) ((2 * (loadav)) / (2 * (loadav) + 1))
 
 
-double ccpu = 0.95122942450071400909;          /* exp(-1/20) */
+/* calculations for digital decay to forget 90% of usage in 5*loadav sec */
+#define        get_b(loadav)           (2 * (loadav))
+#define        get_pcpu(b, cpu)        (((b) * ((cpu) & 0377)) / ((b) + FSCALE))
+
+/* decay 95% of `p_pctcpu' in 60 seconds; see CCPU_SHIFT before changing */
+fixpt_t        ccpu = 0.95122942450071400909 * FSCALE;         /* exp(-1/20) */
+
+/*
+ * If `ccpu' is not equal to `exp(-1/20)' and you still want to use the
+ * faster/more-accurate formula, you'll have to estimate CCPU_SHIFT below
+ * and possibly adjust FSHIFT in "param.h" so that (FSHIFT >= CCPU_SHIFT).
+ *
+ * To estimate CCPU_SHIFT for exp(-1/20), the following formula was used:
+ *     1 - exp(-1/20) ~= 0.0487 ~= 0.0488 == 1 (fixed pt, *11* bits).
+ *
+ * If you dont want to bother with the faster/more-accurate formula, you
+ * can set CCPU_SHIFT to (FSHIFT + 1) which will use a slower/less-accurate
+ * (more general) method of calculating the %age of CPU used by a process.
+ */
+#define        CCPU_SHIFT      11
 
 /*
  * Recompute process priorities, once a second
  */
 schedcpu()
 {
 
 /*
  * Recompute process priorities, once a second
  */
 schedcpu()
 {
-       register double ccpu1 = (1.0 - ccpu) / (double)hz;
+       register fixpt_t b = get_b(averunnable[0]);
        register struct proc *p;
        register int s, a;
        register struct proc *p;
        register int s, a;
-       float scale = filter(avenrun[0]);
 
        wakeup((caddr_t)&lbolt);
        for (p = allproc; p != NULL; p = p->p_nxt) {
 
        wakeup((caddr_t)&lbolt);
        for (p = allproc; p != NULL; p = p->p_nxt) {
@@ -113,20 +130,27 @@ schedcpu()
                if (p->p_stat==SSLEEP || p->p_stat==SSTOP)
                        if (p->p_slptime != 127)
                                p->p_slptime++;
                if (p->p_stat==SSLEEP || p->p_stat==SSTOP)
                        if (p->p_slptime != 127)
                                p->p_slptime++;
+               p->p_pctcpu = (p->p_pctcpu * ccpu) >> FSHIFT;
                /*
                 * If the process has slept the entire second,
                 * stop recalculating its priority until it wakes up.
                 */
                /*
                 * If the process has slept the entire second,
                 * stop recalculating its priority until it wakes up.
                 */
-               if (p->p_slptime > 1) {
-                       p->p_pctcpu *= ccpu;
+               if (p->p_slptime > 1)
                        continue;
                        continue;
-               }
                /*
                 * p_pctcpu is only for ps.
                 */
                /*
                 * p_pctcpu is only for ps.
                 */
-               p->p_pctcpu = ccpu * p->p_pctcpu + ccpu1 * p->p_cpticks;
+#if    (FSHIFT >= CCPU_SHIFT)
+               p->p_pctcpu += (hz == 100)?
+                       ((fixpt_t) p->p_cpticks) << (FSHIFT - CCPU_SHIFT):
+                       100 * (((fixpt_t) p->p_cpticks)
+                               << (FSHIFT - CCPU_SHIFT)) / hz;
+#else
+               p->p_pctcpu += ((FSCALE - ccpu) *
+                       (p->p_cpticks * FSCALE / hz)) >> FSHIFT;
+#endif
                p->p_cpticks = 0;
                p->p_cpticks = 0;
-               a = (int) (scale * (p->p_cpu & 0377)) + p->p_nice;
+               a = (int) get_pcpu(b, p->p_cpu) + p->p_nice;
                if (a < 0)
                        a = 0;
                if (a > 255)
                if (a < 0)
                        a = 0;
                if (a > 255)
@@ -165,11 +189,11 @@ updatepri(p)
        register struct proc *p;
 {
        register int a = p->p_cpu & 0377;
        register struct proc *p;
 {
        register int a = p->p_cpu & 0377;
-       float scale = filter(avenrun[0]);
+       register fixpt_t b = get_b(averunnable[0]);
 
        p->p_slptime--;         /* the first time was done in schedcpu */
        while (a && --p->p_slptime)
 
        p->p_slptime--;         /* the first time was done in schedcpu */
        while (a && --p->p_slptime)
-               a = (int) (scale * a) /* + p->p_nice */;
+               a = (int) get_pcpu(b, a) /* + p->p_nice */;
        p->p_slptime = 0;
        if (a < 0)
                a = 0;
        p->p_slptime = 0;
        if (a < 0)
                a = 0;
index 7bb0b02..d5c35a7 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)dkstat.h    7.3 (Berkeley) %G%
+ *     @(#)dkstat.h    7.4 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -26,7 +26,7 @@ long  dk_time[DK_NDRIVE];
 long   dk_seek[DK_NDRIVE];
 long   dk_xfer[DK_NDRIVE];
 long   dk_wds[DK_NDRIVE];
 long   dk_seek[DK_NDRIVE];
 long   dk_xfer[DK_NDRIVE];
 long   dk_wds[DK_NDRIVE];
-float  dk_mspw[DK_NDRIVE];
+long   dk_wpms[DK_NDRIVE];
 
 long   tk_nin;
 long   tk_cancc;
 
 long   tk_nin;
 long   tk_cancc;
index ae76d91..ad744f7 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)kernel.h    7.1 (Berkeley) %G%
+ *     @(#)kernel.h    7.2 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -27,7 +27,10 @@ int  tick;
 int    lbolt;                          /* awoken once a second */
 int    realitexpire();
 
 int    lbolt;                          /* awoken once a second */
 int    realitexpire();
 
+fixpt_t        averunnable[3];
+#ifdef COMPAT_43
 double avenrun[3];
 double avenrun[3];
+#endif /* COMPAT_43 */
 
 #ifdef GPROF
 extern int profiling;
 
 #ifdef GPROF
 extern int profiling;
index 8508107..9518058 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)param.h     7.9 (Berkeley) %G%
+ *     @(#)param.h     7.10 (Berkeley) %G%
  */
 
 #define        BSD     198810          /* system version  (year & month) */
  */
 
 #define        BSD     198810          /* system version  (year & month) */
 #endif
 #define        roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
 #define powerof2(x)    ((((x)-1)&(x))==0)
 #endif
 #define        roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
 #define powerof2(x)    ((((x)-1)&(x))==0)
+
+/*
+ * Scale factor for scaled integers used to count %cpu time and load avgs.
+ *
+ * The number of CPU `tick's that map to a unique `%age' can be expressed
+ * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
+ * can be calculated (assuming 32 bits) can be closely approximated using
+ * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
+ *
+ * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
+ * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
+ */
+#define        FSHIFT  11              /* bits to right of fixed binary point */
+#define FSCALE (1<<FSHIFT)
index 4d47531..6703c51 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)proc.h      7.5 (Berkeley) %G%
+ *     @(#)proc.h      7.6 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -71,7 +71,7 @@ struct        proc {
        struct  pte *p_p0br;    /* page table base P0BR */
        struct  proc *p_xlink;  /* linked list of procs sharing same text */
        short   p_cpticks;      /* ticks of cpu time */
        struct  pte *p_p0br;    /* page table base P0BR */
        struct  proc *p_xlink;  /* linked list of procs sharing same text */
        short   p_cpticks;      /* ticks of cpu time */
-       float   p_pctcpu;       /* %cpu for this process during p_time */
+       fixpt_t p_pctcpu;       /* %cpu for this process during p_time */
        short   p_ndx;          /* proc index for memall (because of vfork) */
        short   p_idhash;       /* hashed based on p_pid for kill+exit+... */
        struct  proc *p_pptr;   /* pointer to process structure of parent */
        short   p_ndx;          /* proc index for memall (because of vfork) */
        short   p_idhash;       /* hashed based on p_pid for kill+exit+... */
        struct  proc *p_pptr;   /* pointer to process structure of parent */
index 5d4ead5..33e54f3 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)types.h     7.5 (Berkeley) %G%
+ *     @(#)types.h     7.6 (Berkeley) %G%
  */
 
 #ifndef _TYPES_
  */
 
 #ifndef _TYPES_
@@ -49,6 +49,7 @@ typedef       u_short gid_t;
 typedef        short   pid_t;
 typedef        short   nlink_t;
 typedef        u_short mode_t;
 typedef        short   pid_t;
 typedef        short   nlink_t;
 typedef        u_short mode_t;
+typedef u_long fixpt_t;
 
 #define        NBBY    8               /* number of bits in a byte */
 /*
 
 #define        NBBY    8               /* number of bits in a byte */
 /*
index b2f4dda..603c2f1 100644 (file)
@@ -1,4 +1,4 @@
-#      symbols.raw     7.1     88/05/21
+#      symbols.raw     7.2     89/05/29
        _version
 #dmesg
        _msgbuf
        _version
 #dmesg
        _msgbuf
@@ -11,7 +11,7 @@
        _tk_nout
        _dk_seek
        _cp_time
        _tk_nout
        _dk_seek
        _cp_time
-       _dk_mspw
+       _dk_wpms
 #      _io_info
 #ps
        _proc
 #      _io_info
 #ps
        _proc
@@ -57,7 +57,7 @@
        _Usrptmap
        _usrpt
        _nswap
        _Usrptmap
        _usrpt
        _nswap
-       _avenrun
+       _averunnable
        _boottime
 #netstat
        _mbstat
        _boottime
 #netstat
        _mbstat
@@ -76,5 +76,6 @@
 #routed
        _ifnet
 #rwho
 #routed
        _ifnet
 #rwho
-       _avenrun
        _boottime
        _boottime
+#deprecated
+       _avenrun
index 4b889ec..11bc70d 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)hd.c        7.4 (Berkeley) %G%
+ *     @(#)hd.c        7.5 (Berkeley) %G%
  */
 
 #include "hd.h"
  */
 
 #include "hd.h"
@@ -264,8 +264,8 @@ hdattach(vi)
         * (60 / rpm) / (sectors per track * (bytes per sector / 2))
         */
        if (vi->ui_dk >= 0)
         * (60 / rpm) / (sectors per track * (bytes per sector / 2))
         */
        if (vi->ui_dk >= 0)
-               dk_mspw[vi->ui_dk] = 120.0 /
-                   (lp->d_rpm * lp->d_nsectors * lp->d_secsize);
+               dk_wpms[vi->ui_dk] =
+                   (lp->d_rpm * lp->d_nsectors * lp->d_secsize) / 120;
 #ifdef notyet
        addswap(makedev(HDMAJOR, hdminor(unit, 0)), lp);
 #endif
 #ifdef notyet
        addswap(makedev(HDMAJOR, hdminor(unit, 0)), lp);
 #endif
index 31f9597..871dc12 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)vd.c        7.9 (Berkeley) %G%
+ *     @(#)vd.c        7.10 (Berkeley) %G%
  */
 
 #include "dk.h"
  */
 
 #include "dk.h"
@@ -289,8 +289,8 @@ vdattach(vi)
         * (60 / rpm) / (sectors per track * (bytes per sector / 2))
         */
        if (vi->ui_dk >= 0)
         * (60 / rpm) / (sectors per track * (bytes per sector / 2))
         */
        if (vi->ui_dk >= 0)
-               dk_mspw[vi->ui_dk] = 120.0 /
-                   (lp->d_rpm * lp->d_nsectors * lp->d_secsize);
+               dk_wpms[vi->ui_dk] =
+                   (lp->d_rpm * lp->d_nsectors * lp->d_secsize) / 120;
 #ifdef notyet
        addswap(makedev(VDMAJOR, vdminor(unit, 0)), lp);
 #endif
 #ifdef notyet
        addswap(makedev(VDMAJOR, vdminor(unit, 0)), lp);
 #endif
index 46d220f..a0343ac 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)kdb.c       7.6 (Berkeley) %G%
+ *     @(#)kdb.c       7.7 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -519,7 +519,7 @@ try_another:
 
 /*
  * Attach a found slave.  Make sure the watchdog timer is running.
 
 /*
  * Attach a found slave.  Make sure the watchdog timer is running.
- * If this disk is being profiled, fill in the `mspw' value (used by
+ * If this disk is being profiled, fill in the `wpms' value (used by
  * what?).  Set up the inverting pointer, and attempt to bring the
  * drive on line.
  */
  * what?).  Set up the inverting pointer, and attempt to bring the
  * drive on line.
  */
@@ -532,7 +532,7 @@ kdbattach(ui)
                kdbwstart++;
        }
        if (ui->ui_dk >= 0)
                kdbwstart++;
        }
        if (ui->ui_dk >= 0)
-               dk_mspw[ui->ui_dk] = 1.0 / (60 * 31 * 256);     /* approx */
+               dk_wpms[ui->ui_dk] = (60 * 31 * 256);   /* approx */
        kdbip[ui->ui_ctlr][ui->ui_slave] = ui;
        (void) kdb_bringonline(ui, 1);
        /* should we get its status too? */
        kdbip[ui->ui_ctlr][ui->ui_slave] = ui;
        (void) kdb_bringonline(ui, 1);
        /* should we get its status too? */
index f4da18b..67b9fd9 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)hp.c        7.16 (Berkeley) %G%
+ *     @(#)hp.c        7.17 (Berkeley) %G%
  */
 
 #ifdef HPDEBUG
  */
 
 #ifdef HPDEBUG
@@ -334,7 +334,7 @@ hpinit(dev, flags)
                        sc->sc_mlsize >>= 2;
                if (mi->mi_dk >= 0) {
                        trt = (hpaddr->hpmr & HPMR_TRT) >> 8;
                        sc->sc_mlsize >>= 2;
                if (mi->mi_dk >= 0) {
                        trt = (hpaddr->hpmr & HPMR_TRT) >> 8;
-                       dk_mspw[mi->mi_dk] = 1.0 / (1<<(20-trt));
+                       dk_wpms[mi->mi_dk] = (1<<(20-trt));
                }
                mi->mi_type = MBDT_ML11A;
                lp->d_partitions[0].p_size = sc->sc_mlsize;
                }
                mi->mi_type = MBDT_ML11A;
                lp->d_partitions[0].p_size = sc->sc_mlsize;
@@ -361,8 +361,8 @@ hpinit(dev, flags)
         * Seconds per word = (60 / rpm) / (nsectors * secsize/2)
         */
        if (mi->mi_dk >= 0 && lp->d_rpm)
         * Seconds per word = (60 / rpm) / (nsectors * secsize/2)
         */
        if (mi->mi_dk >= 0 && lp->d_rpm)
-               dk_mspw[mi->mi_dk] = 120.0 /
-                   (lp->d_rpm * lp->d_nsectors * lp->d_secsize);
+               dk_wpms[mi->mi_dk] =
+                   (lp->d_rpm * lp->d_nsectors * lp->d_secsize) / 120;
        /*
         * Read bad sector table into memory.
         */
        /*
         * Read bad sector table into memory.
         */
index 4b3c29b..4b1ff84 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)idc.c       7.7 (Berkeley) %G%
+ *     @(#)idc.c       7.8 (Berkeley) %G%
  */
 
 #include "rb.h"
  */
 
 #include "rb.h"
@@ -191,9 +191,9 @@ idcattach(ui)
        }
        if (ui->ui_dk >= 0)
                if (ui->ui_type)
        }
        if (ui->ui_dk >= 0)
                if (ui->ui_type)
-                       dk_mspw[ui->ui_dk] = 1.0 / (60 * NRB80SECT * 256);
+                       dk_wpms[ui->ui_dk] = (60 * NRB80SECT * 256);
                else
                else
-                       dk_mspw[ui->ui_dk] = 1.0 / (60 * NRB02SECT * 128);
+                       dk_wpms[ui->ui_dk] = (60 * NRB02SECT * 128);
        idccyl[ui->ui_unit].dar_dar = -1;
        ui->ui_flags = 0;
 }
        idccyl[ui->ui_unit].dar_dar = -1;
        ui->ui_flags = 0;
 }
index a0b9c08..23afacb 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)rk.c        7.6 (Berkeley) %G%
+ *     @(#)rk.c        7.7 (Berkeley) %G%
  */
 
 #include "rk.h"
  */
 
 #include "rk.h"
@@ -164,7 +164,7 @@ rkattach(ui)
                rkwstart++;
        }
        if (ui->ui_dk >= 0)
                rkwstart++;
        }
        if (ui->ui_dk >= 0)
-               dk_mspw[ui->ui_dk] = 1.0 / (60 * NRKSECT * 256);
+               dk_wpms[ui->ui_dk] = (60 * NRKSECT * 256);
        rkip[ui->ui_ctlr][ui->ui_slave] = ui;
        rk_softc[ui->ui_ctlr].sc_ndrive++;
        rkcyl[ui->ui_unit] = -1;
        rkip[ui->ui_ctlr][ui->ui_slave] = ui;
        rk_softc[ui->ui_ctlr].sc_ndrive++;
        rkcyl[ui->ui_unit] = -1;
index a9e3513..e14c2f6 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)rl.c        7.7 (Berkeley) %G%
+ *     @(#)rl.c        7.8 (Berkeley) %G%
  */
 
 #include "rl.h"
  */
 
 #include "rl.h"
@@ -166,7 +166,7 @@ rlattach(ui)
        }
        /* Initialize iostat values */
        if (ui->ui_dk >= 0)
        }
        /* Initialize iostat values */
        if (ui->ui_dk >= 0)
-               dk_mspw[ui->ui_dk] = .000003906;   /* 16bit transfer time? */
+               dk_wpms[ui->ui_dk] = 256016;   /* 16bit transfer time? */
        rlip[ui->ui_ctlr][ui->ui_slave] = ui;
        rl_softc[ui->ui_ctlr].rl_ndrive++;
        rladdr = (struct rldevice *)ui->ui_addr;
        rlip[ui->ui_ctlr][ui->ui_slave] = ui;
        rl_softc[ui->ui_ctlr].rl_ndrive++;
        rladdr = (struct rldevice *)ui->ui_addr;
index 7659864..d6b5bc6 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)uda.c       7.22 (Berkeley) %G%
+ *     @(#)uda.c       7.23 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -517,7 +517,7 @@ try_another:
 
 /*
  * Attach a found slave.  Make sure the watchdog timer is running.
 
 /*
  * Attach a found slave.  Make sure the watchdog timer is running.
- * If this disk is being profiled, fill in the `mspw' value (used by
+ * If this disk is being profiled, fill in the `wpms' value (used by
  * what?).  Set up the inverting pointer, and attempt to bring the
  * drive on line and read its label.
  */
  * what?).  Set up the inverting pointer, and attempt to bring the
  * drive on line and read its label.
  */
@@ -545,7 +545,7 @@ udaattach(ui)
                return;
        }
        if (ui->ui_dk >= 0)
                return;
        }
        if (ui->ui_dk >= 0)
-               dk_mspw[ui->ui_dk] = 1.0 / (60 * 31 * 256);     /* approx */
+               dk_wpms[ui->ui_dk] = (60 * 31 * 256);   /* approx */
        udaip[ui->ui_ctlr][ui->ui_slave] = ui;
 
        if (uda_rainit(ui, 0))
        udaip[ui->ui_ctlr][ui->ui_slave] = ui;
 
        if (uda_rainit(ui, 0))
index f47bf15..1addf19 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)up.c        7.7 (Berkeley) %G%
+ *     @(#)up.c        7.8 (Berkeley) %G%
  */
 
 #include "up.h"
  */
 
 #include "up.h"
@@ -208,7 +208,7 @@ upattach(ui)
                upwstart++;
        }
        if (ui->ui_dk >= 0)
                upwstart++;
        }
        if (ui->ui_dk >= 0)
-               dk_mspw[ui->ui_dk] = .0000020345;
+               dk_wpms[ui->ui_dk] = 491521;
        upip[ui->ui_ctlr][ui->ui_slave] = ui;
        up_softc[ui->ui_ctlr].sc_ndrive++;
        ui->ui_type = upmaptype(ui);
        upip[ui->ui_ctlr][ui->ui_slave] = ui;
        up_softc[ui->ui_ctlr].sc_ndrive++;
        ui->ui_type = upmaptype(ui);
index a6dfb5f..9dac113 100644 (file)
@@ -3,7 +3,7 @@
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
-#      @(#)symbols.raw 7.1 (Berkeley) %G%
+#      @(#)symbols.raw 7.2 (Berkeley) %G%
 #
        _version
 #dmesg
 #
        _version
 #dmesg
@@ -17,7 +17,7 @@
        _tk_nout
        _dk_seek
        _cp_time
        _tk_nout
        _dk_seek
        _cp_time
-       _dk_mspw
+       _dk_wpms
 #      _io_info
 #ps
        _proc
 #      _io_info
 #ps
        _proc
@@ -63,7 +63,7 @@
        _Usrptmap
        _usrpt
        _nswap
        _Usrptmap
        _usrpt
        _nswap
-       _avenrun
+       _averunnable
        _boottime
 #netstat
        _mbstat
        _boottime
 #netstat
        _mbstat
@@ -82,5 +82,6 @@
 #routed
        _ifnet
 #rwho
 #routed
        _ifnet
 #rwho
-       _avenrun
        _boottime
        _boottime
+#deprecated
+       _avenrun
index e6ef507..c519f0f 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)vm_meter.c  7.5 (Berkeley) %G%
+ *     @(#)vm_meter.c  7.6 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -48,7 +48,7 @@ int   kltxt = KLTXT;
 int    klout = KLOUT;
 int    multprog = -1;          /* so we don't count process 2 */
 
 int    klout = KLOUT;
 int    multprog = -1;          /* so we don't count process 2 */
 
-double avenrun[3];             /* load average, of runnable procs */
+fixpt_t        averunnable[3];         /* load average, of runnable procs */
 
 /*
  * The main loop of the scheduling (swapping) process.
 
 /*
  * The main loop of the scheduling (swapping) process.
@@ -113,8 +113,9 @@ loop:
         *         memory is less than desirable.
         */
        if (kmapwnt ||
         *         memory is less than desirable.
         */
        if (kmapwnt ||
-           (avenrun[0] >= 2 && imax(avefree, avefree30) < desfree &&
-           (rate.v_pgin + rate.v_pgout > maxpgio || avefree < minfree))) {
+           (averunnable[0] >= 2 * FSCALE &&
+            imax(avefree, avefree30) < desfree &&
+            (rate.v_pgin + rate.v_pgout > maxpgio || avefree < minfree))) {
                desperate = 1;
                goto hardswap;
        }
                desperate = 1;
                goto hardswap;
        }
@@ -439,17 +440,17 @@ active:
        total.t_rm += total.t_rmtxt;
        total.t_arm += total.t_armtxt;
        total.t_free = avefree;
        total.t_rm += total.t_rmtxt;
        total.t_arm += total.t_armtxt;
        total.t_free = avefree;
-       loadav(avenrun, nrun);
+       loadav(averunnable, nrun);
 }
 
 /*
  * Constants for averages over 1, 5, and 15 minutes
  * when sampling at 5 second intervals.
  */
 }
 
 /*
  * Constants for averages over 1, 5, and 15 minutes
  * when sampling at 5 second intervals.
  */
-double cexp[3] = {
-       0.9200444146293232    /* exp(-1/12) */
-       0.9834714538216174    /* exp(-1/60) */
-       0.9944598480048967    /* exp(-1/180) */
+fixpt_t        cexp[3] = {
+       0.9200444146293232 * FSCALE,    /* exp(-1/12) */
+       0.9834714538216174 * FSCALE,    /* exp(-1/60) */
+       0.9944598480048967 * FSCALE,    /* exp(-1/180) */
 };
 
 /*
 };
 
 /*
@@ -457,11 +458,16 @@ double    cexp[3] = {
  * 1, 5 and 15 minute intervals.
  */
 loadav(avg, n)
  * 1, 5 and 15 minute intervals.
  */
 loadav(avg, n)
-       register double *avg;
+       register fixpt_t *avg;
        int n;
 {
        register int i;
 
        for (i = 0; i < 3; i++)
        int n;
 {
        register int i;
 
        for (i = 0; i < 3; i++)
-               avg[i] = cexp[i] * avg[i] + n * (1.0 - cexp[i]);
+               avg[i] = (cexp[i] * avg[i] + n * FSCALE * (FSCALE - cexp[i]))
+                        >> FSHIFT;
+#ifdef COMPAT_43
+       for (i = 0; i < 3; i++)
+               avenrun[i] = (double) averunnable[i] / FSCALE;
+#endif /* COMPAT_43 */
 }
 }