IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 23, 2006, 5:31:09 PM (20 years ago)
Author:
eugene
Message:

cleanup of timeouts and thread-safety issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pcontrol/CheckSystem.c

    r8424 r8546  
    5555void *CheckSystem_Threaded (void *data) {
    5656
    57   struct timeval now;
    58   float dtime;
     57  int Njobchecks, Nhostchecks, Nlivechecks;
     58
     59  Nlivechecks = 0;
    5960
    6061  gprintInit ();
     
    6667    // don't run the system checks if RunSystem is FALSE
    6768    if (!RunSystem) {
    68       usleep (50000);
     69      usleep (50000); // idle if RunSystem is FALSE
    6970      continue;
    7071    }
    7172
     73    Njobchecks = 0;
     74    Nhostchecks = 0;
     75
    7276    // we want to give each block a maximum allowed time
    73     CheckIdleHosts(0.020); /* submit a new job */
    74 
    75     CheckBusyJobs(0.020);  /* get job status */
    76     CheckDoneJobs(0.020);  /* harvest job stdout/stderr */
    77     CheckKillJobs(0.020);  /* harvest job stdout/stderr */
    78 
    79     CheckDoneHosts(0.020); /* reset the host */
    80     CheckDownHosts(0.100); /* launch the host */
     77    Nhostchecks += CheckIdleHosts(0.020); /* submit a new job */
     78
     79    Njobchecks  += CheckBusyJobs(0.020);  /* get job status */
     80    Njobchecks  += CheckDoneJobs(0.020);  /* harvest job stdout/stderr */
     81    Njobchecks  += CheckKillJobs(0.020);  /* harvest job stdout/stderr */
     82
     83    Nhostchecks += CheckDoneHosts(0.020); /* reset the host */
     84    Nhostchecks += CheckDownHosts(0.100); /* launch the host */
    8185
    8286    /* always allow at least one test */
     
    8488       CheckDoneJobs must depend on the size of the output buffer */
    8589
    86     gettimeofday (&now, (void *) NULL);
    87     dtime = DTIME (now, lastlive);
    88     if (dtime > 1.0) {
     90    // there is nothing on the stacks.  test the hosts and wait a bit
     91    if (!Njobchecks && !Nhostchecks) {
    8992      CheckLiveHosts(0.040);
    90       lastlive = now;
     93      usleep (100000); // idle if no jobs are waiting
    9194    }
    9295
     
    145148  }
    146149  if (DEBUG && (Nobject > 0)) gprint (GP_ERR, "checked %d of %d jobs\n", i, Nobject);
    147   return (TRUE);
     150  return (i);
    148151}
    149152
     
    182185  }
    183186  if (DEBUG && (Nobject > 0)) gprint (GP_ERR, "checked %d of %d jobs\n", i, Nobject);
    184   return (TRUE);
     187  return (i);
    185188}
    186189
     
    219222  }
    220223  if (DEBUG && (Nobject > 0)) gprint (GP_ERR, "checked %d of %d jobs\n", i, Nobject);
    221   return (TRUE);
     224  return (i);
    222225}
    223226
     
    245248  }
    246249  if (DEBUG) gprint (GP_ERR, "checked %d hosts\n", i);
    247   return (TRUE);
     250  return (i);
    248251}
    249252
     
    281284  }
    282285  if (DEBUG) gprint (GP_ERR, "checked %d hosts\n", i);
    283   return (TRUE);
     286  return (i);
    284287}
    285288
     
    294297  /* check if there are any pending jobs, otherwise skip step */
    295298  stack = GetJobStack (PCONTROL_JOB_PENDING);
    296   if (!stack[0].Nobject) return (TRUE);
     299  if (!stack[0].Nobject) return (0);
    297300
    298301  /* Loop through objects on the stack, no more than once. see note above */
     
    311314  }
    312315  if (DEBUG) gprint (GP_ERR, "checked %d hosts\n", i);
    313   return (TRUE);
     316  return (i);
    314317}
    315318
Note: See TracChangeset for help on using the changeset viewer.