version 1.14, 2012/08/21 12:54:39
|
version 1.14.2.3, 2012/08/22 23:43:36
|
Line 209 sched_hook_cancel(void *task, void *arg __unused)
|
Line 209 sched_hook_cancel(void *task, void *arg __unused)
|
#endif |
#endif |
case taskTHREAD: |
case taskTHREAD: |
#ifdef HAVE_LIBPTHREAD |
#ifdef HAVE_LIBPTHREAD |
pthread_cancel((pthread_t) TASK_VAL(t)); | /* try to wait for valid thread id */ |
| for (i = 0; i < MAX_TASK_MISS && |
| pthread_kill((pthread_t) TASK_VAL(t), 0); i++) |
| usleep(10); |
| /* try to sure thread is cancelled */ |
| for (i = 0; i < MAX_TASK_MISS && |
| !pthread_kill((pthread_t) TASK_VAL(t), 0); i++) |
| pthread_cancel((pthread_t) TASK_VAL(t)); |
| if (TASK_FLAG(t) == PTHREAD_CREATE_JOINABLE) /* joinable thread */ |
| schedTask(TASK_ROOT(t), _sched_threadJoin, TASK_ARG(t), |
| TASK_VAL(t), TASK_DATA(t), TASK_DATLEN(t)); |
#endif |
#endif |
TASK_UNLOCK(t); |
TASK_UNLOCK(t); |
default: |
default: |
Line 233 sched_hook_thread(void *task, void *arg)
|
Line 243 sched_hook_thread(void *task, void *arg)
|
{ |
{ |
sched_task_t *t = task; |
sched_task_t *t = task; |
pthread_t tid; |
pthread_t tid; |
|
sigset_t ns, os; |
|
|
if (!t || !TASK_ROOT(t)) |
if (!t || !TASK_ROOT(t)) |
return (void*) -1; |
return (void*) -1; |
|
|
|
sigfillset(&ns); |
|
pthread_sigmask(SIG_BLOCK, &ns, &os); |
if (pthread_create(&tid, (pthread_attr_t*) arg, |
if (pthread_create(&tid, (pthread_attr_t*) arg, |
(void *(*)(void*)) TASK_FUNC(t), t)) { |
(void *(*)(void*)) TASK_FUNC(t), t)) { |
LOGERR; |
LOGERR; |
|
pthread_sigmask(SIG_SETMASK, &os, NULL); |
return (void*) -1; |
return (void*) -1; |
} |
} |
|
|
Line 247 sched_hook_thread(void *task, void *arg)
|
Line 261 sched_hook_thread(void *task, void *arg)
|
TASK_LOCK(t); |
TASK_LOCK(t); |
|
|
TASK_VAL(t) = (u_long) tid; |
TASK_VAL(t) = (u_long) tid; |
|
pthread_sigmask(SIG_SETMASK, &os, NULL); |
return NULL; |
return NULL; |
} |
} |
#endif |
#endif |