--- libaitsched/src/aitsched.c 2012/08/21 12:54:39 1.15 +++ libaitsched/src/aitsched.c 2012/08/23 00:31:41 1.15.2.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitsched.c,v 1.15 2012/08/21 12:54:39 misho Exp $ +* $Id: aitsched.c,v 1.15.2.3 2012/08/23 00:31:41 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -121,6 +121,16 @@ schedRegisterHooks(sched_root_task_t * __restrict root return 0; } +#ifdef HAVE_LIBPTHREAD +static void +_sched_threadChild() +{ + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + pthread_testcancel(); +} +#endif + /* * schedInit() - Init scheduler * @@ -181,6 +191,8 @@ schedInit(void ** __restrict data, size_t datlen) TAILQ_INIT(&root->root_thread); #ifdef HAVE_LIBPTHREAD + pthread_atfork(NULL, NULL, _sched_threadChild); + for (i = 0; i < taskMAX; i++) pthread_mutex_unlock(&root->root_mtx[i]); #endif @@ -242,13 +254,13 @@ 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