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