|
|
| version 1.8.2.3, 2012/05/31 21:36:40 | version 1.10, 2012/07/24 14:06:11 |
|---|---|
| Line 330 sched_task_t * | Line 330 sched_task_t * |
| schedUser(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, u_long id, | schedUser(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, u_long id, |
| void *opt_data, size_t opt_dlen) | void *opt_data, size_t opt_dlen) |
| { | { |
| #ifndef EVFILT_USER | |
| sched_SetErr(ENOTSUP, "Not supported kevent() filter"); | |
| return NULL; | |
| #else | |
| sched_task_t *task; | sched_task_t *task; |
| void *ptr; | void *ptr; |
| Line 367 schedUser(sched_root_task_t * __restrict root, sched_t | Line 371 schedUser(sched_root_task_t * __restrict root, sched_t |
| task = _sched_unuseTask(task); | task = _sched_unuseTask(task); |
| return task; | return task; |
| #endif | |
| } | } |
| /* | /* |
| Line 656 schedEventLo(sched_root_task_t * __restrict root, sche | Line 661 schedEventLo(sched_root_task_t * __restrict root, sche |
| TAILQ_INSERT_TAIL(&root->root_eventlo, TASK_ID(task), task_node); | TAILQ_INSERT_TAIL(&root->root_eventlo, TASK_ID(task), task_node); |
| #ifdef HAVE_LIBPTHREAD | #ifdef HAVE_LIBPTHREAD |
| pthread_mutex_unlock(&root->root_mtx[taskEVENTLO]); | pthread_mutex_unlock(&root->root_mtx[taskEVENTLO]); |
| #endif | |
| } else | |
| task = _sched_unuseTask(task); | |
| return task; | |
| } | |
| /* | |
| * schedSuspend() - Add Suspended task to scheduler queue | |
| * | |
| * @root = root task | |
| * @func = task execution function | |
| * @arg = 1st func argument | |
| * @id = Trigger ID | |
| * @opt_data = Optional data | |
| * @opt_dlen = Optional data length | |
| * return: NULL error or !=NULL new queued task | |
| */ | |
| sched_task_t * | |
| schedSuspend(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, u_long id, | |
| void *opt_data, size_t opt_dlen) | |
| { | |
| sched_task_t *task; | |
| void *ptr; | |
| if (!root || !func) | |
| return NULL; | |
| /* get new task */ | |
| if (!(task = _sched_useTask(root))) | |
| return NULL; | |
| task->task_func = func; | |
| TASK_TYPE(task) = taskSUSPEND; | |
| TASK_ROOT(task) = root; | |
| TASK_ARG(task) = arg; | |
| TASK_VAL(task) = id; | |
| TASK_DATA(task) = opt_data; | |
| TASK_DATLEN(task) = opt_dlen; | |
| if (root->root_hooks.hook_add.suspend) | |
| ptr = root->root_hooks.hook_add.suspend(task, NULL); | |
| else | |
| ptr = NULL; | |
| if (!ptr) { | |
| #ifdef HAVE_LIBPTHREAD | |
| pthread_mutex_lock(&root->root_mtx[taskSUSPEND]); | |
| #endif | |
| TAILQ_INSERT_TAIL(&root->root_suspend, TASK_ID(task), task_node); | |
| #ifdef HAVE_LIBPTHREAD | |
| pthread_mutex_unlock(&root->root_mtx[taskSUSPEND]); | |
| #endif | #endif |
| } else | } else |
| task = _sched_unuseTask(task); | task = _sched_unuseTask(task); |