--- libaitsched/inc/aitsched.h 2012/08/21 11:45:34 1.14.2.2 +++ libaitsched/inc/aitsched.h 2012/08/23 02:33:12 1.16 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitsched.h,v 1.14.2.2 2012/08/21 11:45:34 misho Exp $ +* $Id: aitsched.h,v 1.16 2012/08/23 02:33:12 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -269,6 +269,20 @@ int schedEnd(sched_root_task_t ** __restrict root); */ int schedRegisterHooks(sched_root_task_t * __restrict root); /* + * sched_useTask() - Get and init new task + * + * @root = root task + * return: NULL error or !=NULL prepared task + */ +inline sched_task_t *sched_useTask(sched_root_task_t * __restrict root); +/* + * sched_unuseTask() - Unlock and put task to unuse queue + * + * @task = task + * return: always is NULL + */ +inline sched_task_t *sched_unuseTask(sched_task_t * __restrict task); +/* * schedPolling() - Polling timeout period if no timer task is present * * @root = root task @@ -633,22 +647,21 @@ sched_task_t *schedThread(sched_root_task_t * __restri #define schedThreadSelf(x) schedThread(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \ TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x))) /* - * taskExit() - Exit routine for scheduler task + * sched_taskExit() - Exit routine for scheduler task, explicit required for thread tasks * + * @task = current task + * @retcode = return code + * return: return code + */ +inline void *sched_taskExit(sched_task_t *task, intptr_t retcode); +/* + * taskExit() - Exit helper for scheduler task + * * @t = current executed task * @x = exit value for task * return: none */ -#define taskExit(t, x) do { assert((t) && TASK_ROOT(t)); \ - if (TASK_ROOT(t)->root_hooks.hook_exec.exit) \ - TASK_ROOT(t)->root_hooks.hook_exec.exit((t), \ - (void*) (x)); \ - TASK_ROOT(t)->root_ret = (void*) (x); \ - if (TASK_TYPE(t) == taskTHREAD) \ - pthread_exit((void*) (x)); \ - else \ - return ((void*) (x)); \ -} while (0) +#define taskExit(t, x) return sched_taskExit((t), (intptr_t) (x)) #endif