| 37 |
|
static void killpersist(void); |
| 38 |
|
|
| 39 |
|
|
| 40 |
< |
extern int |
| 40 |
> |
int |
| 41 |
|
start_rtrace(void) /* start rtrace process */ |
| 42 |
|
{ |
| 43 |
|
static char buf1[8]; |
| 59 |
|
rtargv[rtargc++] = "-I-"; |
| 60 |
|
rtargv[rtargc++] = "-h-"; |
| 61 |
|
rtargv[rtargc++] = "-ld-"; |
| 62 |
+ |
rtargv[rtargc++] = "-co-"; |
| 63 |
|
sprintf(buf1, "%d", RPACKSIZ); |
| 64 |
|
rtargv[rtargc++] = "-x"; rtargv[rtargc++] = buf1; |
| 65 |
|
rtargv[rtargc++] = "-y"; rtargv[rtargc++] = "0"; |
| 100 |
|
bestout(void) /* get best process to process packet */ |
| 101 |
|
{ |
| 102 |
|
int cnt; |
| 103 |
< |
register int pn, i; |
| 103 |
> |
int pn, i; |
| 104 |
|
|
| 105 |
|
pn = 0; /* find shortest queue */ |
| 106 |
|
for (i = 1; i < nprocs; i++) |
| 114 |
|
if (pqlen[i] == pqlen[pn]) |
| 115 |
|
cnt++; |
| 116 |
|
/* break ties fairly */ |
| 117 |
< |
if ((cnt = random() % cnt)) |
| 117 |
> |
if ((cnt = irandom(cnt))) |
| 118 |
|
for (i = pn; i < nprocs; i++) |
| 119 |
|
if (pqlen[i] == pqlen[pn] && !cnt--) |
| 120 |
|
return(i); |
| 125 |
|
static int |
| 126 |
|
slots_avail(void) /* count packet slots available */ |
| 127 |
|
{ |
| 128 |
< |
register int nslots = 0; |
| 129 |
< |
register int i; |
| 128 |
> |
int nslots = 0; |
| 129 |
> |
int i; |
| 130 |
|
|
| 131 |
|
for (i = nprocs; i--; ) |
| 132 |
|
nslots += maxqlen - pqlen[i]; |
| 136 |
|
|
| 137 |
|
static void |
| 138 |
|
queue_packet( /* queue up a beam packet */ |
| 139 |
< |
register PACKET *p |
| 139 |
> |
PACKET *p |
| 140 |
|
) |
| 141 |
|
{ |
| 142 |
|
int pn, n; |
| 147 |
|
packrays(rtbuf, p); |
| 148 |
|
if ((n = p->nr) < RPACKSIZ) /* add flush block? */ |
| 149 |
|
memset((char *)(rtbuf+6*n++), '\0', 6*sizeof(float)); |
| 150 |
< |
if (writebuf(rtpd[pn].w, (char *)rtbuf, 6*sizeof(float)*n) < 0) |
| 150 |
> |
if (writebuf(rtpd[pn].w, rtbuf, 6*sizeof(float)*n) < 0) |
| 151 |
|
error(SYSTEM, "write error in queue_packet"); |
| 152 |
|
p->next = NULL; |
| 153 |
|
if (!pqlen[pn]++) /* add it to the end of the queue */ |
| 154 |
|
pqueue[pn] = p; |
| 155 |
|
else { |
| 156 |
< |
register PACKET *rpl = pqueue[pn]; |
| 156 |
> |
PACKET *rpl = pqueue[pn]; |
| 157 |
|
while (rpl->next != NULL) |
| 158 |
|
rpl = rpl->next; |
| 159 |
|
rpl->next = p; |
| 169 |
|
static struct timeval tpoll; /* zero timeval struct */ |
| 170 |
|
fd_set readset, errset; |
| 171 |
|
PACKET *pldone = NULL, *plend; |
| 172 |
< |
register PACKET *p; |
| 172 |
> |
PACKET *p; |
| 173 |
|
int n, nr; |
| 174 |
< |
register int pn; |
| 174 |
> |
int pn; |
| 175 |
|
float *bp; |
| 176 |
|
/* prepare select call */ |
| 177 |
|
FD_ZERO(&readset); FD_ZERO(&errset); n = 0; |
| 241 |
|
} |
| 242 |
|
|
| 243 |
|
|
| 244 |
< |
extern PACKET * |
| 244 |
> |
PACKET * |
| 245 |
|
do_packets( /* queue a packet list, return finished */ |
| 246 |
< |
register PACKET *pl |
| 246 |
> |
PACKET *pl |
| 247 |
|
) |
| 248 |
|
{ |
| 249 |
< |
register PACKET *p; |
| 249 |
> |
PACKET *p; |
| 250 |
|
/* consistency check */ |
| 251 |
|
if (nprocs < 1) |
| 252 |
|
error(CONSISTENCY, "do_packets called with no active process"); |
| 259 |
|
} |
| 260 |
|
|
| 261 |
|
|
| 262 |
< |
extern PACKET * |
| 262 |
> |
PACKET * |
| 263 |
|
flush_queue(void) /* empty all rtrace queues */ |
| 264 |
|
{ |
| 265 |
|
PACKET *rpdone = NULL; |
| 266 |
< |
register PACKET *rpl = NULL; |
| 266 |
> |
PACKET *rpl = NULL; |
| 267 |
|
float *bp; |
| 268 |
< |
register PACKET *p; |
| 268 |
> |
PACKET *p; |
| 269 |
|
int i, n, nr; |
| 270 |
|
|
| 271 |
|
for (i = 0; i < nprocs; i++) |
| 282 |
|
if (rpl->nr < RPACKSIZ) |
| 283 |
|
nr++; /* add flush block */ |
| 284 |
|
} |
| 285 |
< |
n = readbuf(rtpd[i].r, (char *)rtbuf, |
| 285 |
< |
4*sizeof(float)*nr); |
| 285 |
> |
n = readbuf(rtpd[i].r, rtbuf, 4*sizeof(float)*nr); |
| 286 |
|
if (n < 0) |
| 287 |
|
error(SYSTEM, "read failure in flush_queue"); |
| 288 |
|
bp = rtbuf; /* process packets */ |
| 317 |
|
} |
| 318 |
|
|
| 319 |
|
|
| 320 |
< |
extern int |
| 320 |
> |
int |
| 321 |
|
end_rtrace(void) /* close rtrace process(es) */ |
| 322 |
|
{ |
| 323 |
|
int status = 0, rv; |
| 324 |
|
|
| 325 |
|
if (nprocs > 1) |
| 326 |
|
killpersist(); |
| 327 |
< |
while (nprocs > 0) { |
| 328 |
< |
rv = close_process(&rtpd[--nprocs]); |
| 329 |
< |
if (rv > 0) |
| 330 |
< |
status = rv; |
| 331 |
< |
} |
| 327 |
> |
status = close_processes(rtpd, nprocs); |
| 328 |
> |
nprocs = 0; |
| 329 |
|
free((void *)rtbuf); |
| 330 |
|
rtbuf = NULL; |
| 331 |
|
maxqlen = 0; |