Changeset 12404 for trunk/Ohana/src/opihi/pantasks/CheckTasks.c
- Timestamp:
- Mar 11, 2007, 10:56:27 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pantasks/CheckTasks.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pantasks/CheckTasks.c
r12332 r12404 1 1 # include "pantasks.h" 2 2 3 int CheckTasks () {3 float CheckTasks () { 4 4 5 5 Job *job; 6 6 Task *task; 7 7 int status; 8 float time_running, next_timeout; 8 9 // struct timeval now; 10 11 // actual maximum delay is controlled in job_threads.c 12 next_timeout = 1.0; 9 13 10 14 /** test all tasks: ready to test? ready to run? **/ 11 15 while ((task = NextTask ()) != NULL) { 12 16 13 if (!task[0].active) continue;17 /*** test for all reasons we should skip this task ***/ 14 18 15 /* ready to test? : check exec period */ 16 if (GetTaskTimer(task[0].last, FALSE) < task[0].exec_period) continue; 17 18 /* need to check if the current time is within valid/invalid periods */ 19 /* task has been de-activated by the user */ 20 if (!task[0].active) { 21 continue; 22 } 23 /* current time is not within valid/invalid periods */ 19 24 if (!CheckTimeRanges (task[0].ranges, task[0].Nranges)) { 20 gettimeofday (&task[0].last, (void *) NULL); 21 continue; 25 continue; 22 26 } 27 /* all allowed tasks have been run in this period */ 23 28 if (task[0].Nmax && (task[0].Njobs >= task[0].Nmax)) { 24 gettimeofday (&task[0].last, (void *) NULL); 25 continue; 29 continue; 26 30 } 31 /* too many outstanding jobs */ 27 32 if (task[0].NpendingMax && (task[0].Npending >= task[0].NpendingMax)) { 28 // fprintf (stderr, "npending: %d, max npending: %d\n", task[0].Npending, task[0].NpendingMax); 29 gettimeofday (&task[0].last, (void *) NULL); 30 continue; 33 continue; 31 34 } 32 35 33 // gettimeofday (&now, (void *) NULL); 34 // fprintf (stderr, "t0: %d %6d - \n", now.tv_sec, now.tv_usec); 36 /* ready to test? : check time since last exec */ 37 time_running = GetTaskTimer(task[0].last, FALSE); 38 if (time_running < task[0].exec_period) { 39 // is we are to ready to run, set time to timeout, if shortest of all tasks 40 next_timeout = MIN (next_timeout, task[0].exec_period - time_running); 41 continue; 42 } 43 44 /* ready to try running the task : reset the timer */ 45 next_timeout = 0.0; 46 gettimeofday (&task[0].last, (void *) NULL); 47 // XXX here is where I should add a fuzz factor (fraction of exec_period) 35 48 36 49 /* ready to run? : run task.exec macro */ … … 38 51 status = exec_loop (task[0].exec); 39 52 if (!status) { 40 gettimeofday (&task[0].last, (void *) NULL); 41 continue; 53 continue; 42 54 } 43 55 } … … 48 60 /* check if there are errors with this task */ 49 61 if (!ValidateTask (task, TRUE)) { 50 gettimeofday (&task[0].last, (void *) NULL); 51 continue; 62 continue; 52 63 } 53 64 … … 67 78 // task[0].last.tv_sec, task[0].last.tv_usec); 68 79 69 /* reset timer on task (don't do this if Create/Submit fails) (why not??) */ 70 gettimeofday (&task[0].last, (void *) NULL); 80 /* increment job counters */ 71 81 task[0].Njobs ++; 72 82 task[0].Npending ++; … … 77 87 /* increment Nrun for inclusive ranges with Nmax */ 78 88 BumpTimeRanges (task[0].ranges, task[0].Nranges); 79 80 if (TestElapsedCheck()) return (TRUE);81 89 } 82 return ( TRUE);90 return (next_timeout); 83 91 }
Note:
See TracChangeset
for help on using the changeset viewer.
