| 1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
| 1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
| 16 |
|
#define CACHESIZE 16 /* default cache size (Mbytes, 0==inf) */ |
| 17 |
|
#endif |
| 18 |
|
#ifndef FREEBEAMS |
| 19 |
< |
#define FREEBEAMS 512 /* maximum beams to free at a time */ |
| 19 |
> |
#define FREEBEAMS 1024 /* maximum beams to free at a time */ |
| 20 |
|
#endif |
| 21 |
|
#ifndef PCTFREE |
| 22 |
< |
#define PCTFREE 20 /* maximum fraction to free (%) */ |
| 22 |
> |
#define PCTFREE 15 /* maximum fraction to free (%) */ |
| 23 |
|
#endif |
| 24 |
|
#ifndef MAXFRAG |
| 25 |
|
#define MAXFRAG 32767 /* maximum fragments/file to track (0==inf) */ |
| 105 |
|
int fd; /* corresponding file descriptor */ |
| 106 |
|
HDGRID *hproto; /* holodeck section grid */ |
| 107 |
|
{ |
| 108 |
+ |
long rtrunc; |
| 109 |
|
long fpos; |
| 110 |
|
register HOLO *hp; |
| 111 |
|
register int n; |
| 127 |
|
error(SYSTEM, "failure loading holodeck directory"); |
| 128 |
|
/* check that it's clean */ |
| 129 |
|
if (hp->bi[nbeams(hp)].fo < 0) |
| 130 |
< |
error(USER, "dirty holodeck section"); |
| 130 |
> |
error(WARNING, "dirty holodeck section"); |
| 131 |
|
} else { /* assume we're creating it */ |
| 132 |
|
if ((hp = hdalloc(hproto)) == NULL) |
| 133 |
|
goto memerr; |
| 145 |
|
hdattach(fd); |
| 146 |
|
/* check rays on disk */ |
| 147 |
|
fpos = hdfilen(fd); |
| 148 |
< |
biglob(hp)->nrd = 0; |
| 148 |
> |
biglob(hp)->nrd = rtrunc = 0; |
| 149 |
|
for (n = hproto == NULL ? nbeams(hp) : 0; n > 0; n--) |
| 150 |
|
if (hp->bi[n].nrd) |
| 151 |
< |
if (hp->bi[n].fo + hp->bi[n].nrd > fpos) |
| 152 |
< |
hp->bi[n].nrd = 0; /* off end */ |
| 153 |
< |
else |
| 151 |
> |
if (hp->bi[n].fo + hp->bi[n].nrd > fpos) { |
| 152 |
> |
rtrunc += hp->bi[n].nrd; |
| 153 |
> |
hp->bi[n].nrd = 0; |
| 154 |
> |
} else |
| 155 |
|
biglob(hp)->nrd += hp->bi[n].nrd; |
| 156 |
+ |
if (rtrunc) { |
| 157 |
+ |
sprintf(errmsg, "truncated section, %ld rays lost (%.1f%%)", |
| 158 |
+ |
rtrunc, 100.*rtrunc/(rtrunc+biglob(hp)->nrd)); |
| 159 |
+ |
error(WARNING, errmsg); |
| 160 |
+ |
} |
| 161 |
|
/* add to holodeck list */ |
| 162 |
|
for (n = 0; n < HDMAX; n++) |
| 163 |
|
if (hdlist[n] == NULL) { |
| 379 |
|
int (*bf)(); /* callback function (optional) */ |
| 380 |
|
{ |
| 381 |
|
unsigned origcachesize, memuse; |
| 375 |
– |
register BEAM *bp; |
| 382 |
|
int bytesloaded, needbytes, bytes2free; |
| 383 |
+ |
register BEAM *bp; |
| 384 |
|
register int i; |
| 385 |
|
/* precheck consistency */ |
| 386 |
|
for (i = n; i--; ) |
| 390 |
|
qsort((char *)hb, n, sizeof(HDBEAMI), hdfilord); |
| 391 |
|
bytesloaded = 0; /* run through loaded beams */ |
| 392 |
|
for ( ; n && (bp = hb->h->bl[hb->b]) != NULL; n--, hb++) { |
| 393 |
< |
bp->tick = hdclock; /* preempt swap */ |
| 393 |
> |
bp->tick = hdclock; /* preempt swap */ |
| 394 |
|
bytesloaded += bp->nrm; |
| 395 |
|
if (bf != NULL) |
| 396 |
< |
(*bf)(bp, hb->h, hb->b); |
| 396 |
> |
(*bf)(bp, hb); |
| 397 |
|
} |
| 398 |
|
bytesloaded *= sizeof(RAYVAL); |
| 399 |
|
if ((origcachesize = hdcachesize) > 0) { |
| 412 |
|
} |
| 413 |
|
for (i = 0; i < n; i++) |
| 414 |
|
if ((bp = hdgetbeam(hb[i].h, hb[i].b)) != NULL && bf != NULL) |
| 415 |
< |
(*bf)(bp, hb[i].h, hb[i].b); |
| 415 |
> |
(*bf)(bp, hb+i); |
| 416 |
|
hdcachesize = origcachesize; /* resume dynamic swapping */ |
| 417 |
|
} |
| 418 |
|
|
| 648 |
|
{ |
| 649 |
|
register int i, j; |
| 650 |
|
/* insert each beam from hp */ |
| 651 |
< |
for (i = nbeams(hp); i > 0; i--) { |
| 651 |
> |
for (i = 1; i <= nbeams(hp); i++) { |
| 652 |
|
if (hp->bl[i] == NULL) /* check if loaded */ |
| 653 |
|
continue; |
| 654 |
|
#if 0 |