--- libaitsched/src/aitsched.c 2012/08/22 10:33:45 1.15.2.1 +++ libaitsched/src/aitsched.c 2013/05/26 20:14:02 1.17.2.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitsched.c,v 1.15.2.1 2012/08/22 10:33:45 misho Exp $ +* $Id: aitsched.c,v 1.17.2.1 2013/05/26 20:14:02 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 +Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -56,21 +56,21 @@ char sched_Error[STRSIZ]; // sched_GetErrno() Get error code of last operation -inline int +int sched_GetErrno() { return sched_Errno; } // sched_GetError() Get error text of last operation -inline const char * +const char * sched_GetError() { return sched_Error; } // sched_SetErr() Set error to variables for internal use!!! -inline void +void sched_SetErr(int eno, char *estr, ...) { va_list lst; @@ -151,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]); @@ -215,7 +215,6 @@ schedEnd(sched_root_task_t ** __restrict root) sched_task_t *task, *tmp; #ifdef HAVE_LIBPTHREAD register int i; - pthread_t tid; #endif if (!root || !*root) @@ -247,14 +246,8 @@ schedEnd(sched_root_task_t ** __restrict root) schedCancel(task); TAILQ_FOREACH_SAFE(task, &(*root)->root_ready, task_node, tmp) schedCancel(task); - TAILQ_FOREACH_SAFE(task, &(*root)->root_thread, task_node, tmp) { - tid = (pthread_t) TASK_VAL(task); + TAILQ_FOREACH_SAFE(task, &(*root)->root_thread, task_node, tmp) schedCancel(task); -#ifdef HAVE_LIBPTHREAD - if (TASK_FLAG(task) == PTHREAD_CREATE_JOINABLE) - pthread_join(tid, NULL); -#endif - } TAILQ_FOREACH_SAFE(task, &(*root)->root_task, task_node, tmp) schedCancel(task); @@ -288,7 +281,7 @@ schedEnd(sched_root_task_t ** __restrict root) * @task = current task * return: !=NULL error or =NULL ok */ -inline void * +void * schedCall(sched_task_t * __restrict task) { void *ptr = (void*) -1; @@ -311,7 +304,7 @@ schedCall(sched_task_t * __restrict task) * @root = root task * return: =NULL error or !=NULL ready task */ -inline void * +void * schedFetch(sched_root_task_t * __restrict root) { void *ptr; @@ -666,7 +659,7 @@ schedRun(sched_root_task_t *root, volatile intptr_t * * @tsold = old timeout polling if !=NULL * return: -1 error or 0 ok */ -inline int +int schedPolling(sched_root_task_t * __restrict root, struct timespec * __restrict ts, struct timespec * __restrict tsold) { @@ -691,7 +684,7 @@ schedPolling(sched_root_task_t * __restrict root, stru * @condValue = condition value, kill schedRun() if condValue == killState * return: -1 error or 0 ok */ -inline int +int schedTermCondition(sched_root_task_t * __restrict root, intptr_t condValue) { if (!root)