|
|
| version 1.20, 2013/08/26 13:36:45 | version 1.20.2.1, 2013/08/26 14:29:20 |
|---|---|
| Line 117 _sched_threadCleanup(sched_task_t *t) | Line 117 _sched_threadCleanup(sched_task_t *t) |
| if (TASK_FLAG(t) == PTHREAD_CREATE_JOINABLE) | if (TASK_FLAG(t) == PTHREAD_CREATE_JOINABLE) |
| pthread_detach(pthread_self()); | pthread_detach(pthread_self()); |
| pthread_mutex_lock(&TASK_ROOT(t)->root_mtx[taskTHREAD]); | |
| TAILQ_REMOVE(&TASK_ROOT(t)->root_thread, t, task_node); | |
| pthread_mutex_unlock(&TASK_ROOT(t)->root_mtx[taskTHREAD]); | |
| sched_unuseTask(t); | |
| } | } |
| void * | void * |
| _sched_threadWrapper(sched_task_t *t) | _sched_threadWrapper(sched_task_t *t) |
| { | { |
| void *ret = NULL; | void *ret = NULL; |
| sem_t *s = NULL; | sem_t *s = NULL; |
| sched_root_task_t *r; | |
| if (!t || !TASK_ROOT(t) || !TASK_RET(t)) | if (!t || !TASK_ROOT(t) || !TASK_RET(t)) |
| pthread_exit(ret); | pthread_exit(ret); |
| else { | else |
| s = (sem_t*) TASK_RET(t); | s = (sem_t*) TASK_RET(t); |
| r = TASK_ROOT(t); | |
| } | |
| pthread_cleanup_push((void (*)(void*)) _sched_threadCleanup, t); | pthread_cleanup_push((void (*)(void*)) _sched_threadCleanup, t); |
| pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); | pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); |
| pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); | pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); |
| #ifdef HAVE_LIBPTHREAD | pthread_mutex_lock(&TASK_ROOT(t)->root_mtx[taskTHREAD]); |
| pthread_mutex_lock(&r->root_mtx[taskTHREAD]); | TAILQ_REMOVE(&TASK_ROOT(t)->root_thread, t, task_node); |
| #endif | pthread_mutex_unlock(&TASK_ROOT(t)->root_mtx[taskTHREAD]); |
| TAILQ_REMOVE(&r->root_thread, t, task_node); | sched_unuseTask(t); |
| #ifdef HAVE_LIBPTHREAD | |
| pthread_mutex_unlock(&r->root_mtx[taskTHREAD]); | |
| #endif | |
| t->task_type = taskUNUSE; | |
| #ifdef HAVE_LIBPTHREAD | |
| pthread_mutex_lock(&r->root_mtx[taskUNUSE]); | |
| #endif | |
| TAILQ_INSERT_TAIL(&r->root_unuse, t, task_node); | |
| #ifdef HAVE_LIBPTHREAD | |
| pthread_mutex_unlock(&r->root_mtx[taskUNUSE]); | |
| #endif | |
| /* notify parent, thread is ready for execution */ | /* notify parent, thread is ready for execution */ |
| sem_post(s); | sem_post(s); |
| Line 175 _sched_threadWrapper(sched_task_t *t) | Line 155 _sched_threadWrapper(sched_task_t *t) |
| void * | void * |
| _sched_rtcWrapper(sched_task_t *t) | _sched_rtcWrapper(sched_task_t *t) |
| { | { |
| void *ret = NULL; | |
| sched_task_func_t func; | sched_task_func_t func; |
| sched_task_t *task; | sched_task_t *task; |
| sched_root_task_t *r; | sched_root_task_t *r; |
| Line 195 _sched_rtcWrapper(sched_task_t *t) | Line 174 _sched_rtcWrapper(sched_task_t *t) |
| #ifdef HAVE_LIBPTHREAD | #ifdef HAVE_LIBPTHREAD |
| pthread_mutex_unlock(&r->root_mtx[taskRTC]); | pthread_mutex_unlock(&r->root_mtx[taskRTC]); |
| #endif | #endif |
| task->task_type = taskUNUSE; | sched_unuseTask(task); |
| #ifdef HAVE_LIBPTHREAD | |
| pthread_mutex_lock(&r->root_mtx[taskUNUSE]); | |
| #endif | |
| TAILQ_INSERT_TAIL(&r->root_unuse, task, task_node); | |
| #ifdef HAVE_LIBPTHREAD | |
| pthread_mutex_unlock(&r->root_mtx[taskUNUSE]); | |
| #endif | |
| ret = func(task); | |
| timer_delete((timer_t) TASK_DATLEN(t)); | timer_delete((timer_t) TASK_DATLEN(t)); |
| return ret; | |
| return func(task); | |
| } | } |
| #endif | #endif |