--- libaitsched/src/aitsched.c 2012/08/21 11:07:16 1.14.2.1 +++ libaitsched/src/aitsched.c 2012/09/10 15:07:53 1.17 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitsched.c,v 1.14.2.1 2012/08/21 11:07:16 misho Exp $ +* $Id: aitsched.c,v 1.17 2012/09/10 15:07:53 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -108,6 +108,9 @@ schedRegisterHooks(sched_root_task_t * __restrict root #ifdef EVFILT_USER root->root_hooks.hook_add.user = sched_hook_user; #endif +#ifdef HAVE_LIBPTHREAD + root->root_hooks.hook_add.thread = sched_hook_thread; +#endif root->root_hooks.hook_exec.cancel = sched_hook_cancel; root->root_hooks.hook_exec.fetch = sched_hook_fetch; @@ -148,7 +151,7 @@ schedInit(void ** __restrict data, size_t datlen) #ifdef HAVE_LIBPTHREAD for (i = 0; i < taskMAX; i++) - if (pthread_mutex_init(&root->root_mtx[i], NULL)) { + if ((errno = pthread_mutex_init(&root->root_mtx[i], NULL))) { LOGERR; while (i) pthread_mutex_destroy(&root->root_mtx[--i]); @@ -239,14 +242,14 @@ schedEnd(sched_root_task_t ** __restrict root) schedCancel(task); TAILQ_FOREACH_SAFE(task, &(*root)->root_event, task_node, tmp) schedCancel(task); - TAILQ_FOREACH_SAFE(task, &(*root)->root_task, task_node, tmp) - schedCancel(task); TAILQ_FOREACH_SAFE(task, &(*root)->root_suspend, task_node, tmp) schedCancel(task); TAILQ_FOREACH_SAFE(task, &(*root)->root_ready, task_node, tmp) schedCancel(task); TAILQ_FOREACH_SAFE(task, &(*root)->root_thread, task_node, tmp) schedCancel(task); + TAILQ_FOREACH_SAFE(task, &(*root)->root_task, task_node, tmp) + schedCancel(task); #ifdef HAVE_LIBPTHREAD pthread_mutex_lock(&(*root)->root_mtx[taskUNUSE]); @@ -427,7 +430,7 @@ schedCancel(sched_task_t * __restrict task) #endif } if (TASK_TYPE(task) != taskUNUSE) - _sched_unuseTask(task); + sched_unuseTask(task); return 0; } @@ -594,7 +597,7 @@ schedCancelby(sched_root_task_t * __restrict root, sch TAILQ_REMOVE(queue, task, task_node); if (TASK_TYPE(task) != taskUNUSE) - _sched_unuseTask(task); + sched_unuseTask(task); flg ^= flg; /* ok */ }