--- ray/src/hd/rholo.c 1998/10/08 14:52:26 3.41 +++ ray/src/hd/rholo.c 1999/01/07 22:05:34 3.46 @@ -1,4 +1,4 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ +/* Copyright (c) 1999 Silicon Graphics, Inc. */ #ifndef lint static char SCCSid[] = "$SunId$ SGI"; @@ -14,6 +14,12 @@ static char SCCSid[] = "$SunId$ SGI"; #include #include +#ifndef RTFLUSH +#define RTFLUSH 0 /* flush one at a time in batch */ +#endif +#ifndef FRAGWARN +#define FRAGWARN 20 /* fragmentation for warning (%) */ +#endif #ifndef MAXQTIME #define MAXQTIME 5 /* target maximum seconds in queue */ #endif @@ -147,7 +153,7 @@ int signo; if (gotsig++) /* two signals and we're gone! */ _exit(signo); - alarm(60); /* allow 60 seconds to clean up */ + alarm(180); /* allow 3 minutes to clean up */ signal(SIGALRM, SIG_DFL); /* make certain we do die */ eputs("signal - "); eputs(sigerr[signo]); @@ -269,8 +275,10 @@ memerr: rholo() /* holodeck main loop */ { + static long nextfragwarn = 100*(1L<<20); static int idle = 0; PACKET *pl = NULL, *plend; + long fsiz; int pksiz; register PACKET *p; time_t t; @@ -284,12 +292,21 @@ rholo() /* holodeck main loop */ return(1); } else if (idle) return(0); /* all done */ - /* check file size */ - if (maxdisk > 0 && hdfilen(hdlist[0]->fd) >= maxdisk) { + fsiz = hdfilen(hdlist[0]->fd); /* check file size */ + if (maxdisk > 0 && fsiz >= maxdisk) { error(WARNING, "file limit exceeded"); done_rtrace(); return(1); /* comes back */ } +#if FRAGWARN + if (fsiz >= nextfragwarn && + (fsiz-hdfiluse(hdlist[0]->fd,0))/(fsiz/100) > FRAGWARN) { + sprintf(errmsg, "holodeck file fragmentation is %.0f%%", + 100.*(fsiz-hdfiluse(hdlist[0]->fd,1))/fsiz); + error(WARNING, errmsg); + nextfragwarn = fsiz + (fsiz>>2); /* decent interval */ + } +#endif t = time(NULL); /* check time */ if (endtime > 0 && t >= endtime) { error(WARNING, "time limit exceeded"); @@ -367,7 +384,7 @@ register HDGRID *gp; for (i = 0; i < 3; i++) len[i] = VLEN(gp->xv[i]); if (!vdef(GRID)) { - d = 2/5e5*( len[0]*len[0]*(len[1]*len[1] + + d = 2/2e5*( len[0]*len[0]*(len[1]*len[1] + len[2]*len[2] + 4*len[1]*len[2]) + len[1]*len[1]*len[2]*(len[2] + 4*len[0]) + 4*len[0]*len[1]*len[2]*len[2] ); @@ -420,6 +437,7 @@ HDGRID *gp; } +int headline(s) /* process information header line */ char *s; { @@ -433,7 +451,7 @@ char *s; HOLOFMT, hdkfile, FMTSTR, fmt); error(USER, errmsg); } - return; + return(0); } for (cp = s; *cp; cp++) /* take off any comments */ if (*cp == '#') { @@ -441,6 +459,7 @@ char *s; break; } setvariable(s, matchvar); /* don't flag errors */ + return(0); } @@ -495,8 +514,13 @@ PACKET *pl; p->nr*sizeof(RAYVAL)); if (outdev != NULL) /* display it */ disp_packet((PACKHEAD *)p); - if (hdcachesize <= 0) /* manual flushing */ + if (hdcachesize <= 0) { +#if RTFLUSH + if (outdev == NULL) + hdfreebeam(hdlist[p->hd], p->bi); +#endif n2flush++; + } nraysdone += p->nr; npacksdone++; p->nr = 0; @@ -509,10 +533,14 @@ PACKET *pl; #else if (n2flush > 50*totqlen) { #endif - if (outdev == NULL) - hdflush(NULL); /* flush holodeck buffers */ +#if RTFLUSH + hdsync(NULL, outdev!=NULL); /* sync beams & directories */ +#else + if (outdev != NULL) + hdsync(NULL, 1); else - hdsync(NULL, 1); /* sync holodeck file */ + hdflush(NULL); +#endif n2flush = 0; } }