version 1.24.4.1, 2014/01/27 16:52:56
|
version 1.24.4.2, 2014/01/27 17:08:02
|
Line 618 sched_hook_fetch(void *root, void *arg __unused)
|
Line 618 sched_hook_fetch(void *root, void *arg __unused)
|
{ |
{ |
sched_root_task_t *r = root; |
sched_root_task_t *r = root; |
sched_task_t *task, *tmp; |
sched_task_t *task, *tmp; |
struct timespec now; | struct timespec now, m, mtmp; |
#ifndef KQ_DISABLE |
#ifndef KQ_DISABLE |
struct kevent evt[1], res[KQ_EVENTS]; |
struct kevent evt[1], res[KQ_EVENTS]; |
struct timespec *timeout, m, mtmp; |
struct timespec *timeout, m, mtmp; |
#else |
#else |
struct timeval *timeout, m, mtmp, now2; | struct timeval *timeout, tv; |
#endif |
#endif |
register int i, flg; |
register int i, flg; |
int en; |
int en; |
Line 683 sched_hook_fetch(void *root, void *arg __unused)
|
Line 683 sched_hook_fetch(void *root, void *arg __unused)
|
#ifdef TIMER_WITHOUT_SORT |
#ifdef TIMER_WITHOUT_SORT |
clock_gettime(CLOCK_MONOTONIC, &now); |
clock_gettime(CLOCK_MONOTONIC, &now); |
|
|
#ifndef KQ_DISABLE |
|
sched_timespecclear(&r->root_wait); |
sched_timespecclear(&r->root_wait); |
TAILQ_FOREACH(task, &r->root_timer, task_node) { |
TAILQ_FOREACH(task, &r->root_timer, task_node) { |
if (!sched_timespecisset(&r->root_wait)) |
if (!sched_timespecisset(&r->root_wait)) |
Line 691 sched_hook_fetch(void *root, void *arg __unused)
|
Line 690 sched_hook_fetch(void *root, void *arg __unused)
|
else if (sched_timespeccmp(&TASK_TS(task), &r->root_wait, -) < 0) |
else if (sched_timespeccmp(&TASK_TS(task), &r->root_wait, -) < 0) |
r->root_wait = TASK_TS(task); |
r->root_wait = TASK_TS(task); |
} |
} |
#else |
|
sched_timevalclear(&r->root_wait); |
|
TAILQ_FOREACH(task, &r->root_timer, task_node) { |
|
if (!sched_timevalisset(&r->root_wait)) |
|
TASK_TS2TV(task, &r->root_wait); |
|
else { |
|
TASK_TS2TV(task, &m); |
|
if (sched_timevalcmp(&m, &r->root_wait, -) < 0) |
|
TASK_TS2TV(task, &r->root_wait); |
|
} |
|
} |
|
#endif /* KQ_DISABLE */ |
|
|
|
if (TAILQ_FIRST(&r->root_timer)) { |
if (TAILQ_FIRST(&r->root_timer)) { |
m = r->root_wait; |
m = r->root_wait; |
#ifndef KQ_DISABLE |
|
sched_timespecsub(&m, &now, &mtmp); |
sched_timespecsub(&m, &now, &mtmp); |
#else |
|
sched_timespec2val(&now, &now2); |
|
sched_timevalsub(&m, &now2, &mtmp); |
|
#endif /* KQ_DISABLE */ |
|
r->root_wait = mtmp; |
r->root_wait = mtmp; |
} else { |
} else { |
/* set wait INFTIM */ |
/* set wait INFTIM */ |
#ifndef KQ_DISABLE |
|
sched_timespecinf(&r->root_wait); |
sched_timespecinf(&r->root_wait); |
#else |
|
sched_timevalinf(&r->root_wait); |
|
#endif /* KQ_DISABLE */ |
|
} |
} |
#else /* ! TIMER_WITHOUT_SORT */ |
#else /* ! TIMER_WITHOUT_SORT */ |
if (!TAILQ_FIRST(&r->root_task) && (task = TAILQ_FIRST(&r->root_timer))) { |
if (!TAILQ_FIRST(&r->root_task) && (task = TAILQ_FIRST(&r->root_timer))) { |
clock_gettime(CLOCK_MONOTONIC, &now); |
clock_gettime(CLOCK_MONOTONIC, &now); |
|
|
#ifndef KQ_DISABLE |
|
m = TASK_TS(task); |
m = TASK_TS(task); |
sched_timespecsub(&m, &now, &mtmp); |
sched_timespecsub(&m, &now, &mtmp); |
#else |
|
TASK_TS2TV(task, &m); |
|
sched_timespec2val(&now, &now2); |
|
sched_timevalsub(&m, &now2, &mtmp); |
|
#endif /* KQ_DISABLE */ |
|
r->root_wait = mtmp; |
r->root_wait = mtmp; |
} else { |
} else { |
/* set wait INFTIM */ |
/* set wait INFTIM */ |
#ifndef KQ_DISABLE |
|
sched_timespecinf(&r->root_wait); |
sched_timespecinf(&r->root_wait); |
#else |
|
sched_timevalinf(&r->root_wait); |
|
#endif /* KQ_DISABLE */ |
|
} |
} |
#endif /* TIMER_WITHOUT_SORT */ |
#endif /* TIMER_WITHOUT_SORT */ |
/* if present member of task, set NOWAIT */ |
/* if present member of task, set NOWAIT */ |
if (TAILQ_FIRST(&r->root_task)) |
if (TAILQ_FIRST(&r->root_task)) |
#ifndef KQ_DISABLE |
|
sched_timespecclear(&r->root_wait); |
sched_timespecclear(&r->root_wait); |
#else |
|
sched_timevalclear(&r->root_wait); |
|
#endif /* KQ_DISABLE */ |
|
|
|
|
if (r->root_wait.tv_sec != -1 && r->root_wait.tv_nsec != -1) { |
#ifndef KQ_DISABLE |
#ifndef KQ_DISABLE |
if (r->root_wait.tv_sec != -1 && r->root_wait.tv_nsec != -1) |
|
#else |
|
if (r->root_wait.tv_sec != -1 && r->root_wait.tv_usec != -1) |
|
#endif /* KQ_DISABLE */ |
|
timeout = &r->root_wait; |
timeout = &r->root_wait; |
#ifndef KQ_DISABLE |
|
else if (sched_timespecisinf(&r->root_poll)) |
|
#else |
#else |
else if (sched_timevalisinf(&r->root_poll)) | sched_timespec2val(&r->root_wait, &tv); |
| timeout = &tv; |
#endif /* KQ_DISABLE */ |
#endif /* KQ_DISABLE */ |
|
} else if (sched_timespecisinf(&r->root_poll)) |
timeout = NULL; |
timeout = NULL; |
else | else { |
| #ifndef KQ_DISABLE |
timeout = &r->root_poll; |
timeout = &r->root_poll; |
|
#else |
|
sched_timespec2val(&r->root_poll, &tv); |
|
timeout = &tv; |
|
#endif /* KQ_DISABLE */ |
|
} |
|
|
#ifndef KQ_DISABLE |
#ifndef KQ_DISABLE |
if ((en = kevent(r->root_kq, NULL, 0, res, KQ_EVENTS, timeout)) == -1) { |
if ((en = kevent(r->root_kq, NULL, 0, res, KQ_EVENTS, timeout)) == -1) { |