--- ray/src/util/rad.c 2010/05/18 18:54:35 2.95 +++ ray/src/util/rad.c 2010/10/08 22:11:57 2.99 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rad.c,v 2.95 2010/05/18 18:54:35 greg Exp $"; +static const char RCSid[] = "$Id: rad.c,v 2.99 2010/10/08 22:11:57 greg Exp $"; #endif /* * Executive program for oconv, rpict and pfilt @@ -165,7 +165,7 @@ static int touch(char *fn); static int runcom(char *cs); static int rmfile(char *fn); static int mvfile(char *fold, char *fnew); -static int next_process(void); +static int next_process(int reserve); static void wait_process(int all); static void finish_process(void); static void badvalue(int vc); @@ -751,7 +751,7 @@ lowqopts( /* low quality rendering options */ op = addarg(op, "-ds .4"); else op = addarg(op, "-ds 0"); - op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5"); + op = addarg(op, "-dt .2 -dc .25 -dr 0 -ss 0 -st .5"); if (vdef(AMBFILE)) { sprintf(op, " -af %s", vval(AMBFILE)); op += strlen(op); @@ -826,7 +826,7 @@ medqopts( /* medium quality rendering options */ op = addarg(op, "-ds .2 -dj .9"); else op = addarg(op, "-ds .3"); - op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); + op = addarg(op, "-dt .1 -dc .5 -dr 1 -ss .7 -st .1"); if ( (overture = vint(INDIRECT)) ) { sprintf(op, " -ab %d", overture); op += strlen(op); @@ -904,7 +904,7 @@ hiqopts( /* high quality rendering options */ op = addarg(op, "-ds .1 -dj .9"); else op = addarg(op, "-ds .2"); - op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); + op = addarg(op, "-dt .05 -dc .75 -dr 3 -ss 1 -st .01"); sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); op += strlen(op); if (vdef(AMBFILE)) { @@ -1361,7 +1361,7 @@ rpict( /* run rpict and pfilt for each view */ int xdiv = 8+nprocs/3, ydiv = 8+nprocs/3; rfdt = 0; /* start fresh */ if (!silent) - printf("echo %d %d > %s\n", + printf("\techo %d %d > %s\n", xdiv, ydiv, sfile); if ((fp = fopen(sfile, "w")) == NULL) { fprintf(stderr, "%s: cannot create\n", @@ -1371,7 +1371,7 @@ rpict( /* run rpict and pfilt for each view */ fprintf(fp, "%d %d\n", xdiv, ydiv); fclose(fp); } - } else if (next_process()) { + } else if (next_process(0)) { if (pfile != NULL) sleep(10); continue; @@ -1384,8 +1384,7 @@ rpict( /* run rpict and pfilt for each view */ sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s", c_rpiece, sfile, rppopt, rep, vw, res, opts, po, rawfile, oct1name); - while (children_running < nprocs-1 && - next_process()) { + while (next_process(1)) { sleep(10); combuf[strlen(c_rpiece)+2] = 'F'; } @@ -1400,12 +1399,19 @@ rpict( /* run rpict and pfilt for each view */ "%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", c_rpict, rep, vw, opts, oct1name, overfile); + if (do_rpiece) + while (next_process(1)) + sleep(5); if (runcom(combuf)) { fprintf(stderr, "%s: error in overture for view %s\n", progname, vs); quit(1); } + if (do_rpiece) { + finish_process(); + wait_process(1); + } #ifndef NULL_DEVICE rmfile(overfile); #endif @@ -1414,8 +1420,7 @@ rpict( /* run rpict and pfilt for each view */ sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s", c_rpiece, sfile, rppopt, rep, vw, res, opts, po, rawfile, oct1name); - while (children_running < nprocs-1 && - next_process()) + while (next_process(1)) sleep(10); } else { sprintf(combuf, "%s%s %s %s%s%s%s %s > %s", @@ -1546,7 +1551,7 @@ mvfile( /* move a file */ #ifdef RHAS_FORK_EXEC static int -next_process(void) /* fork the next process (max. nprocs) */ +next_process(int reserve) /* fork the next process */ { RT_PID child_pid; @@ -1557,6 +1562,8 @@ next_process(void) /* fork the next process (max. np progname); quit(1); } + if (reserve > 0 && children_running >= nprocs-reserve) + return(0); /* caller holding back process(es) */ if (children_running >= nprocs) wait_process(0); /* wait for someone to finish */ fflush(NULL); /* flush output */ @@ -1604,7 +1611,7 @@ wait_process( /* wait for process(es) to finish */ } #else /* ! RHAS_FORK_EXEC */ static int -next_process(void) +next_process(int reserve) { return(0); /* cannot start new process */ }