| 162 |
|
|
| 163 |
|
int ray_pnprocs = 0; /* number of child processes */ |
| 164 |
|
int ray_pnidle = 0; /* number of idle children */ |
| 165 |
– |
int ray_pnbatch = 0; /* throughput over responsiveness? */ |
| 165 |
|
|
| 166 |
|
static struct child_proc { |
| 167 |
|
RT_PID pid; /* child process id */ |
| 212 |
|
for (i = ray_pnprocs; nc && i--; ) { |
| 213 |
|
if (r_proc[i].npending > 0) |
| 214 |
|
continue; /* child looks busy */ |
| 215 |
< |
n = r_send_next - sfirst; |
| 217 |
< |
if (ray_pnbatch) |
| 218 |
< |
nc--; /* maximize bundling for batch calc */ |
| 219 |
< |
else |
| 220 |
< |
n /= nc--; /* distribute work for interactivity */ |
| 215 |
> |
n = (r_send_next - sfirst) / nc--; |
| 216 |
|
if (!n) |
| 217 |
|
continue; |
| 218 |
|
/* smuggle set size in crtype */ |
| 456 |
|
nadd = MAX_NPROCS - ray_pnprocs; |
| 457 |
|
if (nadd <= 0) |
| 458 |
|
return; |
| 459 |
+ |
if (nobjects <= 0) |
| 460 |
+ |
error(CONSISTENCY, "ray_popen() called before scene loaded"); |
| 461 |
|
ambsync(); /* load any new ambient values */ |
| 462 |
|
if (shm_boundary == NULL) { /* first child process? */ |
| 463 |
|
preload_objs(); /* preload auxiliary data */ |
| 512 |
|
static int inclose = 0; |
| 513 |
|
RAY res; |
| 514 |
|
int i, status = 0; |
| 515 |
+ |
/* check no child / in child */ |
| 516 |
+ |
if (ray_pnprocs <= 0) |
| 517 |
+ |
return; |
| 518 |
|
/* check recursion */ |
| 519 |
|
if (inclose) |
| 520 |
|
return; |
| 521 |
|
inclose++; |
| 522 |
– |
/* check no child / in child */ |
| 523 |
– |
if (ray_pnprocs <= 0) |
| 524 |
– |
return; |
| 522 |
|
/* check argument */ |
| 523 |
|
if ((nsub <= 0) | (nsub > ray_pnprocs)) |
| 524 |
|
nsub = ray_pnprocs; |
| 525 |
|
/* clear our ray queue */ |
| 526 |
+ |
i = r_send_next; |
| 527 |
+ |
r_send_next = 0; |
| 528 |
|
while (ray_presult(&res,0) > 0) |
| 529 |
< |
; |
| 530 |
< |
r_send_next = 0; /* hard reset in case of error */ |
| 529 |
> |
++i; |
| 530 |
> |
if (i) { |
| 531 |
> |
sprintf(errmsg, "dropped %d rays in ray_pclose()", i); |
| 532 |
> |
error(WARNING, errmsg); |
| 533 |
> |
} |
| 534 |
|
r_recv_first = r_recv_next = RAYQLEN; |
| 535 |
|
/* close send pipes */ |
| 536 |
|
for (i = ray_pnprocs-nsub; i < ray_pnprocs; i++) |
| 544 |
|
for (i = 0; i < nsub; ) { |
| 545 |
|
int j, mystatus; |
| 546 |
|
RT_PID pid = wait(&mystatus); |
| 547 |
+ |
if (pid < 0) { |
| 548 |
+ |
status = 127<<8; |
| 549 |
+ |
break; |
| 550 |
+ |
} |
| 551 |
|
for (j = ray_pnprocs-nsub; j < ray_pnprocs; j++) |
| 552 |
|
if (r_proc[j].pid == pid) { |
| 553 |
|
if (mystatus) |