Annotation of libaitsched/inc/aitsched.h, revision 1.11.2.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.11.2.1! misho       6: * $Id: aitsched.h,v 1.11 2012/07/24 14:06:10 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.11      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.11      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.11      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.11      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;
1.11.2.1! misho     193:        void            *root_ret;
1.6       misho     194: 
1.5       misho     195:        pthread_mutex_t root_mtx[taskMAX];
1.1       misho     196: 
                    197:        sched_queue_t   root_read;
                    198:        sched_queue_t   root_write;
                    199:        sched_queue_t   root_timer;
1.9       misho     200:        sched_queue_t   root_alarm;
1.10      misho     201:        sched_queue_t   root_node;
                    202:        sched_queue_t   root_proc;
                    203:        sched_queue_t   root_user;
                    204:        sched_queue_t   root_signal;
1.1       misho     205:        sched_queue_t   root_event;
1.10      misho     206:        sched_queue_t   root_eventlo;
1.11      misho     207:        sched_queue_t   root_suspend;
1.1       misho     208:        sched_queue_t   root_ready;
                    209:        sched_queue_t   root_unuse;
                    210:        int             root_eventlo_miss;
                    211: 
                    212:        hooks_task_t    root_hooks;
                    213:        struct iovec    root_data;
                    214: #define ROOT_DATA(x)   (x)->root_data.iov_base
                    215: #define ROOT_DATLEN(x) (x)->root_data.iov_len
                    216: };
1.7       misho     217: #define ROOT_QUEUE_EMPTY(x, _q)        TAILQ_EMPTY(&((x)->root_##_q))
1.11.2.1! misho     218: #define ROOT_RETURN(x) (x)->root_ret
1.1       misho     219: 
                    220: 
1.2       misho     221: inline int sched_GetErrno();
                    222: inline const char *sched_GetError();
                    223: 
                    224: 
1.1       misho     225: /*
                    226:  * schedInit() - Init scheduler
1.6       misho     227:  *
1.1       misho     228:  * @data = optional data if !=NULL
                    229:  * @datlen = data len if data is set
                    230:  * return: allocated root task if ok or NULL error
                    231:  */
                    232: sched_root_task_t *schedInit(void ** __restrict data, size_t datlen);
1.2       misho     233: #define schedBegin()   schedInit((void**) &schedRegisterHooks, 0)
1.1       misho     234: /*
                    235:  * schedEnd() - End scheduler & free all resources
1.6       misho     236:  *
1.1       misho     237:  * @root = root task
                    238:  * return: -1 error or 0 ok
                    239:  */
1.2       misho     240: int schedEnd(sched_root_task_t ** __restrict root);
1.1       misho     241: /*
1.2       misho     242:  * schedRegisterHooks() - Register IO handles and bind tasks to it
1.6       misho     243:  *
1.1       misho     244:  * @root = root task
                    245:  * return: -1 error or 0 ok
                    246:  */
1.2       misho     247: int schedRegisterHooks(sched_root_task_t * __restrict root);
1.1       misho     248: /*
1.5       misho     249:  * schedPolling() - Polling timeout period if no timer task is present
1.6       misho     250:  *
1.5       misho     251:  * @root = root task
                    252:  * @ts = timeout polling period, if ==NULL INFINIT timeout
                    253:  * @tsold = old timeout polling if !=NULL
                    254:  * return: -1 error or 0 ok
                    255:  */
                    256: inline int schedPolling(sched_root_task_t * __restrict root, 
                    257:                struct timespec * __restrict ts, struct timespec * __restrict tsold);
                    258: /*
1.6       misho     259:  * schedTermCondition() - Activate hook for scheduler condition kill
                    260:  *
                    261:  * @root = root task
                    262:  * @condValue = condition value, kill schedRun() if condValue == killState
                    263:  * return: -1 error ok 0 ok
                    264:  */
                    265: inline int schedTermCondition(sched_root_task_t * __restrict root, intptr_t condValue);
                    266: /*
1.1       misho     267:  * schedCall() - Call task execution function
1.6       misho     268:  *
1.1       misho     269:  * @task = current task
                    270:  * return: !=NULL error or =NULL ok
                    271:  */
                    272: inline void *schedCall(sched_task_t * __restrict task);
                    273: /*
                    274:  * schedFetch() - Fetch ready task
1.6       misho     275:  *
1.1       misho     276:  * @root = root task
                    277:  * return: =NULL error or !=NULL ready task
                    278:  */
                    279: inline void *schedFetch(sched_root_task_t * __restrict root);
                    280: /*
                    281:  * schedRun() - Scheduler *run loop*
1.6       misho     282:  *
1.1       misho     283:  * @root = root task
1.2       misho     284:  * @killState = kill condition variable, if !=0 stop scheduler loop
1.1       misho     285:  * return: -1 error or 0 ok
                    286:  */
1.7       misho     287: int schedRun(sched_root_task_t *root, volatile intptr_t * __restrict killState);
1.1       misho     288: /*
                    289:  * schedCancel() - Cancel task from scheduler
1.6       misho     290:  *
1.1       misho     291:  * @task = task
                    292:  * return: -1 error or 0 ok
                    293:  */
                    294: int schedCancel(sched_task_t * __restrict task);
                    295: /*
                    296:  * schedCancelby() - Cancel task from scheduler by criteria
1.6       misho     297:  *
1.1       misho     298:  * @root = root task
1.5       misho     299:  * @type = cancel from queue type, if =taskMAX cancel same task from all queues
1.10      misho     300:  * @criteria = find task by criteria 
1.11      misho     301:  *     [CRITERIA_ANY|CRITERIA_CALL|CRITERIA_ARG|CRITERIA_FD|CRITERIA_VAL|CRITERIA_ID|CRITERIA_TS|CRITERIA_DATA]
1.1       misho     302:  * @param = search parameter
                    303:  * @hook = custom cleanup hook function, may be NULL
1.3       misho     304:  * return: -1 error, -2 error in sub-stage cancel execution, -3 error from custom hook or 0 ok
1.1       misho     305:  */
1.5       misho     306: int schedCancelby(sched_root_task_t * __restrict root, sched_task_type_t type, 
1.1       misho     307:                u_char criteria, void *param, sched_hook_func_t hook);
                    308: 
                    309: 
                    310: /*
1.2       misho     311:  * schedRead() - Add READ I/O task to scheduler queue
1.6       misho     312:  *
1.1       misho     313:  * @root = root task
                    314:  * @func = task execution function
                    315:  * @arg = 1st func argument
1.2       misho     316:  * @fd = fd handle
1.5       misho     317:  * @opt_data = Optional data
                    318:  * @opt_dlen = Optional data length
1.1       misho     319:  * return: NULL error or !=NULL new queued task
                    320:  */
1.5       misho     321: sched_task_t *schedRead(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    322:                int fd, void *opt_data, size_t opt_dlen);
1.8       misho     323: #define schedReadSelf(x)       schedRead(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    324:                TASK_FD((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.1       misho     325: /*
1.2       misho     326:  * schedWrite() - Add WRITE I/O task to scheduler queue
1.6       misho     327:  *
1.1       misho     328:  * @root = root task
                    329:  * @func = task execution function
                    330:  * @arg = 1st func argument
1.2       misho     331:  * @fd = fd handle
1.5       misho     332:  * @opt_data = Optional data
                    333:  * @opt_dlen = Optional data length
1.1       misho     334:  * return: NULL error or !=NULL new queued task
                    335:  */
1.5       misho     336: sched_task_t *schedWrite(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    337:                int fd, void *opt_data, size_t opt_dlen);
1.8       misho     338: #define schedWriteSelf(x)      schedWrite(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    339:                TASK_FD((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.1       misho     340: /*
1.9       misho     341:  * schedAlarm() - Add ALARM task to scheduler queue
                    342:  *
                    343:  * @root = root task
                    344:  * @func = task execution function
                    345:  * @arg = 1st func argument
                    346:  * @ts = timeout argument structure, minimum alarm timer resolution is 1msec!
                    347:  * @opt_data = Optional data
                    348:  * @opt_dlen = Optional data length
                    349:  * return: NULL error or !=NULL new queued task
                    350:  */
                    351: sched_task_t *schedAlarm(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    352:                struct timespec ts, void *opt_data, size_t opt_dlen);
                    353: #define schedAlarmSelf(x)      schedAlarm(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    354:                TASK_TS((x)), TASK_DATA((x)), TASK_DATLEN((x)))
                    355: /*
1.10      misho     356:  * schedNode() - Add NODE task to scheduler queue
                    357:  *
                    358:  * @root = root task
                    359:  * @func = task execution function
                    360:  * @arg = 1st func argument
                    361:  * @fd = fd handle
                    362:  * @opt_data = Optional data
                    363:  * @opt_dlen = Optional data length
                    364:  * return: NULL error or !=NULL new queued task
                    365:  */
                    366: sched_task_t *schedNode(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    367:                int fd, void *opt_data, size_t opt_dlen);
                    368: #define schedNodeSelf(x)       schedNode(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    369:                TASK_FD((x)), TASK_DATA((x)), TASK_DATLEN((x)))
                    370: /*
                    371:  * schedProc() - Add PROC task to scheduler queue
                    372:  *
                    373:  * @root = root task
                    374:  * @func = task execution function
                    375:  * @arg = 1st func argument
                    376:  * @pid = PID
                    377:  * @opt_data = Optional data
                    378:  * @opt_dlen = Optional data length
                    379:  * return: NULL error or !=NULL new queued task
                    380:  */
                    381: sched_task_t *schedProc(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    382:                unsigned long pid, void *opt_data, size_t opt_dlen);
                    383: #define schedProcSelf(x)       schedProc(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    384:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
                    385: /*
                    386:  * schedSignal() - Add SIGNAL task to scheduler queue
                    387:  *
                    388:  * @root = root task
                    389:  * @func = task execution function
                    390:  * @arg = 1st func argument
                    391:  * @sig = Signal
                    392:  * @opt_data = Optional data
                    393:  * @opt_dlen = Optional data length
                    394:  * return: NULL error or !=NULL new queued task
                    395:  */
                    396: sched_task_t *schedSignal(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    397:                unsigned long sig, void *opt_data, size_t opt_dlen);
                    398: #define schedSignalSelf(x)     schedSignal(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    399:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
                    400: 
                    401: /*
                    402:  * schedUser() - Add trigger USER task to scheduler queue
                    403:  *
                    404:  * @root = root task
                    405:  * @func = task execution function
                    406:  * @arg = 1st func argument
                    407:  * @id = Trigger ID
                    408:  * @opt_data = Optional data
                    409:  * @opt_dlen = Optional user's trigger flags
                    410:  * return: NULL error or !=NULL new queued task
                    411:  */
                    412: sched_task_t *schedUser(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    413:                unsigned long id, void *opt_data, size_t opt_dlen);
                    414: #define schedUserSelf(x)       schedUser(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    415:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
                    416: /*
                    417:  * schedTrigger() - Triggering USER task
                    418:  *
                    419:  * @task = task
                    420:  * return: -1 error or 0 ok
                    421:  */
                    422: int schedTrigger(sched_task_t * __restrict task);
                    423: 
                    424: /*
1.1       misho     425:  * schedTimer() - Add TIMER task to scheduler queue
1.6       misho     426:  *
1.1       misho     427:  * @root = root task
                    428:  * @func = task execution function
                    429:  * @arg = 1st func argument
1.5       misho     430:  * @ts = timeout argument structure
                    431:  * @opt_data = Optional data
                    432:  * @opt_dlen = Optional data length
1.1       misho     433:  * return: NULL error or !=NULL new queued task
                    434:  */
1.5       misho     435: sched_task_t *schedTimer(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    436:                struct timespec ts, void *opt_data, size_t opt_dlen);
1.8       misho     437: #define schedTimerSelf(x)      schedTimer(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    438:                TASK_TS((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.1       misho     439: /*
                    440:  * schedEvent() - Add EVENT task to scheduler queue
1.6       misho     441:  *
1.1       misho     442:  * @root = root task
                    443:  * @func = task execution function
                    444:  * @arg = 1st func argument
1.2       misho     445:  * @val = additional func argument
1.5       misho     446:  * @opt_data = Optional data
                    447:  * @opt_dlen = Optional data length
1.1       misho     448:  * return: NULL error or !=NULL new queued task
                    449:  */
1.5       misho     450: sched_task_t *schedEvent(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    451:                unsigned long val, void *opt_data, size_t opt_dlen);
1.8       misho     452: #define schedEventSelf(x)      schedEvent(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    453:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.1       misho     454: /*
                    455:  * schedEventLo() - Add EVENT_Lo task to scheduler queue
1.6       misho     456:  *
1.1       misho     457:  * @root = root task
                    458:  * @func = task execution function
                    459:  * @arg = 1st func argument
1.2       misho     460:  * @val = additional func argument
1.5       misho     461:  * @opt_data = Optional data
                    462:  * @opt_dlen = Optional data length
1.1       misho     463:  * return: NULL error or !=NULL new queued task
                    464:  */
1.5       misho     465: sched_task_t *schedEventLo(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    466:                unsigned long val, void *opt_data, size_t opt_dlen);
1.8       misho     467: #define schedEventLoSelf(x)    schedEventLo(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    468:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.11      misho     469: /*
                    470:  * schedSuspend() - Add Suspended task to scheduler queue
                    471:  *
                    472:  * @root = root task
                    473:  * @func = task execution function
                    474:  * @arg = 1st func argument
                    475:  * @id = Trigger ID
                    476:  * @opt_data = Optional data
                    477:  * @opt_dlen = Optional user's trigger flags
                    478:  * return: NULL error or !=NULL new queued task
                    479:  */
                    480: sched_task_t *schedSuspend(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    481:                unsigned long id, void *opt_data, size_t opt_dlen);
                    482: #define schedSuspendSelf(x)    schedUser(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    483:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
                    484: /*
                    485:  * schedResumeby() - Resume suspended task
                    486:  *
                    487:  * @root = root task
                    488:  * @criteria = find task by criteria 
                    489:  *     [CRITERIA_ANY|CRITERIA_ID|CRITERIA_DATA]
                    490:  * @param = search parameter (sched_task_t *task| u_long id)
                    491:  * return: -1 error or 0 resumed ok
                    492:  */
                    493: int schedResumeby(sched_root_task_t * __restrict root, unsigned char criteria, void *param);
1.10      misho     494: 
1.1       misho     495: /*
                    496:  * schedCallOnce() - Call once from scheduler
1.6       misho     497:  *
1.1       misho     498:  * @root = root task
                    499:  * @func = task execution function
                    500:  * @arg = 1st func argument
1.2       misho     501:  * @val = additional func argument
1.5       misho     502:  * @opt_data = Optional data
                    503:  * @opt_dlen = Optional data length
1.2       misho     504:  * return: return value from called func
1.1       misho     505:  */
1.5       misho     506: sched_task_t *schedCallOnce(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
                    507:                unsigned long val, void *opt_data, size_t opt_dlen);
1.8       misho     508: #define schedCallAgain(x)      schedCallOnce(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
                    509:                TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
1.1       misho     510: 
                    511: 
                    512: #endif

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