--- libaitsched/src/aitsched.c 2012/01/08 03:28:26 1.4.2.3 +++ libaitsched/src/aitsched.c 2012/01/24 15:30:55 1.4.2.8 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitsched.c,v 1.4.2.3 2012/01/08 03:28:26 misho Exp $ +* $Id: aitsched.c,v 1.4.2.8 2012/01/24 15:30:55 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -132,6 +132,9 @@ schedInit(void ** __restrict data, size_t datlen) } else { memset(root, 0, sizeof(sched_root_task_t)); + /* INFINIT polling period by default */ + sched_timespecinf(&root->root_poll); + #ifdef HAVE_LIBPTHREAD for (i = 0; i < taskMAX; i++) if (pthread_mutex_init(&root->root_mtx[i], NULL)) { @@ -416,7 +419,7 @@ schedCancelby(sched_root_task_t * __restrict root, sch break; } } else if (criteria == CRITERIA_TV) { - if (!timercmp(&TASK_TV(task), (struct timeval*) param, -)) { + if (!sched_timespeccmp(&TASK_TS(task), (struct timespec*) param, -)) { flg++; break; } @@ -480,6 +483,31 @@ schedRun(sched_root_task_t * __restrict root, volatile while ((task = root->root_hooks.hook_exec.fetch(root, NULL))) schedCall(task); } + + return 0; +} + +/* + * schedPolling() - Polling timeout period if no timer task is present + * @root = root task + * @ts = timeout polling period, if ==NULL INFINIT timeout + * @tsold = old timeout polling if !=NULL + * return: -1 error or 0 ok + */ +inline int +schedPolling(sched_root_task_t * __restrict root, struct timespec * __restrict ts, + struct timespec * __restrict tsold) +{ + if (!root) + return -1; + + if (tsold) + *tsold = root->root_poll; + + if (!ts) + sched_timespecinf(&root->root_poll); + else + root->root_poll = *ts; return 0; }