version 1.4.2.2, 2012/01/08 02:52:29
|
version 1.4.2.6, 2012/01/24 14:51:03
|
Line 132 schedInit(void ** __restrict data, size_t datlen)
|
Line 132 schedInit(void ** __restrict data, size_t datlen)
|
} else { |
} else { |
memset(root, 0, sizeof(sched_root_task_t)); |
memset(root, 0, sizeof(sched_root_task_t)); |
|
|
|
/* INFINIT polling period by default */ |
|
root->root_poll.tv_sec = root->root_poll.tv_nsec = -1; |
|
|
#ifdef HAVE_LIBPTHREAD |
#ifdef HAVE_LIBPTHREAD |
for (i = 0; i < taskMAX; i++) |
for (i = 0; i < taskMAX; i++) |
if (pthread_mutex_init(&root->root_mtx[i], NULL)) { |
if (pthread_mutex_init(&root->root_mtx[i], NULL)) { |
Line 193 schedEnd(sched_root_task_t ** __restrict root)
|
Line 196 schedEnd(sched_root_task_t ** __restrict root)
|
if (!root || !*root) |
if (!root || !*root) |
return -1; |
return -1; |
|
|
#ifdef HAVE_LIBPTHREAD |
|
for (i = 0; i < taskMAX; i++) |
|
pthread_mutex_lock(&(*root)->root_mtx[i]); |
|
#endif |
|
TAILQ_FOREACH(task, &(*root)->root_read, task_node) { |
TAILQ_FOREACH(task, &(*root)->root_read, task_node) { |
schedCancel(task); |
schedCancel(task); |
} |
} |
Line 216 schedEnd(sched_root_task_t ** __restrict root)
|
Line 215 schedEnd(sched_root_task_t ** __restrict root)
|
schedCancel(task); |
schedCancel(task); |
} |
} |
|
|
|
#ifdef HAVE_LIBPTHREAD |
|
pthread_mutex_lock(&(*root)->root_mtx[taskUNUSE]); |
|
#endif |
while ((task = TAILQ_FIRST(&(*root)->root_unuse))) { |
while ((task = TAILQ_FIRST(&(*root)->root_unuse))) { |
TAILQ_REMOVE(&(*root)->root_unuse, task, task_node); |
TAILQ_REMOVE(&(*root)->root_unuse, task, task_node); |
free(task); |
free(task); |
} |
} |
#ifdef HAVE_LIBPTHREAD |
#ifdef HAVE_LIBPTHREAD |
for (i = 0; i < taskMAX; i++) | pthread_mutex_unlock(&(*root)->root_mtx[taskUNUSE]); |
pthread_mutex_unlock(&(*root)->root_mtx[i]); | |
#endif |
#endif |
|
|
if ((*root)->root_hooks.hook_root.fini) |
if ((*root)->root_hooks.hook_root.fini) |
Line 418 schedCancelby(sched_root_task_t * __restrict root, sch
|
Line 419 schedCancelby(sched_root_task_t * __restrict root, sch
|
break; |
break; |
} |
} |
} else if (criteria == CRITERIA_TV) { |
} else if (criteria == CRITERIA_TV) { |
if (!timercmp(&TASK_TV(task), (struct timeval*) param, -)) { | if (!timespeccmp(&TASK_TS(task), (struct timespec*) param, -)) { |
flg++; |
flg++; |
break; |
break; |
} |
} |
Line 482 schedRun(sched_root_task_t * __restrict root, volatile
|
Line 483 schedRun(sched_root_task_t * __restrict root, volatile
|
while ((task = root->root_hooks.hook_exec.fetch(root, NULL))) |
while ((task = root->root_hooks.hook_exec.fetch(root, NULL))) |
schedCall(task); |
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) |
|
root->root_poll.tv_sec = root->root_poll.tv_nsec = -1; |
|
else |
|
root->root_poll = *ts; |
|
|
return 0; |
return 0; |
} |
} |