# 2.11BSD#431 - /usr/src/usr.sbin/timed/networkdelta.c

##### Functions

    networkdelta      X

       1: /*
       2:  * Copyright (c) 1983 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #ifndef lint
       8: static char sccsid[] = "@(#)networkdelta.c	2.1 (Berkeley) 12/10/85";
       9: #endif not lint
      10:
      11: #include "globals.h"
      12: #include <protocols/timed.h>
      13:
      14: extern int machup;
      15:
      16: /*
      17:  * `networkdelta' selects the largest set of deltas that fall within the
      18:  * interval RANGE, and uses them to compute the network average delta
      19:  */
      20:
      21: long networkdelta()
      22: {
      23:     int i, j, maxind, minind;
      24:     int ext;
      25:     int tempind;
      26:     long tempdata;
      27:     long x[NHOSTS];
      28:     long average;
      29:
      30:     for (i=0; i<slvcount; i++)
      31:         x[i] = hp[i].delta;
      32:     for (i=0; i<slvcount-1; i++) {
      33:         tempdata = x[i];
      34:         tempind = i;
      35:         for (j=i+1; j<slvcount; j++) {
      36:             if (x[j] < tempdata) {
      37:                 tempdata = x[j];
      38:                 tempind = j;
      39:             }
      40:         }
      41:         x[tempind] = x[i];
      42:         x[i] = tempdata;
      43:     }
      44:
      45:     /* this piece of code is critical: DO NOT TOUCH IT! */
      46: /****/
      47:     i=0; j=1; minind=0; maxind=1;
      48:     if (machup == 2)
      49:         goto compute;
      50:     do {
      51:         if (x[j]-x[i] <= RANGE)
      52:             j++;
      53:         else {
      54:             if (j > i+1)
      55:                 j--;
      56:             if ((x[j]-x[i] <= RANGE) && (j-i >= maxind-minind)) {
      57:                 minind=i;
      58:                 maxind=j;
      59:             }
      60:             i++;
      61:             if(i = j)
      62:                 j++;
      63:         }
      64:     } while (j < machup);
      65:     if ((x[machup-1] - x[i] <= RANGE) && (machup-i-1 >= maxind-minind)) {
      66:         minind=i; maxind=machup-1;
      67:     }
      68: /****/
      69: compute:
      70:     ext = maxind - minind + 1;
      71:     average = 0;
      72:     for (i=minind; i<=maxind; i++)
      73:         average += x[i];
      74:     average /= ext;
      75:     return(average);
      76: }

#### Defined functions

networkdelta defined in line 21; used 2 times

- in /usr/src/usr.sbin/timed/master.c line 290, 326

#### Defined variables

sccsid defined in line 8; never used

Last modified: 1985-12-10 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1000 |