Annotation of 43BSDTahoe/etc/timed/networkdelta.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted
                      6:  * provided that the above copyright notice and this paragraph are
                      7:  * duplicated in all such forms and that any documentation,
                      8:  * advertising materials, and other materials related to such
                      9:  * distribution and use acknowledge that the software was developed
                     10:  * by the University of California, Berkeley.  The name of the
                     11:  * University may not be used to endorse or promote products derived
                     12:  * from this software without specific prior written permission.
                     13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     16:  */
                     17: 
                     18: #ifndef lint
                     19: static char sccsid[] = "@(#)networkdelta.c     2.3 (Berkeley) 6/18/88";
                     20: #endif /* not lint */
                     21: 
                     22: #include "globals.h"
                     23: #include <protocols/timed.h>
                     24: 
                     25: extern int machup;
                     26: 
                     27: /*
                     28:  * `networkdelta' selects the largest set of deltas that fall within the
                     29:  * interval RANGE, and uses them to compute the network average delta 
                     30:  */
                     31: 
                     32: long networkdelta()
                     33: {
                     34:        int i, j, maxind, minind;
                     35:        int ext;
                     36:        int tempind;
                     37:        long tempdata;
                     38:        long x[NHOSTS];
                     39:        long average;
                     40: 
                     41:        for (i=0; i<slvcount; i++)
                     42:                x[i] = hp[i].delta;
                     43:        for (i=0; i<slvcount-1; i++) {
                     44:                tempdata = x[i];
                     45:                tempind = i;
                     46:                for (j=i+1; j<slvcount; j++) {
                     47:                        if (x[j] < tempdata) {
                     48:                                tempdata = x[j];
                     49:                                tempind = j;
                     50:                        }
                     51:                }
                     52:                x[tempind] = x[i];
                     53:                x[i] = tempdata;
                     54:        }
                     55: 
                     56:        /* this piece of code is critical: DO NOT TOUCH IT! */
                     57: /****/
                     58:        i=0; j=1; minind=0; maxind=1;
                     59:        if (machup == 2)
                     60:                goto compute;
                     61:        do {
                     62:                if (x[j]-x[i] <= RANGE)
                     63:                        j++;
                     64:                else {
                     65:                        if (j > i+1) 
                     66:                                j--; 
                     67:                        if ((x[j]-x[i] <= RANGE) && (j-i >= maxind-minind)) {
                     68:                                minind=i;
                     69:                                maxind=j;
                     70:                        }       
                     71:                        i++;
                     72:                        if(i = j)
                     73:                                j++;
                     74:                }
                     75:        } while (j < machup);
                     76:        if ((x[machup-1] - x[i] <= RANGE) && (machup-i-1 >= maxind-minind)) {
                     77:                minind=i; maxind=machup-1;
                     78:        }
                     79: /****/
                     80: compute:
                     81:        ext = maxind - minind + 1;
                     82:        average = 0;
                     83:        for (i=minind; i<=maxind; i++)
                     84:                average += x[i];
                     85:        average /= ext;
                     86:        return(average);
                     87: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.