1 |
< |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1999 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
14 |
|
#include <sys/types.h> |
15 |
|
#include <sys/stat.h> |
16 |
|
|
17 |
+ |
#ifndef RTFLUSH |
18 |
+ |
#define RTFLUSH 0 /* flush one at a time in batch */ |
19 |
+ |
#endif |
20 |
+ |
#ifndef FRAGWARN |
21 |
+ |
#define FRAGWARN 20 /* fragmentation for warning (%) */ |
22 |
+ |
#endif |
23 |
|
#ifndef MAXQTIME |
24 |
|
#define MAXQTIME 5 /* target maximum seconds in queue */ |
25 |
|
#endif |
153 |
|
if (gotsig++) /* two signals and we're gone! */ |
154 |
|
_exit(signo); |
155 |
|
|
156 |
< |
alarm(60); /* allow 60 seconds to clean up */ |
156 |
> |
alarm(180); /* allow 3 minutes to clean up */ |
157 |
|
signal(SIGALRM, SIG_DFL); /* make certain we do die */ |
158 |
|
eputs("signal - "); |
159 |
|
eputs(sigerr[signo]); |
275 |
|
|
276 |
|
rholo() /* holodeck main loop */ |
277 |
|
{ |
278 |
+ |
static long nextfragwarn = 100*(1L<<20); |
279 |
|
static int idle = 0; |
280 |
|
PACKET *pl = NULL, *plend; |
281 |
+ |
long fsiz; |
282 |
|
int pksiz; |
283 |
|
register PACKET *p; |
284 |
|
time_t t; |
292 |
|
return(1); |
293 |
|
} else if (idle) |
294 |
|
return(0); /* all done */ |
295 |
< |
/* check file size */ |
296 |
< |
if (maxdisk > 0 && hdfilen(hdlist[0]->fd) >= maxdisk) { |
295 |
> |
fsiz = hdfilen(hdlist[0]->fd); /* check file size */ |
296 |
> |
if (maxdisk > 0 && fsiz >= maxdisk) { |
297 |
|
error(WARNING, "file limit exceeded"); |
298 |
|
done_rtrace(); |
299 |
|
return(1); /* comes back */ |
300 |
|
} |
301 |
+ |
#if FRAGWARN |
302 |
+ |
if (fsiz >= nextfragwarn && |
303 |
+ |
(fsiz-hdfiluse(hdlist[0]->fd,0))/(fsiz/100) > FRAGWARN) { |
304 |
+ |
sprintf(errmsg, "holodeck file fragmentation is %.0f%%", |
305 |
+ |
100.*(fsiz-hdfiluse(hdlist[0]->fd,1))/fsiz); |
306 |
+ |
error(WARNING, errmsg); |
307 |
+ |
nextfragwarn = fsiz + (fsiz>>2); /* decent interval */ |
308 |
+ |
} |
309 |
+ |
#endif |
310 |
|
t = time(NULL); /* check time */ |
311 |
|
if (endtime > 0 && t >= endtime) { |
312 |
|
error(WARNING, "time limit exceeded"); |
384 |
|
for (i = 0; i < 3; i++) |
385 |
|
len[i] = VLEN(gp->xv[i]); |
386 |
|
if (!vdef(GRID)) { |
387 |
< |
d = 2/5e5*( len[0]*len[0]*(len[1]*len[1] + |
387 |
> |
d = 2/2e5*( len[0]*len[0]*(len[1]*len[1] + |
388 |
|
len[2]*len[2] + 4*len[1]*len[2]) |
389 |
|
+ len[1]*len[1]*len[2]*(len[2] + 4*len[0]) |
390 |
|
+ 4*len[0]*len[1]*len[2]*len[2] ); |
437 |
|
} |
438 |
|
|
439 |
|
|
440 |
+ |
int |
441 |
|
headline(s) /* process information header line */ |
442 |
|
char *s; |
443 |
|
{ |
451 |
|
HOLOFMT, hdkfile, FMTSTR, fmt); |
452 |
|
error(USER, errmsg); |
453 |
|
} |
454 |
< |
return; |
454 |
> |
return(0); |
455 |
|
} |
456 |
|
for (cp = s; *cp; cp++) /* take off any comments */ |
457 |
|
if (*cp == '#') { |
459 |
|
break; |
460 |
|
} |
461 |
|
setvariable(s, matchvar); /* don't flag errors */ |
462 |
+ |
return(0); |
463 |
|
} |
464 |
|
|
465 |
|
|
514 |
|
p->nr*sizeof(RAYVAL)); |
515 |
|
if (outdev != NULL) /* display it */ |
516 |
|
disp_packet((PACKHEAD *)p); |
517 |
< |
if (hdcachesize <= 0) /* manual flushing */ |
517 |
> |
if (hdcachesize <= 0) { |
518 |
> |
#if RTFLUSH |
519 |
> |
if (outdev == NULL) |
520 |
> |
hdfreebeam(hdlist[p->hd], p->bi); |
521 |
> |
#endif |
522 |
|
n2flush++; |
523 |
+ |
} |
524 |
|
nraysdone += p->nr; |
525 |
|
npacksdone++; |
526 |
|
p->nr = 0; |
533 |
|
#else |
534 |
|
if (n2flush > 50*totqlen) { |
535 |
|
#endif |
536 |
< |
if (outdev == NULL) |
537 |
< |
hdflush(NULL); /* flush holodeck buffers */ |
536 |
> |
#if RTFLUSH |
537 |
> |
hdsync(NULL, outdev!=NULL); /* sync beams & directories */ |
538 |
> |
#else |
539 |
> |
if (outdev != NULL) |
540 |
> |
hdsync(NULL, 1); |
541 |
|
else |
542 |
< |
hdsync(NULL, 1); /* sync holodeck file */ |
542 |
> |
hdflush(NULL); |
543 |
> |
#endif |
544 |
|
n2flush = 0; |
545 |
|
} |
546 |
|
} |