version 1.8.2.4, 2012/05/31 21:48:01
|
version 1.10, 2012/07/24 14:06:11
|
Line 669 schedEventLo(sched_root_task_t * __restrict root, sche
|
Line 669 schedEventLo(sched_root_task_t * __restrict root, sche
|
} |
} |
|
|
/* |
/* |
|
* 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 |
|
} else |
|
task = _sched_unuseTask(task); |
|
|
|
return task; |
|
} |
|
|
|
/* |
* schedCallOnce() - Call once from scheduler |
* schedCallOnce() - Call once from scheduler |
* |
* |
* @root = root task |
* @root = root task |