Annotation of libaitsched/inc/aitsched.h, revision 1.10.6.1

1.1       misho       1: /*************************************************************************
                      2: * (C) 2011 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
                      3: *  by Michael Pounov <misho@openbsd-bg.org>
                      4: *
                      5: * $Author: misho $
1.10.6.1! misho       6: * $Id: aitsched.h,v 1.10 2012/05/31 22:31:48 misho Exp $
1.1       misho       7: *
                      8: **************************************************************************
                      9: The ELWIX and AITNET software is distributed under the following
                     10: terms:
                     11: 
                     12: All of the documentation and software included in the ELWIX and AITNET
                     13: Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
                     14: 
1.6       misho      15: Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
1.1       misho      16:        by Michael Pounov <misho@elwix.org>.  All rights reserved.
                     17: 
                     18: Redistribution and use in source and binary forms, with or without
                     19: modification, are permitted provided that the following conditions
                     20: are met:
                     21: 1. Redistributions of source code must retain the above copyright
                     22:    notice, this list of conditions and the following disclaimer.
                     23: 2. Redistributions in binary form must reproduce the above copyright
                     24:    notice, this list of conditions and the following disclaimer in the
                     25:    documentation and/or other materials provided with the distribution.
                     26: 3. All advertising materials mentioning features or use of this software
                     27:    must display the following acknowledgement:
                     28: This product includes software developed by Michael Pounov <misho@elwix.org>
                     29: ELWIX - Embedded LightWeight unIX and its contributors.
                     30: 4. Neither the name of AITNET nor the names of its contributors
                     31:    may be used to endorse or promote products derived from this software
                     32:    without specific prior written permission.
                     33: 
                     34: THIS SOFTWARE IS PROVIDED BY AITNET AND CONTRIBUTORS ``AS IS'' AND
                     35: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     36: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     37: ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     38: FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     39: DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     40: OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     41: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     42: LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     43: OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     44: SUCH DAMAGE.
                     45: */
                     46: #ifndef __AITSCHED_H
                     47: #define __AITSCHED_H
                     48: 
                     49: 
1.2       misho      50: #include <sys/types.h>
                     51: #include <sys/queue.h>
                     52: #include <sys/uio.h>
1.3       misho      53: #include <stdint.h>
1.5       misho      54: #include <pthread.h>
1.2       misho      55: 
                     56: 
1.1       misho      57: /* criteria type */
1.10      misho      58: #define CRITERIA_ANY   0
                     59: #define CRITERIA_CALL  1
                     60: #define CRITERIA_ARG   2
                     61: #define CRITERIA_FD    3
                     62: #define CRITERIA_VAL   4
                     63: #define CRITERIA_TS    5
                     64: #define CRITERIA_DATA  6
1.10.6.1! misho      65: #define CRITERIA_ID    7
1.1       misho      66: 
                     67: 
                     68: /* early declaration for root & task */
                     69: typedef struct sched_Task      sched_task_t;
                     70: typedef struct sched_RootTask  sched_root_task_t;
                     71: 
                     72: typedef enum {
                     73:        taskREAD = 0,
                     74:        taskWRITE,
                     75:        taskTIMER,
1.10      misho      76:        taskALARM,
                     77:        taskNODE,
                     78:        taskPROC,
                     79:        taskUSER,
                     80:        taskSIGNAL,
1.9       misho      81:        taskEVENT,
                     82:        taskEVENTLO,
1.10.6.1! misho      83:        taskSUSPEND, 
1.1       misho      84:        taskREADY,
                     85:        taskUNUSE,
                     86:        taskMAX
                     87: } sched_task_type_t;
                     88: 
                     89: /* hooks */
                     90: typedef void *(*sched_hook_func_t)(void *, void *);
                     91: struct sched_HooksTask {
                     92:        struct {
                     93:                /* read(sched_task_t *task, NULL) -> int */
                     94:                sched_hook_func_t       read;
                     95:                /* write(sched_task_t *task, NULL) -> int */
                     96:                sched_hook_func_t       write;
1.10      misho      97:                /* timer(sched_task_t *task, struct timespec *ts) -> int */
                     98:                sched_hook_func_t       timer;
                     99:                /* alarm(sched_task_t *task, NULL) -> int */
                    100:                sched_hook_func_t       alarm;
                    101:                /* node(sched_task_t *task, NULL) -> int */
                    102:                sched_hook_func_t       node;
                    103:                /* proc(sched_task_t *task, NULL) -> int */
                    104:                sched_hook_func_t       proc;
                    105:                /* user(sched_task_t *task, NULL) -> int */
                    106:                sched_hook_func_t       user;
                    107:                /* signal(sched_task_t *task, NULL) -> int */
                    108:                sched_hook_func_t       signal;
1.1       misho     109:                /* event(sched_task_t *task, NULL) -> int */
                    110:                sched_hook_func_t       event;
                    111:                /* eventlo(sched_task_t *task, NULL) -> int */
                    112:                sched_hook_func_t       eventlo;
1.10.6.1! misho     113:                /* suspend(sched_task_t *task, NULL) -> int */
        !           114:                sched_hook_func_t       suspend;
1.1       misho     115:        }       hook_add;
                    116:        struct {
                    117:                /* cancel(sched_task_t *task, NULL) -> int */
                    118:                sched_hook_func_t       cancel;
1.10.6.1! misho     119:                /* resume(sched_task_t *task, NULL) -> int */
        !           120:                sched_hook_func_t       resume;
1.1       misho     121:                /* run(sched_root_task_t *root, NULL) -> int */
                    122:                sched_hook_func_t       run;
                    123:                /* fetch(sched_root_task_t *root, NULL) -> sched_task_t* */
                    124:                sched_hook_func_t       fetch;
1.3       misho     125:                /* exception(sched_root_task_t *root, NULL) -> int */
                    126:                sched_hook_func_t       exception;
1.6       misho     127:                /* condition(sched_root_task_t *root, intptr_t *stopValue) -> int */
                    128:                sched_hook_func_t       condition;
1.1       misho     129:        }       hook_exec;
                    130:        struct {
                    131:                /* init(sched_root_task_t *root, void *data) -> int */
                    132:                sched_hook_func_t       init;
                    133:                /* fini(sched_root_task_t *root, NULL) -> int */
                    134:                sched_hook_func_t       fini;
1.3       misho     135:                /* error(sched_root_task_t *root, int errno) -> int */
                    136:                sched_hook_func_t       error;
1.1       misho     137:        }       hook_root;
                    138: };
                    139: typedef struct sched_HooksTask hooks_task_t;
                    140: 
                    141: /* task callback, like pthread callback! */
1.2       misho     142: typedef void *(*sched_task_func_t)(sched_task_t * /* current task data*/);
1.1       misho     143: 
1.4       misho     144: /* task lock helpers */
1.10      misho     145: #define TASK_LOCK(x)           ((x)->task_lock = 42)
1.4       misho     146: #define TASK_UNLOCK(x)         ((x)->task_lock ^= (x)->task_lock)
                    147: #define TASK_ISLOCKED(x)       ((x)->task_lock)
                    148: 
1.1       misho     149: /* task & queue */
                    150: struct sched_Task {
1.4       misho     151:        volatile int                    task_lock;
1.10      misho     152:        uintptr_t                       task_id;
                    153: #define TASK_ID(x)     ((struct sched_Task*) (x)->task_id)
1.1       misho     154:        sched_task_type_t               task_type;
1.5       misho     155: #define TASK_TYPE(x)   (x)->task_type
1.1       misho     156: 
                    157:        sched_root_task_t               *task_root;
1.2       misho     158: #define TASK_ROOT(x)   (x)->task_root
1.1       misho     159:        sched_task_func_t               task_func;
1.8       misho     160: #define TASK_FUNC(x)   (x)->task_func
1.1       misho     161: 
                    162:        void                            *task_arg;
                    163:        union {
                    164:                unsigned long   v;
1.3       misho     165:                intptr_t        fd;
1.5       misho     166:                struct timespec ts;
1.1       misho     167:        }                               task_val;
                    168: #define TASK_ARG(x)    (x)->task_arg
                    169: #define TASK_VAL(x)    (x)->task_val.v
                    170: #define TASK_FD(x)     (x)->task_val.fd
1.5       misho     171: #define TASK_TS(x)     (x)->task_val.ts
1.1       misho     172: 
                    173:        struct iovec                    task_data;
                    174: #define TASK_DATA(x)   (x)->task_data.iov_base
                    175: #define TASK_DATLEN(x) (x)->task_data.iov_len
                    176: 
                    177:        TAILQ_ENTRY(sched_Task)         task_node;
                    178: };
                    179: typedef TAILQ_HEAD(, sched_Task) sched_queue_t;
1.5       misho     180: #define TASK_DATA_SET(x, _dp, _dl)     do { \
                    181:                                                if ((x)) { \
                    182:                                                        (x)->task_data.iov_base = (_dp); \
                    183:                                                        (x)->task_data.iov_len = _dl; \
                    184:                                                } \
                    185:                                        while (0)
1.1       misho     186: 
                    187: /* root task */
                    188: struct sched_RootTask {
                    189:        int             root_kq;
1.5       misho     190:        struct timespec root_wait;
                    191:        struct timespec root_poll;
1.6       misho     192:        intptr_t        root_cond;
                    193: 
1.5       misho     194:        pthread_mutex_t root_mtx[taskMAX];
1.1       misho     195: 
                    196:        sched_queue_t   root_read;
                    197:        sched_queue_t   root_write;
                    198:        sched_queue_t   root_timer;
1.9       misho     199:        sched_queue_t   root_alarm;
1.10      misho     200:        sched_queue_t   root_node;
                    201:        sched_queue_t   root_proc;
                    202:        sched_queue_t   root_user;
                    203:        sched_queue_t   root_signal;
1.1       misho     204:        sched_queue_t   root_event;
1.10      misho     205:        sched_queue_t   root_eventlo;
1.10.6.1! misho     206:        sched_queue_t   root_suspend;
1.1       misho     207:        sched_queue_t   root_ready;
                    208:        sched_queue_t   root_unuse;
                    209:        int             root_eventlo_miss;
                    210: 
                    211:        hooks_task_t    root_hooks;
                    212:        struct iovec    root_data;
                    213: #define ROOT_DATA(x)   (x)->root_data.iov_base
                    214: #define ROOT_DATLEN(x) (x)->root_data.iov_len
                    215: };
1.7       misho     216: #define ROOT_QUEUE_EMPTY(x, _q)        TAILQ_EMPTY(&((x)->root_##_q))
1.1       misho     217: 
                    218: 
1.2       misho     219: inline int sched_GetErrno();
                    220: inline const char *sched_GetError();
                    221: 
                    222: 
1.1       misho     223: /*
                    224:  * schedInit() - Init scheduler
1.6       misho     225:  *
1.1       misho     226:  * @data = optional data if !=NULL
                    227:  * @datlen = data len if data is set
                    228:  * return: allocated root task if ok or NULL error
                    229:  */
                    230: sched_root_task_t *schedInit(void ** __restrict data, size_t datlen);
1.2       misho     231: #define schedBegin()   schedInit((void**) &schedRegisterHooks, 0)
1.1       misho     232: /*
                    233:  * schedEnd() - End scheduler & free all resources
1.6       misho     234:  *
1.1       misho     235:  * @root = root task
                    236:  * return: -1 error or 0 ok
                    237:  */
1.2       misho     238: int schedEnd(sched_root_task_t ** __restrict root);
1.1       misho     239: /*
1.2       misho     240:  * schedRegisterHooks() - Register IO handles and bind tasks to it
1.6       misho     241:  *
1.1       misho     242:  * @root = root task
                    243:  * return: -1 error or 0 ok
                    244:  */
1.2       misho     245: int schedRegisterHooks(sched_root_task_t * __restrict root);
1.1       misho     246: /*
1.5       misho     247:  * schedPolling() - Polling timeout period if no timer task is present
1.6       misho     248:  *
1.5       misho     249:  * @root = root task
                    250:  * @ts = timeout polling period, if ==NULL INFINIT timeout
                    251:  * @tsold = old timeout polling if !=NULL
                    252:  * return: -1 error or 0 ok
                    253:  */
                    254: inline int schedPolling(sched_root_task_t * __restrict root, 
                    255:                struct timespec * __restrict ts, struct timespec * __restrict tsold);
                    256: /*
1.6       misho     257:  * schedTermCondition() - Activate hook for scheduler condition kill
                    258:  *
                    259:  * @root = root task
                    260:  * @condValue = condition value, kill schedRun() if condValue == killState
                    261:  * return: -1 error ok 0 ok
                    262:  */
                    263: inline int schedTermCondition(sched_root_task_t * __restrict root, intptr_t condValue);
                    264: /*
1.1       misho     265:  * schedCall() - Call task execution function
1.6       misho     266:  *
1.1       misho     267:  * @task = current task
                    268:  * return: !=NULL error or =NULL ok
                    269:  */
                    270: inline void *schedCall(sched_task_t * __restrict task);
                    271: /*
                    272:  * schedFetch() - Fetch ready task
1.6       misho     273:  *
1.1       misho     274:  * @root = root task
                    275:  * return: =NULL error or !=NULL ready task
                    276:  */
                    277: inline void *schedFetch(sched_root_task_t * __restrict root);
                    278: /*
                    279:  * schedRun() - Scheduler *run loop*
1.6       misho     280:  *
1.1       misho     281:  * @root = root task
1.2       misho     282:  * @killState = kill condition variable, if !=0 stop scheduler loop
1.1       misho     283:  * return: -1 error or 0 ok
                    284:  */
1.7       misho     285: int schedRun(sched_root_task_t *root, volatile intptr_t * __restrict killState);
1.1       misho     286: /*
                    287:  * schedCancel() - Cancel task from scheduler
1.6       misho     288:  *
1.1       misho     289:  * @task = task
                    290:  * return: -1 error or 0 ok
                    291:  */
                    292: int schedCancel(sched_task_t * __restrict task);
                    293: /*
                    294:  * schedCancelby() - Cancel task from scheduler by criteria
1.6       misho     295:  *
1.1       misho     296:  * @root = root task
1.5       misho     297:  * @type = cancel from queue type, if =taskMAX cancel same task from all queues
1.10      misho     298:  * @criteria = find task by criteria 
1.10.6.1! misho     299:  *     [CRITERIA_ANY|CRITERIA_CALL|CRITERIA_ARG|CRITERIA_FD|CRITERIA_VAL|CRITERIA_ID|CRITERIA_TS|CRITERIA_DATA]
1.1       misho     300:  * @param = search parameter
                    301:  * @hook = custom cleanup hook function, may be NULL
1.3       misho     302:  * return: -1 error, -2 error in sub-stage cancel execution, -3 error from custom hook or 0 ok
1.1       misho     303:  */
1.5       misho     304: int schedCancelby(sched_root_task_t * __restrict root, sched_task_type_t type, 
1.1       misho     305:                u_char criteria, void *param, sched_hook_func_t hook);
                    306: 
                    307: 
                    308: /*
1.2       misho     309:  * schedRead() - Add READ I/O task to scheduler queue
1.6       misho     310:  *
1.1       misho     311:  * @root = root task
                    312:  * @func = task execution function
                    313:  * @arg = 1st func argument
1.2       misho     314:  * @fd = fd handle
1.5       misho     315:  * @opt_data = Optional data
                    316:  * @opt_dlen = Optional data length
1.1       misho     317:  * return: NULL error or !=NULL new queued task
                    318:  */
1.5       misho     319: sched_task_t *schedRead(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    320:                int fd, void *opt_data, size_t opt_dlen);
1.8       misho     321: #define schedReadSelf(x)       schedRead(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    322:                TASK_FD((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.1       misho     323: /*
1.2       misho     324:  * schedWrite() - Add WRITE I/O task to scheduler queue
1.6       misho     325:  *
1.1       misho     326:  * @root = root task
                    327:  * @func = task execution function
                    328:  * @arg = 1st func argument
1.2       misho     329:  * @fd = fd handle
1.5       misho     330:  * @opt_data = Optional data
                    331:  * @opt_dlen = Optional data length
1.1       misho     332:  * return: NULL error or !=NULL new queued task
                    333:  */
1.5       misho     334: sched_task_t *schedWrite(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    335:                int fd, void *opt_data, size_t opt_dlen);
1.8       misho     336: #define schedWriteSelf(x)      schedWrite(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    337:                TASK_FD((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.1       misho     338: /*
1.9       misho     339:  * schedAlarm() - Add ALARM task to scheduler queue
                    340:  *
                    341:  * @root = root task
                    342:  * @func = task execution function
                    343:  * @arg = 1st func argument
                    344:  * @ts = timeout argument structure, minimum alarm timer resolution is 1msec!
                    345:  * @opt_data = Optional data
                    346:  * @opt_dlen = Optional data length
                    347:  * return: NULL error or !=NULL new queued task
                    348:  */
                    349: sched_task_t *schedAlarm(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    350:                struct timespec ts, void *opt_data, size_t opt_dlen);
                    351: #define schedAlarmSelf(x)      schedAlarm(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    352:                TASK_TS((x)), TASK_DATA((x)), TASK_DATLEN((x)))
                    353: /*
1.10      misho     354:  * schedNode() - Add NODE task to scheduler queue
                    355:  *
                    356:  * @root = root task
                    357:  * @func = task execution function
                    358:  * @arg = 1st func argument
                    359:  * @fd = fd handle
                    360:  * @opt_data = Optional data
                    361:  * @opt_dlen = Optional data length
                    362:  * return: NULL error or !=NULL new queued task
                    363:  */
                    364: sched_task_t *schedNode(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    365:                int fd, void *opt_data, size_t opt_dlen);
                    366: #define schedNodeSelf(x)       schedNode(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    367:                TASK_FD((x)), TASK_DATA((x)), TASK_DATLEN((x)))
                    368: /*
                    369:  * schedProc() - Add PROC task to scheduler queue
                    370:  *
                    371:  * @root = root task
                    372:  * @func = task execution function
                    373:  * @arg = 1st func argument
                    374:  * @pid = PID
                    375:  * @opt_data = Optional data
                    376:  * @opt_dlen = Optional data length
                    377:  * return: NULL error or !=NULL new queued task
                    378:  */
                    379: sched_task_t *schedProc(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    380:                unsigned long pid, void *opt_data, size_t opt_dlen);
                    381: #define schedProcSelf(x)       schedProc(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    382:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
                    383: /*
                    384:  * schedSignal() - Add SIGNAL task to scheduler queue
                    385:  *
                    386:  * @root = root task
                    387:  * @func = task execution function
                    388:  * @arg = 1st func argument
                    389:  * @sig = Signal
                    390:  * @opt_data = Optional data
                    391:  * @opt_dlen = Optional data length
                    392:  * return: NULL error or !=NULL new queued task
                    393:  */
                    394: sched_task_t *schedSignal(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    395:                unsigned long sig, void *opt_data, size_t opt_dlen);
                    396: #define schedSignalSelf(x)     schedSignal(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    397:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
                    398: 
                    399: /*
                    400:  * schedUser() - Add trigger USER task to scheduler queue
                    401:  *
                    402:  * @root = root task
                    403:  * @func = task execution function
                    404:  * @arg = 1st func argument
                    405:  * @id = Trigger ID
                    406:  * @opt_data = Optional data
                    407:  * @opt_dlen = Optional user's trigger flags
                    408:  * return: NULL error or !=NULL new queued task
                    409:  */
                    410: sched_task_t *schedUser(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    411:                unsigned long id, void *opt_data, size_t opt_dlen);
                    412: #define schedUserSelf(x)       schedUser(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    413:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
                    414: /*
                    415:  * schedTrigger() - Triggering USER task
                    416:  *
                    417:  * @task = task
                    418:  * return: -1 error or 0 ok
                    419:  */
                    420: int schedTrigger(sched_task_t * __restrict task);
                    421: 
                    422: /*
1.1       misho     423:  * schedTimer() - Add TIMER task to scheduler queue
1.6       misho     424:  *
1.1       misho     425:  * @root = root task
                    426:  * @func = task execution function
                    427:  * @arg = 1st func argument
1.5       misho     428:  * @ts = timeout argument structure
                    429:  * @opt_data = Optional data
                    430:  * @opt_dlen = Optional data length
1.1       misho     431:  * return: NULL error or !=NULL new queued task
                    432:  */
1.5       misho     433: sched_task_t *schedTimer(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    434:                struct timespec ts, void *opt_data, size_t opt_dlen);
1.8       misho     435: #define schedTimerSelf(x)      schedTimer(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    436:                TASK_TS((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.1       misho     437: /*
                    438:  * schedEvent() - Add EVENT task to scheduler queue
1.6       misho     439:  *
1.1       misho     440:  * @root = root task
                    441:  * @func = task execution function
                    442:  * @arg = 1st func argument
1.2       misho     443:  * @val = additional func argument
1.5       misho     444:  * @opt_data = Optional data
                    445:  * @opt_dlen = Optional data length
1.1       misho     446:  * return: NULL error or !=NULL new queued task
                    447:  */
1.5       misho     448: sched_task_t *schedEvent(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    449:                unsigned long val, void *opt_data, size_t opt_dlen);
1.8       misho     450: #define schedEventSelf(x)      schedEvent(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    451:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.1       misho     452: /*
                    453:  * schedEventLo() - Add EVENT_Lo task to scheduler queue
1.6       misho     454:  *
1.1       misho     455:  * @root = root task
                    456:  * @func = task execution function
                    457:  * @arg = 1st func argument
1.2       misho     458:  * @val = additional func argument
1.5       misho     459:  * @opt_data = Optional data
                    460:  * @opt_dlen = Optional data length
1.1       misho     461:  * return: NULL error or !=NULL new queued task
                    462:  */
1.5       misho     463: sched_task_t *schedEventLo(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    464:                unsigned long val, void *opt_data, size_t opt_dlen);
1.8       misho     465: #define schedEventLoSelf(x)    schedEventLo(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    466:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.10.6.1! misho     467: /*
        !           468:  * schedSuspend() - Add Suspended task to scheduler queue
        !           469:  *
        !           470:  * @root = root task
        !           471:  * @func = task execution function
        !           472:  * @arg = 1st func argument
        !           473:  * @id = Trigger ID
        !           474:  * @opt_data = Optional data
        !           475:  * @opt_dlen = Optional user's trigger flags
        !           476:  * return: NULL error or !=NULL new queued task
        !           477:  */
        !           478: sched_task_t *schedSuspend(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
        !           479:                unsigned long id, void *opt_data, size_t opt_dlen);
        !           480: #define schedSuspendSelf(x)    schedUser(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
        !           481:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
        !           482: /*
        !           483:  * schedResumeby() - Resume suspended task
        !           484:  *
        !           485:  * @root = root task
        !           486:  * @criteria = find task by criteria 
        !           487:  *     [CRITERIA_ANY|CRITERIA_ID|CRITERIA_DATA]
        !           488:  * @param = search parameter (sched_task_t *task| u_long id)
        !           489:  * return: -1 error or 0 resumed ok
        !           490:  */
        !           491: int schedResumeby(sched_root_task_t * __restrict root, unsigned char criteria, void *param);
1.10      misho     492: 
1.1       misho     493: /*
                    494:  * schedCallOnce() - Call once from scheduler
1.6       misho     495:  *
1.1       misho     496:  * @root = root task
                    497:  * @func = task execution function
                    498:  * @arg = 1st func argument
1.2       misho     499:  * @val = additional func argument
1.5       misho     500:  * @opt_data = Optional data
                    501:  * @opt_dlen = Optional data length
1.2       misho     502:  * return: return value from called func
1.1       misho     503:  */
1.5       misho     504: sched_task_t *schedCallOnce(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    505:                unsigned long val, void *opt_data, size_t opt_dlen);
1.8       misho     506: #define schedCallAgain(x)      schedCallOnce(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    507:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.1       misho     508: 
                    509: 
                    510: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>