|
|
| version 1.9.2.4, 2012/05/31 21:51:29 | version 1.10.6.1, 2012/07/24 13:47:01 |
|---|---|
| Line 167 schedInit(void ** __restrict data, size_t datlen) | Line 167 schedInit(void ** __restrict data, size_t datlen) |
| TAILQ_INIT(&root->root_signal); | TAILQ_INIT(&root->root_signal); |
| TAILQ_INIT(&root->root_event); | TAILQ_INIT(&root->root_event); |
| TAILQ_INIT(&root->root_eventlo); | TAILQ_INIT(&root->root_eventlo); |
| TAILQ_INIT(&root->root_suspend); | |
| TAILQ_INIT(&root->root_ready); | TAILQ_INIT(&root->root_ready); |
| TAILQ_INIT(&root->root_unuse); | TAILQ_INIT(&root->root_unuse); |
| Line 230 schedEnd(sched_root_task_t ** __restrict root) | Line 231 schedEnd(sched_root_task_t ** __restrict root) |
| schedCancel(task); | schedCancel(task); |
| TAILQ_FOREACH_SAFE(task, &(*root)->root_eventlo, task_node, tmp) | TAILQ_FOREACH_SAFE(task, &(*root)->root_eventlo, task_node, tmp) |
| schedCancel(task); | schedCancel(task); |
| TAILQ_FOREACH_SAFE(task, &(*root)->root_suspend, task_node, tmp) | |
| schedCancel(task); | |
| TAILQ_FOREACH_SAFE(task, &(*root)->root_ready, task_node, tmp) | TAILQ_FOREACH_SAFE(task, &(*root)->root_ready, task_node, tmp) |
| schedCancel(task); | schedCancel(task); |
| Line 384 schedCancel(sched_task_t * __restrict task) | Line 387 schedCancel(sched_task_t * __restrict task) |
| case taskEVENTLO: | case taskEVENTLO: |
| queue = &TASK_ROOT(task)->root_eventlo; | queue = &TASK_ROOT(task)->root_eventlo; |
| break; | break; |
| case taskSUSPEND: | |
| queue = &TASK_ROOT(task)->root_suspend; | |
| break; | |
| case taskREADY: | case taskREADY: |
| queue = &TASK_ROOT(task)->root_ready; | queue = &TASK_ROOT(task)->root_ready; |
| break; | break; |
| Line 411 schedCancel(sched_task_t * __restrict task) | Line 417 schedCancel(sched_task_t * __restrict task) |
| * @root = root task | * @root = root task |
| * @type = cancel from queue type, if =taskMAX cancel same task from all queues | * @type = cancel from queue type, if =taskMAX cancel same task from all queues |
| * @criteria = find task by criteria | * @criteria = find task by criteria |
| * [CRITERIA_ANY|CRITERIA_CALL|CRITERIA_ARG|CRITERIA_FD|CRITERIA_VAL|CRITERIA_TS|CRITERIA_DATA] | * [CRITERIA_ANY|CRITERIA_CALL|CRITERIA_ARG|CRITERIA_FD|CRITERIA_VAL|CRITERIA_ID|CRITERIA_TS|CRITERIA_DATA] |
| * @param = search parameter | * @param = search parameter |
| * @hook = custom cleanup hook function, may be NULL | * @hook = custom cleanup hook function, may be NULL |
| * return: -1 error, -2 error in sub-stage cancel execution, -3 error from custom hook or 0 ok | * return: -1 error, -2 error in sub-stage cancel execution, -3 error from custom hook or 0 ok |
| Line 448 schedCancelby(sched_root_task_t * __restrict root, sch | Line 454 schedCancelby(sched_root_task_t * __restrict root, sch |
| return -2; | return -2; |
| if (schedCancelby(root, taskEVENTLO, criteria, param, hook)) | if (schedCancelby(root, taskEVENTLO, criteria, param, hook)) |
| return -2; | return -2; |
| if (schedCancelby(root, taskSUSPEND, criteria, param, hook)) | |
| return -2; | |
| if (schedCancelby(root, taskREADY, criteria, param, hook)) | if (schedCancelby(root, taskREADY, criteria, param, hook)) |
| return -2; | return -2; |
| return 0; | return 0; |
| Line 484 schedCancelby(sched_root_task_t * __restrict root, sch | Line 492 schedCancelby(sched_root_task_t * __restrict root, sch |
| case taskEVENTLO: | case taskEVENTLO: |
| queue = &root->root_eventlo; | queue = &root->root_eventlo; |
| break; | break; |
| case taskSUSPEND: | |
| queue = &root->root_suspend; | |
| break; | |
| case taskREADY: | case taskREADY: |
| queue = &root->root_ready; | queue = &root->root_ready; |
| break; | break; |
| Line 512 schedCancelby(sched_root_task_t * __restrict root, sch | Line 523 schedCancelby(sched_root_task_t * __restrict root, sch |
| if (TASK_FD(task) == (intptr_t) param) | if (TASK_FD(task) == (intptr_t) param) |
| flg = 1; | flg = 1; |
| break; | break; |
| case CRITERIA_ID: | |
| case CRITERIA_VAL: | case CRITERIA_VAL: |
| if (TASK_VAL(task) == (u_long) param) | if (TASK_VAL(task) == (u_long) param) |
| flg = 1; | flg = 1; |
| Line 642 schedTermCondition(sched_root_task_t * __restrict root | Line 654 schedTermCondition(sched_root_task_t * __restrict root |
| root->root_cond = condValue; | root->root_cond = condValue; |
| root->root_hooks.hook_exec.condition = sched_hook_condition; | root->root_hooks.hook_exec.condition = sched_hook_condition; |
| return 0; | return 0; |
| } | |
| /* | |
| * schedResumeby() - Resume suspended task | |
| * | |
| * @root = root task | |
| * @criteria = find task by criteria | |
| * [CRITERIA_ANY|CRITERIA_ID|CRITERIA_DATA] | |
| * @param = search parameter (sched_task_t *task| u_long id) | |
| * return: -1 error or 0 resumed ok | |
| */ | |
| int | |
| schedResumeby(sched_root_task_t * __restrict root, u_char criteria, void *param) | |
| { | |
| sched_task_t *task, *tmp; | |
| register int flg = 0; | |
| if (!root) | |
| return -1; | |
| #ifdef HAVE_LIBPTHREAD | |
| pthread_mutex_lock(&root->root_mtx[taskSUSPEND]); | |
| #endif | |
| TAILQ_FOREACH_SAFE(task, &root->root_suspend, task_node, tmp) { | |
| flg ^= flg; | |
| switch (criteria) { | |
| case CRITERIA_ANY: | |
| flg = 1; | |
| break; | |
| case CRITERIA_ID: | |
| if (TASK_VAL(task) == (u_long) param) | |
| flg = 1; | |
| break; | |
| case CRITERIA_DATA: | |
| if (TASK_ID(task) == (sched_task_t*) param) | |
| flg = 1; | |
| break; | |
| default: | |
| sched_SetErr(EINVAL, "Invalid parameter criteria %d", criteria); | |
| flg = -1; | |
| } | |
| if (flg < 0) | |
| break; | |
| /* resume choosen task */ | |
| if (flg > 0) { | |
| if (root->root_hooks.hook_exec.resume) | |
| if (root->root_hooks.hook_exec.resume(task, NULL)) { | |
| flg = -1; | |
| break; | |
| } | |
| TAILQ_REMOVE(&root->root_suspend, task, task_node); | |
| task->task_type = taskREADY; | |
| #ifdef HAVE_LIBPTHREAD | |
| pthread_mutex_lock(&root->root_mtx[taskREADY]); | |
| #endif | |
| TAILQ_INSERT_TAIL(&root->root_ready, task, task_node); | |
| #ifdef HAVE_LIBPTHREAD | |
| pthread_mutex_unlock(&root->root_mtx[taskREADY]); | |
| #endif | |
| flg ^= flg; /* ok */ | |
| } | |
| } | |
| #ifdef HAVE_LIBPTHREAD | |
| pthread_mutex_unlock(&root->root_mtx[taskSUSPEND]); | |
| #endif | |
| return flg; | |
| } | } |