--- libaitsched/src/aitsched.c 2023/02/23 15:36:41 1.30.2.1 +++ libaitsched/src/aitsched.c 2023/02/23 17:13:01 1.30.2.4 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitsched.c,v 1.30.2.1 2023/02/23 15:36:41 misho Exp $ +* $Id: aitsched.c,v 1.30.2.4 2023/02/23 17:13:01 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -389,7 +389,11 @@ schedEnd(sched_root_task_t ** __restrict root) if ((*root)->root_sigthr) { pthread_cancel((*root)->root_sigthr); - (*root)->root_sigthr ^= (*root)->root_sigthr; +#ifdef __linux__ + (*root)->root_sigthr = 0L; +#else + (*root)->root_sigthr = NULL; +#endif } #endif @@ -1119,14 +1123,29 @@ schedResumeby(sched_root_task_t * __restrict root, u_c static void * _sched_sigDisp(void *arg) { - sched_root_task_t *sched = arg; - sigset_t ss; - int sig; + sched_root_task_t *root = arg; + sched_task_t *task, *tmp; + int sig, flg; - sigfillset(&ss); - while (sched->root_sigthr) { - sigwait(&ss, &sig); + while (root->root_sigthr) { + if (sigwait(&root->root_sigset, &sig)) + continue; + flg = 0; + TAILQ_FOREACH_SAFE(task, &root->root_signal, task_node, tmp) { + if (TASK_VAL(task) == (uintptr_t) sig) { + if (!flg) { + TASK_RET(task) = 0; + TASK_FLAG(task) = 0; + + /* remove signal handle */ + transit_task2ready(task, &root->root_signal); + } + flg++; + } + } + if (flg < 2) + sigdelset(&root->root_sigset, sig); } return NULL; @@ -1152,7 +1171,11 @@ schedSignalDispatch(sched_root_task_t * __restrict roo if (!on) { pthread_cancel(root->root_sigthr); - root->root_sigthr ^= root->root_sigthr; +#ifdef __linux__ + root->root_sigthr = 0L; +#else + root->root_sigthr = NULL; +#endif return 0; }