Changeset 8191
- Timestamp:
- Aug 5, 2006, 5:12:38 AM (20 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 4 edited
-
include/pantasks.h (modified) (1 diff)
-
pantasks/CheckTasks.c (modified) (1 diff)
-
pantasks/CheckTimeRanges.c (modified) (1 diff)
-
pantasks/task_trange.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/include/pantasks.h
r8129 r8191 52 52 char type; 53 53 char keep; 54 int Nmax; 55 int Nrun; 54 56 } TimeRange; 55 57 -
trunk/Ohana/src/opihi/pantasks/CheckTasks.c
r6687 r8191 30 30 SubmitJob (job); 31 31 32 /* reset timer on task (don't do this if Create/Submit fails) */32 /* reset timer on task (don't do this if Create/Submit fails) (why not??) */ 33 33 gettimeofday (&task[0].last, (void *) NULL); 34 34 task[0].Njobs ++; 35 36 /* increment Nrun for inclusive ranges with Nmax */ 37 BumpTimeRanges (task[0].ranges, task[0].Nranges); 35 38 36 39 if (TestElapsedCheck()) return (TRUE); -
trunk/Ohana/src/opihi/pantasks/CheckTimeRanges.c
r6687 r8191 1 1 # include "pantasks.h" 2 2 3 /* test if we meet all time range qualifications */ 3 4 int CheckTimeRanges (TimeRange *ranges, int Nranges) { 4 5 5 6 int i, intime, valid; 6 time_t daytime, weektime, abstime ;7 time_t daytime, weektime, abstime, testtime; 7 8 struct timeval now; 8 9 struct tm Now; 9 10 11 /* get the current time */ 10 12 gettimeofday (&now, NULL); 11 13 gmtime_r (&now.tv_sec, &Now); 12 daytime = Now.tm_sec + Now.tm_min*60 + Now.tm_hour*3600;14 daytime = Now.tm_sec + Now.tm_min*60 + Now.tm_hour*3600; 13 15 weektime = Now.tm_sec + Now.tm_min*60 + Now.tm_hour*3600 + Now.tm_wday*86400; 14 abstime = now.tv_sec;16 abstime = now.tv_sec; 15 17 16 18 valid = TRUE; 17 19 for (i = 0; (i < Nranges) && valid; i++) { 18 20 switch (ranges[i].type) { 21 /* set the testtime */ 19 22 case RANGE_ABS: 20 intime = (abstime >= ranges[i].start) && (abstime <= ranges[i].stop); 21 valid = ranges[i].keep ? intime : !intime; 23 testtime = abstime; 22 24 break; 23 25 case RANGE_DAY: 24 intime = (daytime >= ranges[i].start) && (daytime <= ranges[i].stop); 25 valid = ranges[i].keep ? intime : !intime; 26 testtime = daytime; 26 27 break; 27 28 case RANGE_WEEK: 28 intime = (weektime >= ranges[i].start) && (weektime <= ranges[i].stop); 29 valid = ranges[i].keep ? intime : !intime; 29 testtime = weektime; 30 30 break; 31 default: 32 abort (); 31 33 } 32 if (!valid) return (FALSE); 34 intime = (testtime >= ranges[i].start) && (testtime <= ranges[i].stop); 35 36 /* check for more than max runs in time range */ 37 if (ranges[i].keep && intime && ranges[i].Nmax) { 38 if (ranges[i].Nrun >= ranges[i].Nmax) return (FALSE); 39 } 40 /* reset Nrun if we are outside of intime */ 41 if (ranges[i].keep && !intime && ranges[i].Nmax && ranges[i].Nrun) { 42 ranges[i].Nrun = 0; 43 } 44 45 /* is this a valid time? */ 46 valid = ranges[i].keep ? intime : !intime; 33 47 } 34 48 return (valid); 35 49 } 50 51 /* increment the number of runs for all inclusive time ranges with Nmax > 0 52 (only call when we execute a task -- after CheckTimeRanges) */ 53 int BumpTimeRanges (TimeRange *ranges, int Nranges) { 54 55 int i; 56 57 for (i = 0; i < Nranges; i++) { 58 if (ranges[i].keep && ranges[i].Nmax) { 59 ranges[i].Nrun ++; 60 } 61 } 62 return (TRUE); 63 } -
trunk/Ohana/src/opihi/pantasks/task_trange.c
r7917 r8191 12 12 } */ 13 13 14 range.Nmax = 0; 15 range.Nrun = 0; 16 if (N = get_argument (argc, argv, "-nmax")) { 17 remove_argument (N, &argc, argv); 18 range.Nmax = atoi (argv[N]); 19 remove_argument (N, &argc, argv); 20 } 14 21 15 22 /* keep = true means the time range defines a valid time range
Note:
See TracChangeset
for help on using the changeset viewer.
