version 1.6, 2012/05/14 12:09:13
|
version 1.7, 2012/05/30 08:52:45
|
Line 128 sched_hook_cancel(void *task, void *arg __unused)
|
Line 128 sched_hook_cancel(void *task, void *arg __unused)
|
#endif |
#endif |
kevent(TASK_ROOT(t)->root_kq, chg, 1, NULL, 0, &timeout); |
kevent(TASK_ROOT(t)->root_kq, chg, 1, NULL, 0, &timeout); |
break; |
break; |
|
case taskALARM: |
|
#ifdef __NetBSD__ |
|
EV_SET(&chg[0], (uintptr_t) TASK_DATA(t), EVFILT_TIMER, EV_DELETE, |
|
0, 0, (intptr_t) TASK_DATA(t)); |
|
#else |
|
EV_SET(&chg[0], (uintptr_t) TASK_DATA(t), EVFILT_TIMER, EV_DELETE, |
|
0, 0, (void*) TASK_DATA(t)); |
|
#endif |
|
kevent(TASK_ROOT(t)->root_kq, chg, 1, NULL, 0, &timeout); |
|
break; |
default: |
default: |
break; |
break; |
} |
} |
Line 202 sched_hook_write(void *task, void *arg __unused)
|
Line 212 sched_hook_write(void *task, void *arg __unused)
|
} |
} |
|
|
/* |
/* |
|
* sched_hook_alarm() - Default ALARM hook |
|
* |
|
* @task = current task |
|
* @arg = unused |
|
* return: <0 errors and 0 ok |
|
*/ |
|
void * |
|
sched_hook_alarm(void *task, void *arg __unused) |
|
{ |
|
sched_task_t *t = task; |
|
struct kevent chg[1]; |
|
struct timespec timeout = { 0, 0 }; |
|
|
|
if (!t || !TASK_ROOT(t)) |
|
return (void*) -1; |
|
|
|
#ifdef __NetBSD__ |
|
EV_SET(&chg[0], (uintptr_t) TASK_DATA(t), EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, |
|
t->task_val.ts.tv_sec * 1000 + t->task_val.ts.tv_nsec / 1000000, |
|
(intptr_t) TASK_DATA(t)); |
|
#else |
|
EV_SET(&chg[0], (uintptr_t) TASK_DATA(t), EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, |
|
t->task_val.ts.tv_sec * 1000 + t->task_val.ts.tv_nsec / 1000000, |
|
(void*) TASK_DATA(t)); |
|
#endif |
|
if (kevent(TASK_ROOT(t)->root_kq, chg, 1, NULL, 0, &timeout) == -1) { |
|
if (TASK_ROOT(t)->root_hooks.hook_exec.exception) |
|
TASK_ROOT(t)->root_hooks.hook_exec.exception(TASK_ROOT(t), NULL); |
|
else |
|
LOGERR; |
|
return (void*) -1; |
|
} |
|
|
|
return NULL; |
|
} |
|
|
|
/* |
* sched_hook_fetch() - Default FETCH hook |
* sched_hook_fetch() - Default FETCH hook |
* |
* |
* @root = root task |
* @root = root task |
Line 404 sched_hook_fetch(void *root, void *arg __unused)
|
Line 451 sched_hook_fetch(void *root, void *arg __unused)
|
pthread_mutex_unlock(&r->root_mtx[taskREADY]); |
pthread_mutex_unlock(&r->root_mtx[taskREADY]); |
#endif |
#endif |
} |
} |
|
break; |
|
} |
|
break; |
|
case EVFILT_TIMER: |
|
TAILQ_FOREACH_SAFE(task, &r->root_alarm, task_node, tmp) { |
|
if ((uintptr_t) TASK_DATA(task) != ((uintptr_t) res[i].udata)) |
|
continue; |
|
/* remove alarm handle */ |
|
#ifdef HAVE_LIBPTHREAD |
|
pthread_mutex_lock(&r->root_mtx[taskALARM]); |
|
#endif |
|
TAILQ_REMOVE(&r->root_alarm, task, task_node); |
|
#ifdef HAVE_LIBPTHREAD |
|
pthread_mutex_unlock(&r->root_mtx[taskALARM]); |
|
#endif |
|
task->task_type = taskREADY; |
|
#ifdef HAVE_LIBPTHREAD |
|
pthread_mutex_lock(&r->root_mtx[taskREADY]); |
|
#endif |
|
TAILQ_INSERT_TAIL(&r->root_ready, task, task_node); |
|
#ifdef HAVE_LIBPTHREAD |
|
pthread_mutex_unlock(&r->root_mtx[taskREADY]); |
|
#endif |
break; |
break; |
} |
} |
break; |
break; |