ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/holofile.c
(Generate patch)

Comparing ray/src/hd/holofile.c (file contents):
Revision 3.34 by gwlarson, Tue Jan 19 10:08:34 1999 UTC vs.
Revision 3.39 by gwlarson, Tue Mar 9 08:40:11 1999 UTC

# Line 13 | Line 13 | static char SCCSid[] = "$SunId$ SGI";
13   #include "holo.h"
14  
15   #ifndef CACHESIZE
16 < #define CACHESIZE       16      /* default cache size (Mbytes, 0==inf) */
16 > #ifdef BIGMEM
17 > #define CACHESIZE       17      /* default cache size (Mbytes, 0==inf) */
18 > #else
19 > #define CACHESIZE       5
20   #endif
21 + #endif
22   #ifndef FREEBEAMS
23   #define FREEBEAMS       1500    /* maximum beams to free at a time */
24   #endif
# Line 26 | Line 30 | static char SCCSid[] = "$SunId$ SGI";
30   #endif
31   #ifndef FF_DEFAULT
32                                  /* when to free a beam fragment */
33 < #define FF_DEFAULT      (FF_ALLOC|FF_WRITE|FF_KILL)
33 > #define FF_DEFAULT      (FF_WRITE|FF_KILL)
34   #endif
35   #ifndef MINDIRSEL
36                                  /* minimum directory seek length */
# Line 187 | Line 191 | memerr:
191   }
192  
193  
194 < markdirty(hp, i)                /* mark holodeck directory position dirty */
194 > hdmarkdirty(hp, i)              /* mark holodeck directory position dirty */
195   register HOLO   *hp;
196   int     i;
197   {
# Line 199 | Line 203 | int    i;
203                  if (lseek(hp->fd, biglob(hp)->fo+(i-1)*sizeof(BEAMI), 0) < 0
204                                  || write(hp->fd, (char *)&smudge,
205                                          sizeof(BEAMI)) != sizeof(BEAMI))
206 <                        error(SYSTEM, "seek/write error in markdirty");
206 >                        error(SYSTEM, "seek/write error in hdmarkdirty");
207                  hp->dirseg[0].s = i;
208                  hp->dirseg[0].n = 1;
209                  return;
# Line 555 | Line 559 | int    i;
559          biglob(hp)->nrd -= bi->nrd;             /* tell fragment it's free */
560          bi->nrd = 0;
561          bi->fo = 0L;
562 +        hdmarkdirty(hp, i);                     /* assume we'll reallocate */
563          return(1);
564   }
565  
# Line 617 | Line 622 | hdsyncbeam(hp, i)              /* sync beam in memory with beam on
622   register HOLO   *hp;
623   register int    i;
624   {
625 +        int     fragfreed;
626          unsigned int4   nrays;
627          unsigned int    n;
628          long    nfo;
# Line 628 | Line 634 | register int   i;
634                                          /* is current fragment OK? */
635          if (hp->bl[i] == NULL || (nrays = hp->bl[i]->nrm) == hp->bi[i].nrd)
636                  return(0);
637 <        if (hdfragflags&FF_WRITE && hp->bi[i].nrd)
638 <                hdfreefrag(hp, i);      /* relinquish old fragment */
637 >                                        /* relinquish old fragment? */
638 >        fragfreed = hdfragflags&FF_WRITE && hp->bi[i].nrd && hdfreefrag(hp,i);
639          if (nrays) {                    /* get and write new fragment */
640                  nfo = hdallocfrag(hp->fd, nrays);
641                  errno = 0;
# Line 646 | Line 652 | register int   i;
652                  hp->bi[i].fo = 0L;
653          biglob(hp)->nrd += nrays - hp->bi[i].nrd;
654          hp->bi[i].nrd = nrays;
655 <        markdirty(hp, i);               /* section directory now out of date */
655 >        if (!fragfreed)
656 >                hdmarkdirty(hp, i);             /* need to flag dir. ent. */
657          return(1);
658   }
659  
# Line 667 | Line 674 | register int   i;
674          if (hdfragl[hp->fd].writerr)    /* check for file error */
675                  return(0);
676          if (i == 0) {                   /* clear entire holodeck */
677 +                if (blglob(hp)->nrm == 0)
678 +                        return(0);              /* already clear */
679                  nchanged = 0;
680                  for (i = nbeams(hp); i > 0; i--)
681                          if (hp->bl[i] != NULL)
682                                  nchanged += hdfreebeam(hp, i);
683 +                DCHECK(blglob(hp)->nrm != 0,
684 +                                CONSISTENCY, "bad beam count in hdfreebeam");
685                  return(nchanged);
686          }
687          DCHECK(i < 1 | i > nbeams(hp),
# Line 702 | Line 713 | register int   i;
713                  return(nchanged);
714          }
715          if (i == 0) {                   /* clobber entire holodeck */
716 +                if (biglob(hp)->nrd == 0 & blglob(hp)->nrm == 0)
717 +                        return(0);              /* already empty */
718                  nchanged = 0;
719 +                nchanged = 0;
720                  for (i = nbeams(hp); i > 0; i--)
721                          if (hp->bi[i].nrd > 0 || hp->bl[i] != NULL)
722                                  nchanged += hdkillbeam(hp, i);
# Line 715 | Line 729 | register int   i;
729          if (hp->bl[i] != NULL) {        /* free memory */
730                  blglob(hp)->nrm -= nchanged = hp->bl[i]->nrm;
731                  free((char *)hp->bl[i]);
732 +                hp->bl[i] = NULL;
733          } else
734                  nchanged = hp->bi[i].nrd;
735 <        if (hp->bi[i].nrd) {
736 <                if (hdfragflags&FF_KILL)
737 <                        hdfreefrag(hp, i);
723 <                biglob(hp)->nrd -= hp->bi[i].nrd;
724 <                hp->bi[i].nrd = 0;      /* make sure it's gone */
735 >        if (hp->bi[i].nrd && !(hdfragflags&FF_KILL && hdfreefrag(hp,i))) {
736 >                biglob(hp)->nrd -= hp->bi[i].nrd;       /* free failed */
737 >                hp->bi[i].nrd = 0;
738                  hp->bi[i].fo = 0L;
739 +                hdmarkdirty(hp, i);
740          }
727        hp->bl[i] = NULL;
741          return(nchanged);
742   }
743  
# Line 818 | Line 831 | register HOLO  *hp;            /* NULL means clean up all */
831                  return;
832          }
833                                          /* flush all data and free memory */
834 <        hdfreebeam(hp, 0);
822 <        hdsync(hp, 0);
834 >        hdflush(hp);
835                                          /* release fragment resources */
836          hdrelease(hp->fd);
837                                          /* remove hp from active list */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines