IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 25, 2009, 11:56:09 AM (17 years ago)
Author:
eugene
Message:

upgrade threading/locking model for pantasks: changes merged from eam_branch_20090322

File:
1 edited

Legend:

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

    r23329 r23530  
    77  int status;
    88  float time_running, next_timeout, fuzz;
    9   // struct timeval now;
    109
    1110  // actual maximum delay is controlled in job_threads.c
    1211  next_timeout = 1.0;
    1312
     13  JobTaskLock();
    1414  /** test all tasks: ready to test? ready to run? **/
    1515  while ((task = NextTask ()) != NULL) {
     
    5454    /* ready to run? : run task.exec macro */
    5555    if (task[0].exec != NULL) {
     56      // we need to unlock JobTask since JobTaskLock is called inside CommandLock in the client thread
     57      JobTaskUnlock();
     58      CommandLock();
    5659      status = exec_loop (task[0].exec);
     60      CommandUnlock();
     61      JobTaskLock();
    5762      if (!status) {
    5863        continue;
    5964      }
    6065    }
    61 
    62     // gettimeofday (&now, (void *) NULL);
    63     // fprintf (stderr, "t1: %d %6d  - \n", now.tv_sec, now.tv_usec);
    6466
    6567    /* check if there are errors with this task */
     
    6870    }
    6971   
    70     // gettimeofday (&now, (void *) NULL);
    71     // fprintf (stderr, "t2: %d %6d  - \n", now.tv_sec, now.tv_usec);
    72 
    7372    /* construct job from task */
    7473    job = CreateJob (task);
    7574    if (DEBUG) fprintf (stderr, "create job: (%zx) %d of %d\n", (size_t) job[0].stdout_buff.buffer, job[0].stdout_buff.Nbuffer, job[0].stdout_buff.Nalloc);
    7675
    77     // gettimeofday (&now, (void *) NULL);
    78     // fprintf (stderr, "t3: %d %6d  - \n", now.tv_sec, now.tv_usec);
    79 
    80     /* execute job - XXX add status test */
    81     SubmitJob (job);
    82 
    83     // fprintf (stderr, "nl: %d %6d  - ",
    84     // task[0].last.tv_sec, task[0].last.tv_usec);
    85 
    86     /* increment job counters */
    87     task[0].Njobs ++;
    88     task[0].Npending ++;
    89 
    90     // fprintf (stderr, "%d %6d\n",
    91     // task[0].last.tv_sec, task[0].last.tv_usec);
     76    /* execute job */
     77    if (!SubmitJob (job)) {
     78      DeleteJob (job);
     79      continue;
     80    }
     81    task[0].Njobs ++; // number of jobs successfully submitted
    9282
    9383    /* increment Nrun for inclusive ranges with Nmax */
    9484    BumpTimeRanges (task[0].ranges, task[0].Nranges);
    9585  }
     86  JobTaskUnlock();
    9687  return (next_timeout);
    9788}
Note: See TracChangeset for help on using the changeset viewer.