version 1.32, 2017/09/04 08:47:43
|
version 1.34, 2019/01/14 15:58:50
|
Line 12 terms:
|
Line 12 terms:
|
All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
Copyright 2004 - 2017 | Copyright 2004 - 2018 |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
Line 713 sched_hook_alarm(void *task, void *arg __unused)
|
Line 713 sched_hook_alarm(void *task, void *arg __unused)
|
* sched_hook_node() - Default NODE hook |
* sched_hook_node() - Default NODE hook |
* |
* |
* @task = current task |
* @task = current task |
* @arg = unused | * @arg = if arg == 42 then waiting for all events |
* return: <0 errors and 0 ok |
* return: <0 errors and 0 ok |
*/ |
*/ |
void * |
void * |
sched_hook_node(void *task, void *arg __unused) | sched_hook_node(void *task, void *arg) |
{ |
{ |
#if SUP_ENABLE == KQ_SUPPORT |
#if SUP_ENABLE == KQ_SUPPORT |
sched_task_t *t = task; |
sched_task_t *t = task; |
struct kevent chg[1]; |
struct kevent chg[1]; |
struct timespec timeout = { 0, 0 }; |
struct timespec timeout = { 0, 0 }; |
|
u_int addflags = (u_int) arg; |
|
|
if (!t || !TASK_ROOT(t)) |
if (!t || !TASK_ROOT(t)) |
return (void*) -1; |
return (void*) -1; |
Line 730 sched_hook_node(void *task, void *arg __unused)
|
Line 731 sched_hook_node(void *task, void *arg __unused)
|
#ifdef __NetBSD__ |
#ifdef __NetBSD__ |
EV_SET(&chg[0], TASK_FD(t), EVFILT_VNODE, EV_ADD | EV_CLEAR, |
EV_SET(&chg[0], TASK_FD(t), EVFILT_VNODE, EV_ADD | EV_CLEAR, |
NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | |
NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | |
NOTE_LINK | NOTE_RENAME | NOTE_REVOKE, 0, (intptr_t) TASK_FD(t)); | NOTE_LINK | NOTE_RENAME | NOTE_REVOKE | addflags, 0, (intptr_t) TASK_FD(t)); |
#else |
#else |
EV_SET(&chg[0], TASK_FD(t), EVFILT_VNODE, EV_ADD | EV_CLEAR, |
EV_SET(&chg[0], TASK_FD(t), EVFILT_VNODE, EV_ADD | EV_CLEAR, |
NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | |
NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | |
NOTE_LINK | NOTE_RENAME | NOTE_REVOKE, 0, (void*) TASK_FD(t)); | NOTE_LINK | NOTE_RENAME | NOTE_REVOKE | addflags, 0, (void*) TASK_FD(t)); |
#endif |
#endif |
if (kevent(TASK_ROOT(t)->root_kq, chg, 1, NULL, 0, &timeout) == -1) { |
if (kevent(TASK_ROOT(t)->root_kq, chg, 1, NULL, 0, &timeout) == -1) { |
if (TASK_ROOT(t)->root_hooks.hook_exec.exception) |
if (TASK_ROOT(t)->root_hooks.hook_exec.exception) |
Line 1300 sched_hook_fetch(void *root, void *arg __unused)
|
Line 1301 sched_hook_fetch(void *root, void *arg __unused)
|
return task; |
return task; |
} |
} |
|
|
|
/* if present member of task, set NOWAIT */ |
|
if (!TAILQ_FIRST(&r->root_task)) { |
|
/* timer tasks */ |
#ifdef TIMER_WITHOUT_SORT |
#ifdef TIMER_WITHOUT_SORT |
clock_gettime(CLOCK_MONOTONIC, &now); | clock_gettime(CLOCK_MONOTONIC, &now); |
|
|
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)) |
r->root_wait = TASK_TS(task); | r->root_wait = TASK_TS(task); |
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); |
} | } |
|
|
if (TAILQ_FIRST(&r->root_timer)) { | if (TAILQ_FIRST(&r->root_timer)) { |
m = r->root_wait; | m = r->root_wait; |
sched_timespecsub(&m, &now, &mtmp); | sched_timespecsub(&m, &now, &mtmp); |
r->root_wait = mtmp; | r->root_wait = mtmp; |
} else { | } else { |
/* set wait INFTIM */ | /* set wait INFTIM */ |
sched_timespecinf(&r->root_wait); | sched_timespecinf(&r->root_wait); |
} | } |
#else /* ! TIMER_WITHOUT_SORT */ |
#else /* ! TIMER_WITHOUT_SORT */ |
if (!TAILQ_FIRST(&r->root_task) && (task = TAILQ_FIRST(&r->root_timer))) { | if ((task = TAILQ_FIRST(&r->root_timer))) { |
clock_gettime(CLOCK_MONOTONIC, &now); | clock_gettime(CLOCK_MONOTONIC, &now); |
|
|
m = TASK_TS(task); | m = TASK_TS(task); |
sched_timespecsub(&m, &now, &mtmp); | sched_timespecsub(&m, &now, &mtmp); |
r->root_wait = mtmp; | r->root_wait = mtmp; |
} else { | } else { |
/* set wait INFTIM */ | /* set wait INFTIM */ |
sched_timespecinf(&r->root_wait); | sched_timespecinf(&r->root_wait); |
} | } |
#endif /* TIMER_WITHOUT_SORT */ |
#endif /* TIMER_WITHOUT_SORT */ |
/* if present member of task, set NOWAIT */ | } else /* no waiting for event, because we have ready task */ |
if (TAILQ_FIRST(&r->root_task)) | |
sched_timespecclear(&r->root_wait); |
sched_timespecclear(&r->root_wait); |
|
|
if (r->root_wait.tv_sec != -1 && r->root_wait.tv_nsec != -1) { |
if (r->root_wait.tv_sec != -1 && r->root_wait.tv_nsec != -1) { |