File:  [ELWIX - Embedded LightWeight unIX -] / libaitsched / inc / aitsched.h
Revision 1.11.2.5: download - view: text, annotated - select for diffs - revision graph
Wed Aug 1 15:17:38 2012 UTC (11 years, 11 months ago) by misho
Branches: sched2_6
Diff to: branchpoint 1.11: preferred, unified
extend hooks

    1: /*************************************************************************
    2: * (C) 2011 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
    3: *  by Michael Pounov <misho@openbsd-bg.org>
    4: *
    5: * $Author: misho $
    6: * $Id: aitsched.h,v 1.11.2.5 2012/08/01 15:17:38 misho Exp $
    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: 
   15: Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
   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: 
   50: #include <sys/types.h>
   51: #include <sys/queue.h>
   52: #include <sys/event.h>
   53: #include <sys/uio.h>
   54: #include <stdint.h>
   55: #include <pthread.h>
   56: #ifdef EVFILT_AIO
   57: #include <aio.h>
   58: #endif
   59: 
   60: 
   61: /* criteria type */
   62: #define CRITERIA_ANY	0
   63: #define CRITERIA_CALL	1
   64: #define CRITERIA_ARG	2
   65: #define CRITERIA_FD	3
   66: #define CRITERIA_VAL	4
   67: #define CRITERIA_TS	5
   68: #define CRITERIA_DATA	6
   69: #define CRITERIA_ID	7
   70: 
   71: 
   72: /* early declaration for root & task */
   73: typedef struct sched_Task	sched_task_t;
   74: typedef struct sched_RootTask	sched_root_task_t;
   75: 
   76: typedef enum {
   77: 	taskREAD = 0,
   78: 	taskWRITE,
   79: 	taskTIMER,
   80: 	taskALARM,
   81: 	taskNODE,
   82: 	taskPROC,
   83: 	taskSIGNAL,
   84: 	taskAIO,
   85: 	taskUSER,
   86: 	taskEVENT,
   87: 	taskEVENTLO,
   88: 	taskSUSPEND, 
   89: 	taskREADY,
   90: 	taskUNUSE,
   91: 	taskMAX
   92: } sched_task_type_t;
   93: 
   94: /* hooks */
   95: typedef void *(*sched_hook_func_t)(void *, void *);
   96: struct sched_HooksTask {
   97: 	struct {
   98: 		/* read(sched_task_t *task, NULL) -> int */
   99: 		sched_hook_func_t	read;
  100: 		/* write(sched_task_t *task, NULL) -> int */
  101: 		sched_hook_func_t	write;
  102: 		/* timer(sched_task_t *task, struct timespec *ts) -> int */
  103: 		sched_hook_func_t	timer;
  104: 		/* alarm(sched_task_t *task, NULL) -> int */
  105: 		sched_hook_func_t	alarm;
  106: 		/* node(sched_task_t *task, NULL) -> int */
  107: 		sched_hook_func_t	node;
  108: 		/* proc(sched_task_t *task, NULL) -> int */
  109: 		sched_hook_func_t	proc;
  110: 		/* signal(sched_task_t *task, NULL) -> int */
  111: 		sched_hook_func_t	signal;
  112: 		/* aio(sched_task_t *task, NULL) -> int */
  113: 		sched_hook_func_t	aio;
  114: 		/* user(sched_task_t *task, NULL) -> int */
  115: 		sched_hook_func_t	user;
  116: 		/* event(sched_task_t *task, NULL) -> int */
  117: 		sched_hook_func_t	event;
  118: 		/* eventlo(sched_task_t *task, NULL) -> int */
  119: 		sched_hook_func_t	eventlo;
  120: 		/* suspend(sched_task_t *task, NULL) -> int */
  121: 		sched_hook_func_t	suspend;
  122: 	}	hook_add;
  123: 	struct {
  124: 		/* cancel(sched_task_t *task, NULL) -> int */
  125: 		sched_hook_func_t	cancel;
  126: 		/* resume(sched_task_t *task, NULL) -> int */
  127: 		sched_hook_func_t	resume;
  128: 		/* run(sched_root_task_t *root, NULL) -> int */
  129: 		sched_hook_func_t	run;
  130: 		/* fetch(sched_root_task_t *root, NULL) -> sched_task_t* */
  131: 		sched_hook_func_t	fetch;
  132: 		/* exception(sched_root_task_t *root, NULL) -> int */
  133: 		sched_hook_func_t	exception;
  134: 		/* condition(sched_root_task_t *root, intptr_t *stopValue) -> int */
  135: 		sched_hook_func_t	condition;
  136: 	}	hook_exec;
  137: 	struct {
  138: 		/* init(sched_root_task_t *root, void *data) -> int */
  139: 		sched_hook_func_t	init;
  140: 		/* fini(sched_root_task_t *root, NULL) -> int */
  141: 		sched_hook_func_t	fini;
  142: 		/* error(sched_root_task_t *root, int errno) -> int */
  143: 		sched_hook_func_t	error;
  144: 	}	hook_root;
  145: };
  146: typedef struct sched_HooksTask hooks_task_t;
  147: 
  148: /* task callback, like pthread callback! */
  149: typedef void *(*sched_task_func_t)(sched_task_t * /* current task data*/);
  150: 
  151: /* task lock helpers */
  152: #define TASK_LOCK(x)		((x)->task_lock = 42)
  153: #define TASK_UNLOCK(x)		((x)->task_lock ^= (x)->task_lock)
  154: #define TASK_ISLOCKED(x)	((x)->task_lock)
  155: 
  156: /* task & queue */
  157: struct sched_Task {
  158: 	volatile int			task_lock;
  159: 	uintptr_t			task_id;
  160: #define TASK_ID(x)	((struct sched_Task*) (x)->task_id)
  161: 	sched_task_type_t		task_type;
  162: #define TASK_TYPE(x)	(x)->task_type
  163: 
  164: 	sched_root_task_t		*task_root;
  165: #define TASK_ROOT(x)	(x)->task_root
  166: 	sched_task_func_t		task_func;
  167: #define TASK_FUNC(x)	(x)->task_func
  168: 
  169: 	void				*task_arg;
  170: 	union {
  171: 		unsigned long	v;
  172: 		intptr_t	fd;
  173: 		struct timespec	ts;
  174: 	}				task_val;
  175: #define TASK_ARG(x)	(x)->task_arg
  176: #define TASK_VAL(x)	(x)->task_val.v
  177: #define TASK_FD(x)	(x)->task_val.fd
  178: #define TASK_TS(x)	(x)->task_val.ts
  179: 
  180: 	struct iovec			task_data;
  181: #define TASK_DATA(x)	(x)->task_data.iov_base
  182: #define TASK_DATLEN(x)	(x)->task_data.iov_len
  183: 
  184: 	TAILQ_ENTRY(sched_Task)		task_node;
  185: };
  186: typedef TAILQ_HEAD(, sched_Task) sched_queue_t;
  187: #define TASK_DATA_SET(x, _dp, _dl)	do { \
  188: 						if ((x)) { \
  189: 							(x)->task_data.iov_base = (_dp); \
  190: 							(x)->task_data.iov_len = _dl; \
  191: 						} \
  192: 					while (0)
  193: 
  194: /* root task */
  195: struct sched_RootTask {
  196: 	int		root_kq;
  197: 	struct timespec	root_wait;
  198: 	struct timespec	root_poll;
  199: 	intptr_t	root_cond;
  200: 	void		*root_ret;
  201: 
  202: 	pthread_mutex_t	root_mtx[taskMAX];
  203: 
  204: 	sched_queue_t	root_read;
  205: 	sched_queue_t	root_write;
  206: 	sched_queue_t	root_timer;
  207: 	sched_queue_t	root_alarm;
  208: 	sched_queue_t	root_node;
  209: 	sched_queue_t	root_proc;
  210: 	sched_queue_t	root_signal;
  211: 	sched_queue_t	root_aio;
  212: 	sched_queue_t	root_user;
  213: 	sched_queue_t	root_event;
  214: 	sched_queue_t	root_eventlo;
  215: 	sched_queue_t	root_suspend;
  216: 	sched_queue_t	root_ready;
  217: 	sched_queue_t	root_unuse;
  218: 	int		root_eventlo_miss;
  219: 
  220: 	hooks_task_t	root_hooks;
  221: 	struct iovec	root_data;
  222: #define ROOT_DATA(x)	(x)->root_data.iov_base
  223: #define ROOT_DATLEN(x)	(x)->root_data.iov_len
  224: };
  225: #define ROOT_QUEUE_EMPTY(x, _q)	TAILQ_EMPTY(&((x)->root_##_q))
  226: #define ROOT_RETURN(x)	(x)->root_ret
  227: 
  228: 
  229: inline int sched_GetErrno();
  230: inline const char *sched_GetError();
  231: 
  232: 
  233: /*
  234:  * schedInit() - Init scheduler
  235:  *
  236:  * @data = optional data if !=NULL
  237:  * @datlen = data len if data is set
  238:  * return: allocated root task if ok or NULL error
  239:  */
  240: sched_root_task_t *schedInit(void ** __restrict data, size_t datlen);
  241: #define schedBegin()	schedInit((void**) &schedRegisterHooks, 0)
  242: /*
  243:  * schedEnd() - End scheduler & free all resources
  244:  *
  245:  * @root = root task
  246:  * return: -1 error or 0 ok
  247:  */
  248: int schedEnd(sched_root_task_t ** __restrict root);
  249: /*
  250:  * schedRegisterHooks() - Register IO handles and bind tasks to it
  251:  *
  252:  * @root = root task
  253:  * return: -1 error or 0 ok
  254:  */
  255: int schedRegisterHooks(sched_root_task_t * __restrict root);
  256: /*
  257:  * schedPolling() - Polling timeout period if no timer task is present
  258:  *
  259:  * @root = root task
  260:  * @ts = timeout polling period, if ==NULL INFINIT timeout
  261:  * @tsold = old timeout polling if !=NULL
  262:  * return: -1 error or 0 ok
  263:  */
  264: inline int schedPolling(sched_root_task_t * __restrict root, 
  265: 		struct timespec * __restrict ts, struct timespec * __restrict tsold);
  266: /*
  267:  * schedTermCondition() - Activate hook for scheduler condition kill
  268:  *
  269:  * @root = root task
  270:  * @condValue = condition value, kill schedRun() if condValue == killState
  271:  * return: -1 error ok 0 ok
  272:  */
  273: inline int schedTermCondition(sched_root_task_t * __restrict root, intptr_t condValue);
  274: /*
  275:  * schedCall() - Call task execution function
  276:  *
  277:  * @task = current task
  278:  * return: !=NULL error or =NULL ok
  279:  */
  280: inline void *schedCall(sched_task_t * __restrict task);
  281: /*
  282:  * schedFetch() - Fetch ready task
  283:  *
  284:  * @root = root task
  285:  * return: =NULL error or !=NULL ready task
  286:  */
  287: inline void *schedFetch(sched_root_task_t * __restrict root);
  288: /*
  289:  * schedRun() - Scheduler *run loop*
  290:  *
  291:  * @root = root task
  292:  * @killState = kill condition variable, if !=0 stop scheduler loop
  293:  * return: -1 error or 0 ok
  294:  */
  295: int schedRun(sched_root_task_t *root, volatile intptr_t * __restrict killState);
  296: /*
  297:  * schedCancel() - Cancel task from scheduler
  298:  *
  299:  * @task = task
  300:  * return: -1 error or 0 ok
  301:  */
  302: int schedCancel(sched_task_t * __restrict task);
  303: /*
  304:  * schedCancelby() - Cancel task from scheduler by criteria
  305:  *
  306:  * @root = root task
  307:  * @type = cancel from queue type, if =taskMAX cancel same task from all queues
  308:  * @criteria = find task by criteria 
  309:  * 	[CRITERIA_ANY|CRITERIA_CALL|CRITERIA_ARG|CRITERIA_FD|CRITERIA_VAL|CRITERIA_ID|CRITERIA_TS|CRITERIA_DATA]
  310:  * @param = search parameter
  311:  * @hook = custom cleanup hook function, may be NULL
  312:  * return: -1 error, -2 error in sub-stage cancel execution, -3 error from custom hook or 0 ok
  313:  */
  314: int schedCancelby(sched_root_task_t * __restrict root, sched_task_type_t type, 
  315: 		u_char criteria, void *param, sched_hook_func_t hook);
  316: 
  317: 
  318: /*
  319:  * schedRead() - Add READ I/O task to scheduler queue
  320:  *
  321:  * @root = root task
  322:  * @func = task execution function
  323:  * @arg = 1st func argument
  324:  * @fd = fd handle
  325:  * @opt_data = Optional data
  326:  * @opt_dlen = Optional data length
  327:  * return: NULL error or !=NULL new queued task
  328:  */
  329: sched_task_t *schedRead(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  330: 		int fd, void *opt_data, size_t opt_dlen);
  331: #define schedReadSelf(x)	schedRead(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  332: 		TASK_FD((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  333: /*
  334:  * schedWrite() - Add WRITE I/O task to scheduler queue
  335:  *
  336:  * @root = root task
  337:  * @func = task execution function
  338:  * @arg = 1st func argument
  339:  * @fd = fd handle
  340:  * @opt_data = Optional data
  341:  * @opt_dlen = Optional data length
  342:  * return: NULL error or !=NULL new queued task
  343:  */
  344: sched_task_t *schedWrite(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  345: 		int fd, void *opt_data, size_t opt_dlen);
  346: #define schedWriteSelf(x)	schedWrite(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  347: 		TASK_FD((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  348: /*
  349:  * schedAlarm() - Add ALARM task to scheduler queue
  350:  *
  351:  * @root = root task
  352:  * @func = task execution function
  353:  * @arg = 1st func argument
  354:  * @ts = timeout argument structure, minimum alarm timer resolution is 1msec!
  355:  * @opt_data = Optional data
  356:  * @opt_dlen = Optional data length
  357:  * return: NULL error or !=NULL new queued task
  358:  */
  359: sched_task_t *schedAlarm(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  360: 		struct timespec ts, void *opt_data, size_t opt_dlen);
  361: #define schedAlarmSelf(x)	schedAlarm(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  362: 		TASK_TS((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  363: /*
  364:  * schedNode() - Add NODE task to scheduler queue
  365:  *
  366:  * @root = root task
  367:  * @func = task execution function
  368:  * @arg = 1st func argument
  369:  * @fd = fd handle
  370:  * @opt_data = Optional data
  371:  * @opt_dlen = Optional data length
  372:  * return: NULL error or !=NULL new queued task
  373:  */
  374: sched_task_t *schedNode(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  375: 		int fd, void *opt_data, size_t opt_dlen);
  376: #define schedNodeSelf(x)	schedNode(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  377: 		TASK_FD((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  378: /*
  379:  * schedProc() - Add PROC task to scheduler queue
  380:  *
  381:  * @root = root task
  382:  * @func = task execution function
  383:  * @arg = 1st func argument
  384:  * @pid = PID
  385:  * @opt_data = Optional data
  386:  * @opt_dlen = Optional data length
  387:  * return: NULL error or !=NULL new queued task
  388:  */
  389: sched_task_t *schedProc(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  390: 		unsigned long pid, void *opt_data, size_t opt_dlen);
  391: #define schedProcSelf(x)	schedProc(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  392: 		TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  393: /*
  394:  * schedSignal() - Add SIGNAL task to scheduler queue
  395:  *
  396:  * @root = root task
  397:  * @func = task execution function
  398:  * @arg = 1st func argument
  399:  * @sig = Signal
  400:  * @opt_data = Optional data
  401:  * @opt_dlen = Optional data length
  402:  * return: NULL error or !=NULL new queued task
  403:  */
  404: sched_task_t *schedSignal(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  405: 		unsigned long sig, void *opt_data, size_t opt_dlen);
  406: #define schedSignalSelf(x)	schedSignal(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  407: 		TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  408: 
  409: /*
  410:  * schedAIO() - Add AIO task to scheduler queue
  411:  *
  412:  * @root = root task
  413:  * @func = task execution function
  414:  * @arg = 1st func argument
  415:  * @acb = AIO cb structure address
  416:  * @opt_data = Optional data
  417:  * @opt_dlen = Optional data length
  418:  * return: NULL error or !=NULL new queued task
  419:  */
  420: sched_task_t *schedAIO(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  421: 		struct aiocb * __restrict acb, void *opt_data, size_t opt_dlen);
  422: /*
  423:  * schedAIORead() - Add AIO read task to scheduler queue
  424:  *
  425:  * @root = root task
  426:  * @func = task execution function
  427:  * @arg = 1st func argument
  428:  * @fd = file descriptor
  429:  * @buffer = Buffer
  430:  * @buflen = Buffer length
  431:  * return: NULL error or !=NULL new queued task
  432:  */
  433: inline sched_task_t *schedAIORead(sched_root_task_t * __restrict root, sched_task_func_t func, 
  434: 		void *arg, int fd, void *buffer, size_t buflen);
  435: /*
  436:  * schedAIOWrite() - Add AIO write task to scheduler queue
  437:  *
  438:  * @root = root task
  439:  * @func = task execution function
  440:  * @arg = 1st func argument
  441:  * @fd = file descriptor
  442:  * @buffer = Buffer
  443:  * @buflen = Buffer length
  444:  * return: NULL error or !=NULL new queued task
  445:  */
  446: inline sched_task_t *schedAIOWrite(sched_root_task_t * __restrict root, sched_task_func_t func, 
  447: 		void *arg, int fd, void *buffer, size_t buflen);
  448: 
  449: /*
  450:  * schedUser() - Add trigger USER task to scheduler queue
  451:  *
  452:  * @root = root task
  453:  * @func = task execution function
  454:  * @arg = 1st func argument
  455:  * @id = Trigger ID
  456:  * @opt_data = Optional data
  457:  * @opt_dlen = Optional user's trigger flags
  458:  * return: NULL error or !=NULL new queued task
  459:  */
  460: sched_task_t *schedUser(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  461: 		unsigned long id, void *opt_data, size_t opt_dlen);
  462: #define schedUserSelf(x)	schedUser(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  463: 		TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  464: /*
  465:  * schedTrigger() - Triggering USER task
  466:  *
  467:  * @task = task
  468:  * return: -1 error or 0 ok
  469:  */
  470: int schedTrigger(sched_task_t * __restrict task);
  471: 
  472: /*
  473:  * schedTimer() - Add TIMER task to scheduler queue
  474:  *
  475:  * @root = root task
  476:  * @func = task execution function
  477:  * @arg = 1st func argument
  478:  * @ts = timeout argument structure
  479:  * @opt_data = Optional data
  480:  * @opt_dlen = Optional data length
  481:  * return: NULL error or !=NULL new queued task
  482:  */
  483: sched_task_t *schedTimer(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  484: 		struct timespec ts, void *opt_data, size_t opt_dlen);
  485: #define schedTimerSelf(x)	schedTimer(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  486: 		TASK_TS((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  487: /*
  488:  * schedEvent() - Add EVENT task to scheduler queue
  489:  *
  490:  * @root = root task
  491:  * @func = task execution function
  492:  * @arg = 1st func argument
  493:  * @val = additional func argument
  494:  * @opt_data = Optional data
  495:  * @opt_dlen = Optional data length
  496:  * return: NULL error or !=NULL new queued task
  497:  */
  498: sched_task_t *schedEvent(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  499: 		unsigned long val, void *opt_data, size_t opt_dlen);
  500: #define schedEventSelf(x)	schedEvent(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  501: 		TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  502: /*
  503:  * schedEventLo() - Add EVENT_Lo task to scheduler queue
  504:  *
  505:  * @root = root task
  506:  * @func = task execution function
  507:  * @arg = 1st func argument
  508:  * @val = additional func argument
  509:  * @opt_data = Optional data
  510:  * @opt_dlen = Optional data length
  511:  * return: NULL error or !=NULL new queued task
  512:  */
  513: sched_task_t *schedEventLo(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  514: 		unsigned long val, void *opt_data, size_t opt_dlen);
  515: #define schedEventLoSelf(x)	schedEventLo(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  516: 		TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  517: /*
  518:  * schedSuspend() - Add Suspended task to scheduler queue
  519:  *
  520:  * @root = root task
  521:  * @func = task execution function
  522:  * @arg = 1st func argument
  523:  * @id = Trigger ID
  524:  * @opt_data = Optional data
  525:  * @opt_dlen = Optional user's trigger flags
  526:  * return: NULL error or !=NULL new queued task
  527:  */
  528: sched_task_t *schedSuspend(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  529: 		unsigned long id, void *opt_data, size_t opt_dlen);
  530: #define schedSuspendSelf(x)	schedUser(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  531: 		TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  532: /*
  533:  * schedResumeby() - Resume suspended task
  534:  *
  535:  * @root = root task
  536:  * @criteria = find task by criteria 
  537:  * 	[CRITERIA_ANY|CRITERIA_ID|CRITERIA_DATA]
  538:  * @param = search parameter (sched_task_t *task| u_long id)
  539:  * return: -1 error or 0 resumed ok
  540:  */
  541: int schedResumeby(sched_root_task_t * __restrict root, unsigned char criteria, void *param);
  542: 
  543: /*
  544:  * schedCallOnce() - Call once from scheduler
  545:  *
  546:  * @root = root task
  547:  * @func = task execution function
  548:  * @arg = 1st func argument
  549:  * @val = additional func argument
  550:  * @opt_data = Optional data
  551:  * @opt_dlen = Optional data length
  552:  * return: return value from called func
  553:  */
  554: sched_task_t *schedCallOnce(sched_root_task_t * __restrict root, sched_task_func_t func, void *arg, 
  555: 		unsigned long val, void *opt_data, size_t opt_dlen);
  556: #define schedCallAgain(x)	schedCallOnce(TASK_ROOT((x)), TASK_FUNC((x)), TASK_ARG((x)), \
  557: 		TASK_VAL((x)), TASK_DATA((x)), TASK_DATLEN((x)))
  558: 
  559: 
  560: #endif

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