--- ray/src/hd/rholo.c 1998/12/30 08:02:37 3.44 +++ ray/src/hd/rholo.c 1999/03/09 08:51:39 3.50 @@ -1,4 +1,4 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ +/* Copyright (c) 1999 Silicon Graphics, Inc. */ #ifndef lint static char SCCSid[] = "$SunId$ SGI"; @@ -11,7 +11,6 @@ static char SCCSid[] = "$SunId$ SGI"; #include "rholo.h" #include "random.h" #include -#include #include #ifndef FRAGWARN @@ -20,6 +19,14 @@ static char SCCSid[] = "$SunId$ SGI"; #ifndef MAXQTIME #define MAXQTIME 5 /* target maximum seconds in queue */ #endif + /* manual cache flushing frequency */ +#ifndef RTFLUSH +#if MAXQTIME +#define RTFLUSH (300/MAXQTIME*totqlen) /* <= 5 minutes */ +#else +#define RTFLUSH (50*totqlen) /* just guess */ +#endif +#endif /* the following must be consistent with rholo.h */ int NVARS = NRHVARS; /* total number of variables */ @@ -52,7 +59,7 @@ long nraysdone = 0L; /* number of rays done */ long npacksdone = 0L; /* number of packets done */ PACKET *freepacks; /* available packets */ -int totqlen; /* maximum queue length when full */ +int totqlen; /* maximum queue length (number of packets) */ char *sigerr[NSIG]; /* signal error messages */ @@ -147,11 +154,13 @@ int signo; { static int gotsig = 0; - if (gotsig++) /* two signals and we're gone! */ + if (gotsig > 1) /* we're going as fast as we can! */ + return; + if (gotsig++) { /* two signals and we split */ + hdsync(NULL, 0); /* don't leave w/o saying goodbye */ _exit(signo); - - alarm(60); /* allow 60 seconds to clean up */ - signal(SIGALRM, SIG_DFL); /* make certain we do die */ + } + alarm(300); /* allow 5 minutes to clean up */ eputs("signal - "); eputs(sigerr[signo]); eputs("\n"); @@ -207,7 +216,7 @@ initrholo() /* get our holodeck running */ maxdisk = 1024.*1024.*vflt(DISKSPACE); /* set up memory cache */ if (outdev == NULL) - hdcachesize = 0; /* manual flushing */ + hdcachesize = 0; /* manual flushing */ else if (vdef(CACHE)) hdcachesize = 1024.*1024.*vflt(CACHE); /* open report file */ @@ -262,7 +271,7 @@ initrholo() /* get our holodeck running */ sigdie(SIGXCPU, "CPU limit exceeded"); sigdie(SIGXFSZ, "File size exceeded"); #endif - /* protect holodeck file */ + /* protect holodeck file */ orig_mode = resfmode(hdlist[0]->fd, ncprocs>0 ? 0 : 0444); return; memerr: @@ -313,13 +322,14 @@ rholo() /* holodeck main loop */ if (reporttime > 0 && t >= reporttime) report(t); /* figure out good packet size */ + pksiz = RPACKSIZ; #if MAXQTIME - pksiz = nraysdone*MAXQTIME/(totqlen*(t - starttime + 1L)); - if (pksiz < 1) - pksiz = 1; - else if (pksiz > RPACKSIZ) + if (!chunkycmp) { + pksiz = nraysdone*MAXQTIME/(totqlen*(t - starttime + 1L)); + if (pksiz < 1) pksiz = 1; + else if (pksiz > RPACKSIZ) pksiz = RPACKSIZ; + } #endif - pksiz = RPACKSIZ; idle = 0; /* get packets to process */ while (freepacks != NULL) { p = freepacks; freepacks = p->next; p->next = NULL; @@ -511,7 +521,7 @@ PACKET *pl; p->nr*sizeof(RAYVAL)); if (outdev != NULL) /* display it */ disp_packet((PACKHEAD *)p); - if (hdcachesize <= 0) /* manual flushing */ + if (hdcachesize <= 0) n2flush++; nraysdone += p->nr; npacksdone++; @@ -520,15 +530,11 @@ PACKET *pl; p->next = freepacks; /* push onto free list */ freepacks = p; } -#if MAXQTIME - if (n2flush > 300/MAXQTIME*totqlen) { -#else - if (n2flush > 50*totqlen) { -#endif - if (outdev == NULL) - hdflush(NULL); /* flush holodeck buffers */ + if (n2flush >= RTFLUSH) { + if (outdev != NULL) + hdsync(NULL, 1); else - hdsync(NULL, 1); /* sync holodeck file */ + hdflush(NULL); n2flush = 0; } }