IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23329


Ignore:
Timestamp:
Mar 15, 2009, 11:13:18 AM (17 years ago)
Author:
eugene
Message:

better fuzzing of task exec periods

Location:
trunk/Ohana/src/opihi/pantasks
Files:
2 edited

Legend:

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

    r15872 r23329  
    4848    // add random offset between 0 and 5% of exec_period
    4949    // XXX this should be optional
    50     fuzz = 0.05*task[0].exec_period*drand48() + 1e-6*task[0].last.tv_usec;
     50    fuzz = 0.1*task[0].exec_period*drand48();
    5151    task[0].last.tv_usec = 1e6*(fuzz - (int)fuzz);
    5252    task[0].last.tv_sec += (int) fuzz;
  • trunk/Ohana/src/opihi/pantasks/task_threads.c

    r15791 r23329  
    22
    33/** things related to CheckTasks **/
     4void ResetTaskTimers ();
    45
    56static int CheckTasksRun = FALSE;
    67
    78void CheckTasksSetState (int state) {
     9  if (state && !CheckTasksRun) {
     10    ResetTaskTimers ();
     11  }
    812  CheckTasksRun = state;
    913}
     
    5155// timeout.  this enforces a certain granularity in the task creation, but prevents the task
    5256// thread from driving the load up to silly levels.
     57
     58// reset all of the task timers, with a bit of fuzz.  this is called
     59// whenever we transition from 'stop' to 'run'
     60void ResetTaskTimers () {
     61
     62  Task *task;
     63  struct timeval now;
     64  float fuzz;
     65
     66  // get the current time
     67  gettimeofday (&now, NULL);
     68
     69  // check all tasks
     70  while ((task = NextTask ()) != NULL) {
     71    task[0].last.tv_usec = now.tv_usec;
     72    task[0].last.tv_sec  = now.tv_sec;
     73
     74    // add random offset between 0 and 10% of exec_period
     75    // XXX this should be optional
     76    fuzz = 0.1*task[0].exec_period*drand48();
     77    task[0].last.tv_usec = 1e6*(fuzz - (int)fuzz);
     78    task[0].last.tv_sec += (int) fuzz;
     79  }
     80  return;
     81}
Note: See TracChangeset for help on using the changeset viewer.