version 1.15.2.1, 2013/05/26 20:14:02
|
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) |
Line 140 _sched_threadWrapper(sched_task_t *t)
|
Line 134 _sched_threadWrapper(sched_task_t *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); |
|
|
|
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); |
|
|
/* notify parent, thread is ready for execution */ |
/* notify parent, thread is ready for execution */ |
sem_post(s); |
sem_post(s); |
pthread_testcancel(); |
pthread_testcancel(); |
Line 152 _sched_threadWrapper(sched_task_t *t)
|
Line 151 _sched_threadWrapper(sched_task_t *t)
|
} |
} |
#endif |
#endif |
|
|
|
#if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME) |
|
void * |
|
_sched_rtcWrapper(sched_task_t *t) |
|
{ |
|
sched_task_func_t func; |
|
sched_task_t *task; |
|
sched_root_task_t *r; |
|
|
|
if (!t || !TASK_ROOT(t) || !TASK_DATA(t)) |
|
return NULL; |
|
else { |
|
r = TASK_ROOT(t); |
|
task = (sched_task_t*) TASK_DATA(t); |
|
func = TASK_FUNC(task); |
|
} |
|
|
|
#ifdef HAVE_LIBPTHREAD |
|
pthread_mutex_lock(&r->root_mtx[taskRTC]); |
|
#endif |
|
TAILQ_REMOVE(&r->root_rtc, task, task_node); |
|
#ifdef HAVE_LIBPTHREAD |
|
pthread_mutex_unlock(&r->root_mtx[taskRTC]); |
|
#endif |
|
sched_unuseTask(task); |
|
|
|
timer_delete((timer_t) TASK_DATLEN(t)); |
|
|
|
return func(task); |
|
} |
|
#endif |
|
|
#pragma GCC visibility pop |
#pragma GCC visibility pop |
|
|
/* |
/* |
Line 511 schedSignal(sched_root_task_t * __restrict root, sched
|
Line 541 schedSignal(sched_root_task_t * __restrict root, sched
|
* @func = task execution function |
* @func = task execution function |
* @arg = 1st func argument |
* @arg = 1st func argument |
* @ts = timeout argument structure, minimum alarm timer resolution is 1msec! |
* @ts = timeout argument structure, minimum alarm timer resolution is 1msec! |
* @opt_data = Optional data | * @opt_data = Alarm timer ID |
* @opt_dlen = Optional data length |
* @opt_dlen = Optional data length |
* return: NULL error or !=NULL new queued task |
* return: NULL error or !=NULL new queued task |
*/ |
*/ |
Line 1322 schedThread(sched_root_task_t * __restrict root, sched
|
Line 1352 schedThread(sched_root_task_t * __restrict root, sched
|
return task; |
return task; |
} |
} |
|
|
|
/* |
|
* schedRTC() - Add RTC task to scheduler queue |
|
* |
|
* @root = root task |
|
* @func = task execution function |
|
* @arg = 1st func argument |
|
* @ts = timeout argument structure, minimum alarm timer resolution is 1msec! |
|
* @opt_data = Optional RTC ID |
|
* @opt_dlen = Optional data length |
|
* return: NULL error or !=NULL new queued task |
|
*/ |
|
sched_task_t * |
|
schedRTC(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, struct timespec ts, |
|
void *opt_data, size_t opt_dlen) |
|
{ |
|
#if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME) |
|
sched_task_t *task; |
|
void *ptr; |
|
|
|
if (!root || !func) |
|
return NULL; |
|
|
|
/* get new task */ |
|
if (!(task = sched_useTask(root))) |
|
return NULL; |
|
|
|
task->task_func = func; |
|
TASK_TYPE(task) = taskRTC; |
|
TASK_ROOT(task) = root; |
|
|
|
TASK_ARG(task) = arg; |
|
TASK_TS(task) = ts; |
|
|
|
TASK_DATA(task) = opt_data; |
|
TASK_DATLEN(task) = opt_dlen; |
|
|
|
if (root->root_hooks.hook_add.rtc) |
|
ptr = root->root_hooks.hook_add.rtc(task, NULL); |
|
else |
|
ptr = NULL; |
|
|
|
if (!ptr) { |
|
#ifdef HAVE_LIBPTHREAD |
|
pthread_mutex_lock(&root->root_mtx[taskRTC]); |
|
#endif |
|
TAILQ_INSERT_TAIL(&root->root_rtc, TASK_ID(task), task_node); |
|
#ifdef HAVE_LIBPTHREAD |
|
pthread_mutex_unlock(&root->root_mtx[taskRTC]); |
|
#endif |
|
} else |
|
task = sched_unuseTask(task); |
|
|
|
return task; |
|
#else |
|
sched_SetErr(ENOTSUP, "Not supported realtime clock extensions"); |
|
return NULL; |
|
#endif |
|
} |