|
version 1.24.4.3, 2014/01/28 10:07:06
|
version 1.26.2.1, 2014/02/01 14:06:08
|
|
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, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 | Copyright 2004 - 2014 |
| 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 270 sched_hook_cancel(void *task, void *arg __unused)
|
Line 270 sched_hook_cancel(void *task, void *arg __unused)
|
| pthread_cancel((pthread_t) TASK_VAL(t)); |
pthread_cancel((pthread_t) TASK_VAL(t)); |
| #endif |
#endif |
| return NULL; |
return NULL; |
| #if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME) | #if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME) && defined(HAVE_TIMER_DELETE) |
| case taskRTC: |
case taskRTC: |
| timer_delete((timer_t) TASK_FLAG(t)); |
timer_delete((timer_t) TASK_FLAG(t)); |
| schedCancel((sched_task_t*) TASK_RET(t)); |
schedCancel((sched_task_t*) TASK_RET(t)); |
|
Line 562 sched_hook_signal(void *task, void *arg __unused)
|
Line 562 sched_hook_signal(void *task, void *arg __unused)
|
| LOGERR; |
LOGERR; |
| return (void*) -1; |
return (void*) -1; |
| } |
} |
| |
#else |
| |
#if 0 |
| |
sched_task_t *t = task; |
| |
struct sigaction sa; |
| |
|
| |
memset(&sa, 0, sizeof sa); |
| |
sigemptyset(&sa.sa_mask); |
| |
sa.sa_handler = _sched_sigHandler; |
| |
sa.sa_flags = SA_RESETHAND | SA_RESTART; |
| |
|
| |
if (sigaction(TASK_VAL(t), &sa, NULL) == -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; |
| |
} |
| |
#endif /* 0 */ |
| #endif |
#endif |
| return NULL; |
return NULL; |
| } |
} |
|
Line 621 sched_hook_fetch(void *root, void *arg __unused)
|
Line 638 sched_hook_fetch(void *root, void *arg __unused)
|
| struct timespec now, m, mtmp; |
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; |
| #else |
#else |
| struct timeval *timeout, tv; |
struct timeval *timeout, tv; |
| |
fd_set rfd, wfd, xfd; |
| #endif |
#endif |
| register int i, flg; |
register int i, flg; |
| int en; |
int en; |
|
Line 736 sched_hook_fetch(void *root, void *arg __unused)
|
Line 754 sched_hook_fetch(void *root, void *arg __unused)
|
| #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) { |
| #else |
#else |
| if ((en = select(r->root_kq, &r->root_fds[0], &r->root_fds[1], | rfd = xfd = r->root_fds[0]; |
| &r->root_fds[0], timeout)) == -1) { | wfd = r->root_fds[1]; |
| | if ((en = select(r->root_kq, &rfd, &wfd, &xfd, timeout)) == -1) { |
| #endif /* KQ_DISABLE */ |
#endif /* KQ_DISABLE */ |
| if (r->root_hooks.hook_exec.exception) { |
if (r->root_hooks.hook_exec.exception) { |
| if (r->root_hooks.hook_exec.exception(r, NULL)) |
if (r->root_hooks.hook_exec.exception(r, NULL)) |
|
Line 1123 sched_hook_fetch(void *root, void *arg __unused)
|
Line 1142 sched_hook_fetch(void *root, void *arg __unused)
|
| } |
} |
| #else /* end of kevent dispatcher */ |
#else /* end of kevent dispatcher */ |
| for (i = 0; i < r->root_kq; i++) { |
for (i = 0; i < r->root_kq; i++) { |
| if (FD_ISSET(i, &r->root_fds[0])) { | if (FD_ISSET(i, &rfd) || FD_ISSET(i, &xfd)) { |
| flg = 0; |
flg = 0; |
| TAILQ_FOREACH_SAFE(task, &r->root_read, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_read, task_node, tmp) { |
| if (TASK_FD(task) != i) |
if (TASK_FD(task) != i) |
| continue; |
continue; |
| else { |
else { |
| flg++; |
flg++; |
| TASK_RET(task) ^= TASK_RET(task); | TASK_FLAG(task) = ioctl(TASK_FD(task), |
| TASK_FLAG(task) ^= TASK_FLAG(task); | FIONREAD, &TASK_RET(task)); |
| } |
} |
| /* remove read handle */ |
/* remove read handle */ |
| #ifdef HAVE_LIBPTHREAD |
#ifdef HAVE_LIBPTHREAD |
|
Line 1177 sched_hook_fetch(void *root, void *arg __unused)
|
Line 1196 sched_hook_fetch(void *root, void *arg __unused)
|
| FD_CLR(i, &r->root_fds[0]); |
FD_CLR(i, &r->root_fds[0]); |
| } |
} |
| |
|
| if (FD_ISSET(i, &r->root_fds[1])) { | if (FD_ISSET(i, &wfd)) { |
| flg = 0; |
flg = 0; |
| TAILQ_FOREACH_SAFE(task, &r->root_write, task_node, tmp) { |
TAILQ_FOREACH_SAFE(task, &r->root_write, task_node, tmp) { |
| if (TASK_FD(task) != i) |
if (TASK_FD(task) != i) |
| continue; |
continue; |
| else { |
else { |
| flg++; |
flg++; |
| TASK_RET(task) ^= TASK_RET(task); | TASK_FLAG(task) = ioctl(TASK_FD(task), |
| TASK_FLAG(task) ^= TASK_FLAG(task); | FIONWRITE, &TASK_RET(task)); |
| } |
} |
| /* remove write handle */ |
/* remove write handle */ |
| #ifdef HAVE_LIBPTHREAD |
#ifdef HAVE_LIBPTHREAD |
|
Line 1231 sched_hook_fetch(void *root, void *arg __unused)
|
Line 1250 sched_hook_fetch(void *root, void *arg __unused)
|
| FD_CLR(i, &r->root_fds[1]); |
FD_CLR(i, &r->root_fds[1]); |
| } |
} |
| } |
} |
| |
|
| |
/* optimize select */ |
| |
for (i = r->root_kq - 1; i > 2; i--) |
| |
if (FD_ISSET(i, &r->root_fds[0]) || FD_ISSET(i, &r->root_fds[1])) |
| |
break; |
| |
if (i > 2) |
| |
r->root_kq = i + 1; |
| #endif /* KQ_DISABLE */ |
#endif /* KQ_DISABLE */ |
| |
|
| skip_event: |
skip_event: |
|
Line 1361 sched_hook_condition(void *root, void *arg)
|
Line 1387 sched_hook_condition(void *root, void *arg)
|
| * @arg = unused |
* @arg = unused |
| * return: <0 errors and 0 ok |
* return: <0 errors and 0 ok |
| */ |
*/ |
| #if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME) | #if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME) && defined(HAVE_TIMER_DELETE) |
| void * |
void * |
| sched_hook_rtc(void *task, void *arg __unused) |
sched_hook_rtc(void *task, void *arg __unused) |
| { |
{ |