--- libaitsched/src/aitsched.c 2011/12/08 08:02:23 1.3 +++ libaitsched/src/aitsched.c 2012/01/08 00:51:17 1.4 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitsched.c,v 1.3 2011/12/08 08:02:23 misho Exp $ +* $Id: aitsched.c,v 1.4 2012/01/08 00:51:17 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -204,11 +204,19 @@ schedEnd(sched_root_task_t ** __restrict root) inline void * schedCall(sched_task_t * __restrict task) { + void *ptr = (void*) -1; + if (!task) - return (void*) -1; + return ptr; + if (!TASK_ISLOCKED(task)) + TASK_LOCK(task); + task->task_id++; - return task->task_func(task); + ptr = task->task_func(task); + + TASK_UNLOCK(task); + return ptr; } /* @@ -270,10 +278,8 @@ schedCancel(sched_task_t * __restrict task) } if (queue) TAILQ_REMOVE(queue, task, task_node); - if (task->task_type != taskUNUSE) { - task->task_type = taskUNUSE; - TAILQ_INSERT_TAIL(&task->task_root->root_unuse, task, task_node); - } + if (task->task_type != taskUNUSE) + _sched_unuseTask(task); return 0; } @@ -354,10 +360,8 @@ schedCancelby(sched_root_task_t * __restrict root, sch TAILQ_REMOVE(queue, task, task_node); - if (task->task_type != taskUNUSE) { - task->task_type = taskUNUSE; - TAILQ_INSERT_TAIL(&task->task_root->root_unuse, task, task_node); - } + if (task->task_type != taskUNUSE) + _sched_unuseTask(task); return 0; }