| 124 |
|
* but otherwise your process should not be compromised. |
| 125 |
|
*/ |
| 126 |
|
|
| 127 |
< |
#include "ray.h" |
| 127 |
> |
#include <stdio.h> |
| 128 |
> |
#include <sys/types.h> |
| 129 |
> |
#include <sys/wait.h> /* XXX platform */ |
| 130 |
|
|
| 131 |
+ |
#include "rtprocess.h" |
| 132 |
+ |
#include "ray.h" |
| 133 |
+ |
#include "ambient.h" |
| 134 |
|
#include "selcall.h" |
| 135 |
|
|
| 136 |
|
#ifndef RAYQLEN |
| 165 |
|
|
| 166 |
|
#define sendq_full() (r_send_next >= RAYQLEN) |
| 167 |
|
|
| 168 |
+ |
static int ray_pflush(void); |
| 169 |
+ |
static void ray_pchild(int fd_in, int fd_out); |
| 170 |
|
|
| 171 |
< |
void |
| 172 |
< |
ray_pinit(otnm, nproc) /* initialize ray-tracing processes */ |
| 173 |
< |
char *otnm; |
| 174 |
< |
int nproc; |
| 171 |
> |
|
| 172 |
> |
extern void |
| 173 |
> |
ray_pinit( /* initialize ray-tracing processes */ |
| 174 |
> |
char *otnm, |
| 175 |
> |
int nproc |
| 176 |
> |
) |
| 177 |
|
{ |
| 178 |
|
if (nobjects > 0) /* close old calculation */ |
| 179 |
|
ray_pdone(0); |
| 194 |
|
|
| 195 |
|
|
| 196 |
|
static int |
| 197 |
< |
ray_pflush() /* send queued rays to idle children */ |
| 197 |
> |
ray_pflush(void) /* send queued rays to idle children */ |
| 198 |
|
{ |
| 199 |
|
int nc, n, nw, i, sfirst; |
| 200 |
|
|
| 201 |
< |
if ((ray_pnidle <= 0 | r_send_next <= 0)) |
| 201 |
> |
if ((ray_pnidle <= 0) | (r_send_next <= 0)) |
| 202 |
|
return(0); /* nothing we can send */ |
| 203 |
|
|
| 204 |
|
sfirst = 0; /* divvy up labor */ |
| 228 |
|
} |
| 229 |
|
|
| 230 |
|
|
| 231 |
< |
void |
| 232 |
< |
ray_psend(r) /* add a ray to our send queue */ |
| 233 |
< |
RAY *r; |
| 231 |
> |
extern void |
| 232 |
> |
ray_psend( /* add a ray to our send queue */ |
| 233 |
> |
RAY *r |
| 234 |
> |
) |
| 235 |
|
{ |
| 236 |
|
if (r == NULL) |
| 237 |
|
return; |
| 244 |
|
} |
| 245 |
|
|
| 246 |
|
|
| 247 |
< |
int |
| 248 |
< |
ray_pqueue(r) /* queue a ray for computation */ |
| 249 |
< |
RAY *r; |
| 247 |
> |
extern int |
| 248 |
> |
ray_pqueue( /* queue a ray for computation */ |
| 249 |
> |
RAY *r |
| 250 |
> |
) |
| 251 |
|
{ |
| 252 |
|
if (r == NULL) |
| 253 |
|
return(0); |
| 276 |
|
} |
| 277 |
|
|
| 278 |
|
|
| 279 |
< |
int |
| 280 |
< |
ray_presult(r, poll) /* check for a completed ray */ |
| 281 |
< |
RAY *r; |
| 282 |
< |
int poll; |
| 279 |
> |
extern int |
| 280 |
> |
ray_presult( /* check for a completed ray */ |
| 281 |
> |
RAY *r, |
| 282 |
> |
int poll |
| 283 |
> |
) |
| 284 |
|
{ |
| 285 |
|
static struct timeval tpoll; /* zero timeval struct */ |
| 286 |
|
static fd_set readset, errset; |
| 372 |
|
} |
| 373 |
|
|
| 374 |
|
|
| 375 |
< |
void |
| 376 |
< |
ray_pdone(freall) /* reap children and free data */ |
| 377 |
< |
int freall; |
| 375 |
> |
extern void |
| 376 |
> |
ray_pdone( /* reap children and free data */ |
| 377 |
> |
int freall |
| 378 |
> |
) |
| 379 |
|
{ |
| 380 |
|
ray_pclose(0); /* close child processes */ |
| 381 |
|
|
| 388 |
|
|
| 389 |
|
|
| 390 |
|
static void |
| 391 |
< |
ray_pchild(fd_in, fd_out) /* process rays (never returns) */ |
| 392 |
< |
int fd_in; |
| 393 |
< |
int fd_out; |
| 391 |
> |
ray_pchild( /* process rays (never returns) */ |
| 392 |
> |
int fd_in, |
| 393 |
> |
int fd_out |
| 394 |
> |
) |
| 395 |
|
{ |
| 396 |
|
int n; |
| 397 |
|
register int i; |
| 435 |
|
} |
| 436 |
|
|
| 437 |
|
|
| 438 |
< |
void |
| 439 |
< |
ray_popen(nadd) /* open the specified # processes */ |
| 440 |
< |
int nadd; |
| 438 |
> |
extern void |
| 439 |
> |
ray_popen( /* open the specified # processes */ |
| 440 |
> |
int nadd |
| 441 |
> |
) |
| 442 |
|
{ |
| 443 |
|
/* check if our table has room */ |
| 444 |
|
if (ray_pnprocs + nadd > MAX_NPROCS) |
| 473 |
|
} |
| 474 |
|
|
| 475 |
|
|
| 476 |
< |
void |
| 477 |
< |
ray_pclose(nsub) /* close one or more child processes */ |
| 478 |
< |
int nsub; |
| 476 |
> |
extern void |
| 477 |
> |
ray_pclose( /* close one or more child processes */ |
| 478 |
> |
int nsub |
| 479 |
> |
) |
| 480 |
|
{ |
| 481 |
|
static int inclose = 0; |
| 482 |
|
RAY res; |
| 485 |
|
return; |
| 486 |
|
inclose++; |
| 487 |
|
/* check argument */ |
| 488 |
< |
if ((nsub <= 0 | nsub > ray_pnprocs)) |
| 488 |
> |
if ((nsub <= 0) | (nsub > ray_pnprocs)) |
| 489 |
|
nsub = ray_pnprocs; |
| 490 |
|
/* clear our ray queue */ |
| 491 |
|
while (ray_presult(&res,0) > 0) |