--- libaitsched/inc/aitsched.h 2012/05/31 22:31:48 1.10 +++ libaitsched/inc/aitsched.h 2012/07/24 13:47:01 1.10.6.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitsched.h,v 1.10 2012/05/31 22:31:48 misho Exp $ +* $Id: aitsched.h,v 1.10.6.1 2012/07/24 13:47:01 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -62,6 +62,7 @@ SUCH DAMAGE. #define CRITERIA_VAL 4 #define CRITERIA_TS 5 #define CRITERIA_DATA 6 +#define CRITERIA_ID 7 /* early declaration for root & task */ @@ -79,6 +80,7 @@ typedef enum { taskSIGNAL, taskEVENT, taskEVENTLO, + taskSUSPEND, taskREADY, taskUNUSE, taskMAX @@ -108,10 +110,14 @@ struct sched_HooksTask { sched_hook_func_t event; /* eventlo(sched_task_t *task, NULL) -> int */ sched_hook_func_t eventlo; + /* suspend(sched_task_t *task, NULL) -> int */ + sched_hook_func_t suspend; } hook_add; struct { /* cancel(sched_task_t *task, NULL) -> int */ sched_hook_func_t cancel; + /* resume(sched_task_t *task, NULL) -> int */ + sched_hook_func_t resume; /* run(sched_root_task_t *root, NULL) -> int */ sched_hook_func_t run; /* fetch(sched_root_task_t *root, NULL) -> sched_task_t* */ @@ -197,6 +203,7 @@ struct sched_RootTask { sched_queue_t root_signal; sched_queue_t root_event; sched_queue_t root_eventlo; + sched_queue_t root_suspend; sched_queue_t root_ready; sched_queue_t root_unuse; int root_eventlo_miss; @@ -289,7 +296,7 @@ int schedCancel(sched_task_t * __restrict task); * @root = root task * @type = cancel from queue type, if =taskMAX cancel same task from all queues * @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 * @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 @@ -457,6 +464,31 @@ sched_task_t *schedEventLo(sched_root_task_t * __restr unsigned long val, void *opt_data, size_t opt_dlen); #define schedEventLoSelf(x) schedEventLo(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \ TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x))) +/* + * 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 user's trigger flags + * 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, + unsigned long id, void *opt_data, size_t opt_dlen); +#define schedSuspendSelf(x) schedUser(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \ + TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x))) +/* + * 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, unsigned char criteria, void *param); /* * schedCallOnce() - Call once from scheduler