IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 13, 2005, 10:30:13 AM (21 years ago)
Author:
eugene
Message:

working on speed issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pantasks/ControllerOps.c

    r4714 r4762  
    11# include "psched.h"
    22/* adding a new host can delay controller up to a second or so */
    3 # define CONTROLLER_TIMEOUT 200
     3# define CONTROLLER_TIMEOUT 500
    44# define CONNECT_TIMEOUT 300
    55
     
    1818/* check job / get output if done */
    1919int CheckControllerJob (Job *job) {
    20 
     20  struct timeval start, stop;
     21  float dtime;
     22
     23  gettimeofday (&start, (void *) NULL);
    2124  CheckControllerJobStatus (job);
     25  gettimeofday (&stop, (void *) NULL);
     26  dtime = DTIME (stop, start);
     27  if (VerboseMode()) fprintf (stderr, "check job status %f\n", dtime);
    2228
    2329  if ((job[0].state == JOB_EXIT) || (job[0].state == JOB_CRASH)) {
     30    gettimeofday (&start, (void *) NULL);
    2431    GetJobOutput ("stdout", job[0].pid, &job[0].stdout, job[0].stdout_size);
     32    gettimeofday (&stop, (void *) NULL);
     33    dtime = DTIME (stop, start);
     34    if (VerboseMode()) fprintf (stderr, "get stdout %f\n", dtime);
     35
    2536    GetJobOutput ("stderr", job[0].pid, &job[0].stderr, job[0].stderr_size);
    2637    DeleteControllerJob (job);
     
    97108  int i, status, Nstart;
    98109  char *line;
     110  struct timespec request, remain;
     111
     112  /* avoid blocking on waitpid, test every 100 usec, up to 50 msec */
     113  request.tv_sec = 0;
     114  request.tv_nsec = 100000;
    99115
    100116  /* flush any earlier messages */
     
    117133      line = memstr (buffer[0].buffer, CONTROLLER_PROMPT, buffer[0].Nbuffer);
    118134    }
    119     if (status == -1) usleep (10000);
     135    if (status == -1) nanosleep (&request, &remain);
    120136  }
    121137  if (status ==  0) return (CONTROLLER_DOWN);
     
    256272
    257273  /* try to get evidence connection is alive - wait upto a few seconds */
     274  /* connection is likely slow; don't bother with nanosleep here */
    258275  p = NULL;
    259276  status = -1;
     
    300317int ControllerCommand (char *cmd, char *response, IOBuffer *buffer) {
    301318
    302   int i;
    303   int status;
     319  int i, status;
    304320  char *line;
     321  struct timespec request, remain;
     322
     323  /* avoid blocking on waitpid, test every 100 usec, up to 50 msec */
     324  request.tv_sec = 0;
     325  request.tv_nsec = 100000;
    305326
    306327  ReadtoIOBuffer (buffer, stdout_cntl);
     
    323344    status = ReadtoIOBuffer (buffer, stdout_cntl);
    324345    line = memstr (buffer[0].buffer, response, buffer[0].Nbuffer);
    325     if (status == -1) usleep (10000);
     346    if (status == -1) nanosleep (&request, &remain);
    326347  }
    327348  if (status ==  0) {
     
    341362    bzero (buffer[0].buffer + buffer[0].Nbuffer, buffer[0].Nalloc - buffer[0].Nbuffer);
    342363  }
    343   if (VerboseMode()) fprintf (stderr, "message received\n");
     364  if (VerboseMode()) fprintf (stderr, "message received, %d cycles\n", i);
    344365  return (TRUE);
    345366}
Note: See TracChangeset for help on using the changeset viewer.