|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include "trace.h" ! 3: #include "trace.d" ! 4: ! 5: extern int *processes, *state, nrprocs, nrtbl; ! 6: extern char mask[MAXPROC], althash; ! 7: extern struct TBL *tbl; ! 8: ! 9: short *Factor; ! 10: short maxr = 0; ! 11: ! 12: inihash() ! 13: { register int i; ! 14: char *Smalloc(); ! 15: ! 16: for (i = 0; i < nrtbl; i++) ! 17: if (tbl[i].nrrows > maxr) ! 18: maxr = tbl[i].nrrows; ! 19: ! 20: Factor = (short *) ! 21: Smalloc(maxr * sizeof(short)); ! 22: ! 23: for (i = 0; i < maxr; i++) ! 24: Factor[i] = rand()%NOTOOBIG; /* number between 0 and 16k */ ! 25: } ! 26: ! 27: hashvalue() ! 28: { register int i, h; ! 29: ! 30: for (i = h = 0; i < nrprocs; i++) ! 31: { if (mask[i]) ! 32: continue; ! 33: h = ((h << 2) | (h >> 13)); /* rotate */ ! 34: h ^= Factor[state[i]] ^ Factor[processes[i]]; ! 35: } ! 36: ! 37: return (h & NOTOOBIG); /* return value will be stored in a short */ ! 38: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.