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