Annotation of libaitsched/src/aitsched.c, revision 1.25.2.5

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.25.2.5! misho       6: * $Id: aitsched.c,v 1.25.2.4 2014/05/21 22:12: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.24      misho      15: Copyright 2004 - 2014
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: #include "global.h"
                     47: #include "hooks.h"
                     48: 
                     49: 
                     50: #pragma GCC visibility push(hidden)
                     51: 
                     52: int sched_Errno;
                     53: char sched_Error[STRSIZ];
                     54: 
                     55: #pragma GCC visibility pop
                     56: 
                     57: 
                     58: // sched_GetErrno() Get error code of last operation
1.18      misho      59: int
1.1       misho      60: sched_GetErrno()
                     61: {
                     62:        return sched_Errno;
                     63: }
                     64: 
                     65: // sched_GetError() Get error text of last operation
1.18      misho      66: const char *
1.1       misho      67: sched_GetError()
                     68: {
                     69:        return sched_Error;
                     70: }
                     71: 
                     72: // sched_SetErr() Set error to variables for internal use!!!
1.18      misho      73: void
1.1       misho      74: sched_SetErr(int eno, char *estr, ...)
                     75: {
                     76:        va_list lst;
                     77: 
                     78:        sched_Errno = eno;
                     79:        memset(sched_Error, 0, sizeof sched_Error);
                     80:        va_start(lst, estr);
                     81:        vsnprintf(sched_Error, sizeof sched_Error, estr, lst);
                     82:        va_end(lst);
                     83: }
                     84: 
1.25.2.2  misho      85: 
                     86: /* string support functions directly imported from OpenBSD */
                     87: 
                     88: #ifndef HAVE_STRLCAT
                     89: /*
                     90:  * Appends src to string dst of size siz (unlike strncat, siz is the
                     91:  * full size of dst, not space left).  At most siz-1 characters
                     92:  * will be copied.  Always NUL terminates (unless siz <= strlen(dst)).
                     93:  * Returns strlen(src) + MIN(siz, strlen(initial dst)).
                     94:  * If retval >= siz, truncation occurred.
                     95:  */
                     96: size_t
                     97: strlcat(char * __restrict dst, const char * __restrict src, size_t siz)
                     98: {
                     99:        char *d = dst;
                    100:        const char *s = src;
                    101:        size_t n = siz;
                    102:        size_t dlen;
                    103: 
                    104:        /* Find the end of dst and adjust bytes left but don't go past end */
                    105:        while (n-- != 0 && *d != '\0')
                    106:                d++;
                    107:        dlen = d - dst;
                    108:        n = siz - dlen;
                    109: 
                    110:        if (n == 0)
                    111:                return(dlen + strlen(s));
                    112:        while (*s != '\0') {
                    113:                if (n != 1) {
                    114:                        *d++ = *s;
                    115:                        n--;
                    116:                }
                    117:                s++;
                    118:        }
                    119:        *d = '\0';
                    120: 
                    121:        return(dlen + (s - src));       /* count does not include NUL */
                    122: }
                    123: #endif
                    124: #ifndef HAVE_STRLCPY
                    125: /*
                    126:  * Copy src to string dst of size siz.  At most siz-1 characters
                    127:  * will be copied.  Always NUL terminates (unless siz == 0).
                    128:  * Returns strlen(src); if retval >= siz, truncation occurred.
                    129:  */
                    130: size_t
                    131: strlcpy(char * __restrict dst, const char * __restrict src, size_t siz)
                    132: {
                    133:        char *d = dst;
                    134:        const char *s = src;
                    135:        size_t n = siz;
                    136: 
                    137:        /* Copy as many bytes as will fit */
                    138:        if (n != 0) {
                    139:                while (--n != 0) {
                    140:                        if ((*d++ = *s++) == '\0')
                    141:                                break;
                    142:                }
                    143:        }
                    144: 
                    145:        /* Not enough room in dst, add NUL and traverse rest of src */
                    146:        if (n == 0) {
                    147:                if (siz != 0)
                    148:                        *d = '\0';              /* NUL-terminate dst */
                    149:                while (*s++)
                    150:                        ;
                    151:        }
                    152: 
                    153:        return(s - src - 1);    /* count does not include NUL */
                    154: }
                    155: #endif
                    156: 
                    157: 
1.1       misho     158: /* Init and prepare scheduler functions */
                    159: 
                    160: /*
1.2       misho     161:  * schedRegisterHooks() - Register IO handles and bind tasks to it
1.6       misho     162:  *
1.2       misho     163:  * @root = root task
                    164:  * return: -1 error or 0 ok
                    165:  */
                    166: int
                    167: schedRegisterHooks(sched_root_task_t * __restrict root)
                    168: {
1.7       misho     169:        assert(root);
1.2       misho     170: 
                    171:        if (root->root_hooks.hook_root.fini)
                    172:                root->root_hooks.hook_root.fini(root, NULL);
                    173:        memset(&root->root_hooks, 0, sizeof root->root_hooks);
                    174: 
                    175:        root->root_hooks.hook_add.read = sched_hook_read;
                    176:        root->root_hooks.hook_add.write = sched_hook_write;
1.25      misho     177: #if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME) && defined(HAVE_TIMER_DELETE)
1.19      misho     178:        root->root_hooks.hook_add.rtc = sched_hook_rtc;
                    179: #endif
1.25.2.5! misho     180: #if SUP_ENABLE == KQ_SUPPORT
1.25.2.4  misho     181:        root->root_hooks.hook_add.alarm = sched_hook_alarm;
1.10      misho     182:        root->root_hooks.hook_add.node = sched_hook_node;
                    183:        root->root_hooks.hook_add.proc = sched_hook_proc;
                    184:        root->root_hooks.hook_add.signal = sched_hook_signal;
                    185: #ifdef EVFILT_USER
                    186:        root->root_hooks.hook_add.user = sched_hook_user;
                    187: #endif
1.25.2.4  misho     188: #endif /* KQ_SUPPORT */
1.15      misho     189: #ifdef HAVE_LIBPTHREAD
                    190:        root->root_hooks.hook_add.thread = sched_hook_thread;
                    191: #endif
1.2       misho     192: 
                    193:        root->root_hooks.hook_exec.cancel = sched_hook_cancel;
                    194:        root->root_hooks.hook_exec.fetch = sched_hook_fetch;
1.3       misho     195:        root->root_hooks.hook_exec.exception = sched_hook_exception;
1.2       misho     196: 
                    197:        root->root_hooks.hook_root.init = sched_hook_init;
                    198:        root->root_hooks.hook_root.fini = sched_hook_fini;
                    199:        return 0;
                    200: }
                    201: 
                    202: /*
1.1       misho     203:  * schedInit() - Init scheduler
1.6       misho     204:  *
1.1       misho     205:  * @data = optional data if !=NULL
                    206:  * @datlen = data len if data is set
                    207:  * return: allocated root task if ok or NULL error
                    208:  */
                    209: sched_root_task_t *
                    210: schedInit(void ** __restrict data, size_t datlen)
                    211: {
                    212:        sched_root_task_t *root = NULL;
                    213:        int (*func)(sched_root_task_t *);
1.5       misho     214: #ifdef HAVE_LIBPTHREAD
                    215:        register int i;
                    216: #endif
1.1       misho     217: 
                    218:        root = malloc(sizeof(sched_root_task_t));
1.2       misho     219:        if (!root) {
                    220:                LOGERR;
                    221:        } else {
1.1       misho     222:                memset(root, 0, sizeof(sched_root_task_t));
1.5       misho     223: 
1.13      misho     224:                /* set default maximum regular task hit misses */
                    225:                root->root_miss = MAX_TASK_MISS;
                    226: 
1.5       misho     227:                /* INFINIT polling period by default */
                    228:                sched_timespecinf(&root->root_poll);
                    229: 
                    230: #ifdef HAVE_LIBPTHREAD
                    231:                for (i = 0; i < taskMAX; i++)
1.17      misho     232:                        if ((errno = pthread_mutex_init(&root->root_mtx[i], NULL))) {
1.5       misho     233:                                LOGERR;
                    234:                                while (i)
                    235:                                        pthread_mutex_destroy(&root->root_mtx[--i]);
                    236:                                free(root);
                    237:                                return NULL;
                    238:                        }
                    239: 
                    240:                for (i = 0; i < taskMAX; i++)
                    241:                        pthread_mutex_lock(&root->root_mtx[i]);
                    242: #endif
                    243: 
1.2       misho     244:                TAILQ_INIT(&root->root_read);
                    245:                TAILQ_INIT(&root->root_write);
1.10      misho     246:                TAILQ_INIT(&root->root_timer);
1.9       misho     247:                TAILQ_INIT(&root->root_alarm);
1.19      misho     248:                TAILQ_INIT(&root->root_rtc);
1.10      misho     249:                TAILQ_INIT(&root->root_node);
                    250:                TAILQ_INIT(&root->root_proc);
1.12      misho     251:                TAILQ_INIT(&root->root_signal);
                    252:                TAILQ_INIT(&root->root_aio);
                    253:                TAILQ_INIT(&root->root_lio);
1.10      misho     254:                TAILQ_INIT(&root->root_user);
1.2       misho     255:                TAILQ_INIT(&root->root_event);
1.13      misho     256:                TAILQ_INIT(&root->root_task);
1.11      misho     257:                TAILQ_INIT(&root->root_suspend);
1.2       misho     258:                TAILQ_INIT(&root->root_ready);
                    259:                TAILQ_INIT(&root->root_unuse);
1.15      misho     260:                TAILQ_INIT(&root->root_thread);
1.1       misho     261: 
1.5       misho     262: #ifdef HAVE_LIBPTHREAD
                    263:                for (i = 0; i < taskMAX; i++)
                    264:                        pthread_mutex_unlock(&root->root_mtx[i]);
                    265: #endif
                    266: 
1.1       misho     267:                if (data && *data) {
                    268:                        if (datlen) {
                    269:                                root->root_data.iov_base = *data;
                    270:                                root->root_data.iov_len = datlen;
1.3       misho     271:                        } else { /* if datlen == 0, switch to callbacks init mode */
                    272:                                 /* little hack :) for correct initialization of scheduler */
1.2       misho     273:                                func = (int(*)(sched_root_task_t*)) data;
1.1       misho     274:                                func(root);
                    275:                        }
                    276:                }
1.2       misho     277: 
                    278:                if (root->root_hooks.hook_root.init)
                    279:                        root->root_hooks.hook_root.init(root, NULL);
1.1       misho     280:        }
                    281: 
                    282:        return root;
                    283: }
                    284: 
                    285: /*
                    286:  * schedEnd() - End scheduler & free all resources
1.6       misho     287:  *
1.1       misho     288:  * @root = root task
                    289:  * return: -1 error or 0 ok
                    290:  */
                    291: int
1.2       misho     292: schedEnd(sched_root_task_t ** __restrict root)
1.1       misho     293: {
1.7       misho     294:        sched_task_t *task, *tmp;
1.5       misho     295: #ifdef HAVE_LIBPTHREAD
                    296:        register int i;
                    297: #endif
1.1       misho     298: 
1.2       misho     299:        if (!root || !*root)
1.1       misho     300:                return -1;
                    301: 
1.10      misho     302:        TAILQ_FOREACH_SAFE(task, &(*root)->root_read, task_node, tmp)
                    303:                schedCancel(task);
                    304:        TAILQ_FOREACH_SAFE(task, &(*root)->root_write, task_node, tmp)
1.1       misho     305:                schedCancel(task);
1.10      misho     306:        TAILQ_FOREACH_SAFE(task, &(*root)->root_timer, task_node, tmp)
                    307:                schedCancel(task);
                    308:        TAILQ_FOREACH_SAFE(task, &(*root)->root_alarm, task_node, tmp)
                    309:                schedCancel(task);
1.19      misho     310:        TAILQ_FOREACH_SAFE(task, &(*root)->root_rtc, task_node, tmp)
                    311:                schedCancel(task);
1.10      misho     312:        TAILQ_FOREACH_SAFE(task, &(*root)->root_node, task_node, tmp)
                    313:                schedCancel(task);
                    314:        TAILQ_FOREACH_SAFE(task, &(*root)->root_proc, task_node, tmp)
1.1       misho     315:                schedCancel(task);
1.12      misho     316:        TAILQ_FOREACH_SAFE(task, &(*root)->root_signal, task_node, tmp)
                    317:                schedCancel(task);
                    318:        TAILQ_FOREACH_SAFE(task, &(*root)->root_aio, task_node, tmp)
                    319:                schedCancel(task);
                    320:        TAILQ_FOREACH_SAFE(task, &(*root)->root_lio, task_node, tmp)
                    321:                schedCancel(task);
1.10      misho     322:        TAILQ_FOREACH_SAFE(task, &(*root)->root_user, task_node, tmp)
1.9       misho     323:                schedCancel(task);
1.10      misho     324:        TAILQ_FOREACH_SAFE(task, &(*root)->root_event, task_node, tmp)
1.1       misho     325:                schedCancel(task);
1.11      misho     326:        TAILQ_FOREACH_SAFE(task, &(*root)->root_suspend, task_node, tmp)
                    327:                schedCancel(task);
1.10      misho     328:        TAILQ_FOREACH_SAFE(task, &(*root)->root_ready, task_node, tmp)
1.1       misho     329:                schedCancel(task);
1.15      misho     330:        TAILQ_FOREACH_SAFE(task, &(*root)->root_thread, task_node, tmp)
                    331:                schedCancel(task);
1.16      misho     332:        TAILQ_FOREACH_SAFE(task, &(*root)->root_task, task_node, tmp)
                    333:                schedCancel(task);
1.1       misho     334: 
1.5       misho     335: #ifdef HAVE_LIBPTHREAD
                    336:        pthread_mutex_lock(&(*root)->root_mtx[taskUNUSE]);
                    337: #endif
1.10      misho     338:        TAILQ_FOREACH_SAFE(task, &(*root)->root_unuse, task_node, tmp) {
1.2       misho     339:                TAILQ_REMOVE(&(*root)->root_unuse, task, task_node);
1.1       misho     340:                free(task);
                    341:        }
1.5       misho     342: #ifdef HAVE_LIBPTHREAD
                    343:        pthread_mutex_unlock(&(*root)->root_mtx[taskUNUSE]);
                    344: #endif
1.1       misho     345: 
1.2       misho     346:        if ((*root)->root_hooks.hook_root.fini)
                    347:                (*root)->root_hooks.hook_root.fini(*root, NULL);
1.1       misho     348: 
1.5       misho     349: #ifdef HAVE_LIBPTHREAD
                    350:        for (i = 0; i < taskMAX; i++)
                    351:                pthread_mutex_destroy(&(*root)->root_mtx[i]);
                    352: #endif
                    353: 
1.2       misho     354:        free(*root);
                    355:        *root = NULL;
1.1       misho     356:        return 0;
                    357: }
                    358: 
                    359: /*
                    360:  * schedCall() - Call task execution function
1.6       misho     361:  *
1.1       misho     362:  * @task = current task
                    363:  * return: !=NULL error or =NULL ok
                    364:  */
1.18      misho     365: void *
1.1       misho     366: schedCall(sched_task_t * __restrict task)
                    367: {
1.4       misho     368:        void *ptr = (void*) -1;
                    369: 
1.1       misho     370:        if (!task)
1.4       misho     371:                return ptr;
                    372: 
                    373:        if (!TASK_ISLOCKED(task))
                    374:                TASK_LOCK(task);
1.1       misho     375: 
1.4       misho     376:        ptr = task->task_func(task);
                    377: 
                    378:        TASK_UNLOCK(task);
                    379:        return ptr;
1.1       misho     380: }
                    381: 
                    382: /*
                    383:  * schedFetch() - Fetch ready task
1.6       misho     384:  *
1.1       misho     385:  * @root = root task
                    386:  * return: =NULL error or !=NULL ready task
                    387:  */
1.18      misho     388: void *
1.1       misho     389: schedFetch(sched_root_task_t * __restrict root)
                    390: {
                    391:        void *ptr;
                    392: 
                    393:        if (!root)
                    394:                return NULL;
                    395: 
                    396:        if (root->root_hooks.hook_exec.fetch)
                    397:                ptr = root->root_hooks.hook_exec.fetch(root, NULL);
                    398:        else
                    399:                ptr = NULL;
                    400: 
                    401:        return ptr;
                    402: }
                    403: 
                    404: /*
1.10      misho     405:  * schedTrigger() - Triggering USER task
                    406:  *
                    407:  * @task = task
                    408:  * return: -1 error or 0 ok
                    409:  */
                    410: int
                    411: schedTrigger(sched_task_t * __restrict task)
                    412: {
1.25.2.1  misho     413: #if SUP_ENABLE != KQ_SUPPORT
1.24      misho     414:        sched_SetErr(ENOTSUP, "disabled kqueue support");
                    415:        return -1;
                    416: #else
1.10      misho     417: #ifndef EVFILT_USER
                    418:        sched_SetErr(ENOTSUP, "Not supported kevent() filter");
                    419:        return -1;
                    420: #else
                    421:        struct kevent chg[1];
                    422:        struct timespec timeout = { 0, 0 };
                    423: 
                    424:        if (!task || !TASK_ROOT(task))
                    425:                return -1;
                    426: 
                    427: #ifdef __NetBSD__
                    428:        EV_SET(chg, TASK_VAL(task), EVFILT_USER, 0, NOTE_TRIGGER, 0, (intptr_t) TASK_VAL(task));
                    429: #else
                    430:        EV_SET(chg, TASK_VAL(task), EVFILT_USER, 0, NOTE_TRIGGER, 0, (void*) TASK_VAL(task));
                    431: #endif
                    432:        if (kevent(TASK_ROOT(task)->root_kq, chg, 1, NULL, 0, &timeout) == -1) {
                    433:                LOGERR;
                    434:                return -1;
                    435:        }
                    436: 
                    437:        return 0;
                    438: #endif
1.25.2.3  misho     439: #endif /* KQ_SUPPORT */
1.10      misho     440: }
                    441: 
                    442: /*
1.20      misho     443:  * schedQuery() - Query task in scheduler
                    444:  *
                    445:  * @task = task
                    446:  * return: -1 error, 0 found  and 1 not found
                    447:  */
                    448: int
                    449: schedQuery(sched_task_t * __restrict task)
                    450: {
                    451:        sched_queue_t *queue;
                    452:        sched_task_t *t;
                    453: 
                    454:        if (!task || !TASK_ROOT(task))
                    455:                return -1;      /* error */
                    456: 
                    457:        switch (TASK_TYPE(task)) {
                    458:                case taskREAD:
                    459:                        queue = &TASK_ROOT(task)->root_read;
                    460:                        break;
                    461:                case taskWRITE:
                    462:                        queue = &TASK_ROOT(task)->root_write;
                    463:                        break;
                    464:                case taskTIMER:
                    465:                        queue = &TASK_ROOT(task)->root_timer;
                    466:                        break;
                    467:                case taskALARM:
                    468:                        queue = &TASK_ROOT(task)->root_alarm;
                    469:                        break;
                    470:                case taskRTC:
                    471:                        queue = &TASK_ROOT(task)->root_rtc;
                    472:                        break;
                    473:                case taskNODE:
                    474:                        queue = &TASK_ROOT(task)->root_node;
                    475:                        break;
                    476:                case taskPROC:
                    477:                        queue = &TASK_ROOT(task)->root_proc;
                    478:                        break;
                    479:                case taskSIGNAL:
                    480:                        queue = &TASK_ROOT(task)->root_signal;
                    481:                        break;
                    482:                case taskAIO:
                    483:                        queue = &TASK_ROOT(task)->root_aio;
                    484:                        break;
                    485:                case taskLIO:
                    486:                        queue = &TASK_ROOT(task)->root_lio;
                    487:                        break;
                    488:                case taskUSER:
                    489:                        queue = &TASK_ROOT(task)->root_user;
                    490:                        break;
                    491:                case taskEVENT:
                    492:                        queue = &TASK_ROOT(task)->root_event;
                    493:                        break;
                    494:                case taskTASK:
                    495:                        queue = &TASK_ROOT(task)->root_task;
                    496:                        break;
                    497:                case taskSUSPEND:
                    498:                        queue = &TASK_ROOT(task)->root_suspend;
                    499:                        break;
                    500:                case taskREADY:
                    501:                        queue = &TASK_ROOT(task)->root_ready;
                    502:                        break;
                    503:                case taskTHREAD:
                    504:                        queue = &TASK_ROOT(task)->root_thread;
                    505:                        break;
                    506:                default:
                    507:                        return 1;       /* not in queue */
                    508:        }
                    509:        if (queue)
                    510:                TAILQ_FOREACH(t, queue, task_node)
                    511:                        if (TASK_ID(t) == TASK_ID(task))
                    512:                                return 0;       /* found */
                    513: 
                    514:        return 1;       /* not in queue */
                    515: }
                    516: 
                    517: /*
                    518:  * schedQueryby() - Query task in scheduler by criteria
                    519:  *
                    520:  * @root = root task
                    521:  * @type = query from queue type, if =taskMAX query same task from all queues
                    522:  * @criteria = find task by criteria 
                    523:  *     [ CRITERIA_ANY|CRITERIA_CALL|CRITERIA_ARG|CRITERIA_FD|CRITERIA_VAL|
1.23      misho     524:  *             CRITERIA_ID|CRITERIA_TS|CRITERIA_DATA|CRITERIA_DATLEN ]
1.20      misho     525:  * @param = search parameter
                    526:  * return: -1 error, 0 found or 1 not found
                    527:  */
                    528: int
                    529: schedQueryby(sched_root_task_t * __restrict root, sched_task_type_t type, 
                    530:                u_char criteria, void *param)
                    531: {
1.21      misho     532:        sched_task_t *task;
1.20      misho     533:        sched_queue_t *queue;
                    534:        register int flg = 0;
                    535: 
                    536:        if (!root)
                    537:                return -1;
                    538:        /* if type == taskMAX check in all queues */
                    539:        if (type == taskMAX) {
                    540:                if ((flg = schedQueryby(root, taskREAD, criteria, param)) < 1)
                    541:                        return flg;
                    542:                if ((flg = schedQueryby(root, taskWRITE, criteria, param)) < 1)
                    543:                        return flg;
                    544:                if ((flg = schedQueryby(root, taskTIMER, criteria, param)) < 1)
                    545:                        return flg;
                    546:                if ((flg = schedQueryby(root, taskALARM, criteria, param)) < 1)
                    547:                        return flg;
                    548:                if ((flg = schedQueryby(root, taskRTC, criteria, param)) < 1)
                    549:                        return flg;
                    550:                if ((flg = schedQueryby(root, taskNODE, criteria, param)) < 1)
                    551:                        return flg;
                    552:                if ((flg = schedQueryby(root, taskPROC, criteria, param)) < 1)
                    553:                        return flg;
                    554:                if ((flg = schedQueryby(root, taskSIGNAL, criteria, param)) < 1)
                    555:                        return flg;
                    556:                if ((flg = schedQueryby(root, taskAIO, criteria, param)) < 1)
                    557:                        return flg;
                    558:                if ((flg = schedQueryby(root, taskLIO, criteria, param)) < 1)
                    559:                        return flg;
                    560:                if ((flg = schedQueryby(root, taskUSER, criteria, param)) < 1)
                    561:                        return flg;
                    562:                if ((flg = schedQueryby(root, taskEVENT, criteria, param)) < 1)
                    563:                        return flg;
                    564:                if ((flg = schedQueryby(root, taskTASK, criteria, param)) < 1)
                    565:                        return flg;
                    566:                if ((flg = schedQueryby(root, taskSUSPEND, criteria, param)) < 1)
                    567:                        return flg;
                    568:                if ((flg = schedQueryby(root, taskREADY, criteria, param)) < 1)
                    569:                        return flg;
                    570:                if ((flg = schedQueryby(root, taskTHREAD, criteria, param)) < 1)
                    571:                        return flg;
                    572:                return 1;       /* not found */
                    573:        }
                    574:        /* choosen queue */
                    575:        switch (type) {
                    576:                case taskREAD:
                    577:                        queue = &root->root_read;
                    578:                        break;
                    579:                case taskWRITE:
                    580:                        queue = &root->root_write;
                    581:                        break;
                    582:                case taskTIMER:
                    583:                        queue = &root->root_timer;
                    584:                        break;
                    585:                case taskALARM:
                    586:                        queue = &root->root_alarm;
                    587:                        break;
                    588:                case taskRTC:
                    589:                        queue = &root->root_rtc;
                    590:                        break;
                    591:                case taskNODE:
                    592:                        queue = &root->root_node;
                    593:                        break;
                    594:                case taskPROC:
                    595:                        queue = &root->root_proc;
                    596:                        break;
                    597:                case taskSIGNAL:
                    598:                        queue = &root->root_signal;
                    599:                        break;
                    600:                case taskAIO:
                    601:                        queue = &root->root_aio;
                    602:                        break;
                    603:                case taskLIO:
                    604:                        queue = &root->root_lio;
                    605:                        break;
                    606:                case taskUSER:
                    607:                        queue = &root->root_user;
                    608:                        break;
                    609:                case taskEVENT:
                    610:                        queue = &root->root_event;
                    611:                        break;
                    612:                case taskTASK:
                    613:                        queue = &root->root_task;
                    614:                        break;
                    615:                case taskSUSPEND:
                    616:                        queue = &root->root_suspend;
                    617:                        break;
                    618:                case taskREADY:
                    619:                        queue = &root->root_ready;
                    620:                        break;
                    621:                case taskTHREAD:
                    622:                        queue = &root->root_thread;
                    623:                        break;
                    624:                default:
                    625:                        return 1;       /* not found */
                    626:        }
                    627: 
                    628:        TAILQ_FOREACH(task, queue, task_node) {
                    629:                switch (criteria) {
                    630:                        case CRITERIA_ANY:
                    631:                                return 0;               /* found */
                    632:                        case CRITERIA_CALL:
                    633:                                if (TASK_FUNC(task) == (sched_task_func_t) param)
                    634:                                        return 0;       /* found */
                    635:                                break;
                    636:                        case CRITERIA_ARG:
                    637:                                if (TASK_ARG(task) == param)
                    638:                                        return 0;       /* found */
                    639:                                break;
                    640:                        case CRITERIA_FD:
                    641:                                if (TASK_FD(task) == (intptr_t) param)
                    642:                                        return 0;       /* found */
                    643:                                break;
                    644:                        case CRITERIA_ID:
                    645:                        case CRITERIA_VAL:
                    646:                                if (TASK_VAL(task) == (u_long) param)
                    647:                                        return 0;       /* found */
                    648:                                break;
                    649:                        case CRITERIA_TS:
                    650:                                if (!sched_timespeccmp(&TASK_TS(task), 
                    651:                                                        (struct timespec*) param, -))
                    652:                                        return 0;       /* found */
                    653:                                break;
                    654:                        case CRITERIA_DATA:
                    655:                                if (TASK_DATA(task) == param)
                    656:                                        return 0;       /* found */
                    657:                                break;
1.23      misho     658:                        case CRITERIA_DATLEN:
                    659:                                if (TASK_DATLEN(task) == (size_t) param)
                    660:                                        return 0;       /* found */
                    661:                                break;
1.20      misho     662:                        default:
                    663:                                sched_SetErr(EINVAL, "Invalid parameter criteria %d", 
                    664:                                                criteria);
                    665:                                return 1;               /* not found */
                    666:                }
                    667:        }
                    668: 
                    669:        return 1;       /* not found */
                    670: }
                    671: 
                    672: /*
1.1       misho     673:  * schedCancel() - Cancel task from scheduler
1.6       misho     674:  *
1.1       misho     675:  * @task = task
                    676:  * return: -1 error or 0 ok
                    677:  */
                    678: int
                    679: schedCancel(sched_task_t * __restrict task)
                    680: {
                    681:        sched_queue_t *queue;
                    682: 
1.5       misho     683:        if (!task || !TASK_ROOT(task))
1.1       misho     684:                return -1;
                    685: 
1.5       misho     686:        if (TASK_ROOT(task)->root_hooks.hook_exec.cancel)
                    687:                if (TASK_ROOT(task)->root_hooks.hook_exec.cancel(task, NULL))
1.1       misho     688:                        return -1;
                    689: 
1.5       misho     690:        switch (TASK_TYPE(task)) {
1.1       misho     691:                case taskREAD:
1.5       misho     692:                        queue = &TASK_ROOT(task)->root_read;
1.1       misho     693:                        break;
                    694:                case taskWRITE:
1.5       misho     695:                        queue = &TASK_ROOT(task)->root_write;
1.1       misho     696:                        break;
1.10      misho     697:                case taskTIMER:
                    698:                        queue = &TASK_ROOT(task)->root_timer;
                    699:                        break;
1.9       misho     700:                case taskALARM:
                    701:                        queue = &TASK_ROOT(task)->root_alarm;
                    702:                        break;
1.19      misho     703:                case taskRTC:
                    704:                        queue = &TASK_ROOT(task)->root_rtc;
                    705:                        break;
1.10      misho     706:                case taskNODE:
                    707:                        queue = &TASK_ROOT(task)->root_node;
                    708:                        break;
                    709:                case taskPROC:
                    710:                        queue = &TASK_ROOT(task)->root_proc;
                    711:                        break;
1.12      misho     712:                case taskSIGNAL:
                    713:                        queue = &TASK_ROOT(task)->root_signal;
                    714:                        break;
                    715:                case taskAIO:
                    716:                        queue = &TASK_ROOT(task)->root_aio;
                    717:                        break;
                    718:                case taskLIO:
                    719:                        queue = &TASK_ROOT(task)->root_lio;
                    720:                        break;
1.10      misho     721:                case taskUSER:
                    722:                        queue = &TASK_ROOT(task)->root_user;
                    723:                        break;
1.1       misho     724:                case taskEVENT:
1.5       misho     725:                        queue = &TASK_ROOT(task)->root_event;
                    726:                        break;
1.13      misho     727:                case taskTASK:
                    728:                        queue = &TASK_ROOT(task)->root_task;
1.1       misho     729:                        break;
1.11      misho     730:                case taskSUSPEND:
                    731:                        queue = &TASK_ROOT(task)->root_suspend;
                    732:                        break;
1.1       misho     733:                case taskREADY:
1.5       misho     734:                        queue = &TASK_ROOT(task)->root_ready;
1.1       misho     735:                        break;
1.15      misho     736:                case taskTHREAD:
                    737:                        queue = &TASK_ROOT(task)->root_thread;
                    738:                        break;
1.1       misho     739:                default:
                    740:                        queue = NULL;
                    741:        }
1.5       misho     742:        if (queue) {
                    743: #ifdef HAVE_LIBPTHREAD
                    744:                pthread_mutex_lock(&TASK_ROOT(task)->root_mtx[TASK_TYPE(task)]);
                    745: #endif
1.10      misho     746:                TAILQ_REMOVE(queue, TASK_ID(task), task_node);
1.5       misho     747: #ifdef HAVE_LIBPTHREAD
                    748:                pthread_mutex_unlock(&TASK_ROOT(task)->root_mtx[TASK_TYPE(task)]);
                    749: #endif
                    750:        }
                    751:        if (TASK_TYPE(task) != taskUNUSE)
1.15      misho     752:                sched_unuseTask(task);
1.1       misho     753: 
                    754:        return 0;
                    755: }
                    756: 
                    757: /*
                    758:  * schedCancelby() - Cancel task from scheduler by criteria
1.6       misho     759:  *
1.1       misho     760:  * @root = root task
1.5       misho     761:  * @type = cancel from queue type, if =taskMAX cancel same task from all queues
1.10      misho     762:  * @criteria = find task by criteria 
1.20      misho     763:  *     [ CRITERIA_ANY|CRITERIA_CALL|CRITERIA_ARG|CRITERIA_FD|CRITERIA_VAL|
1.23      misho     764:  *             CRITERIA_ID|CRITERIA_TS|CRITERIA_DATA|CRITERIA_DATLEN ]
1.1       misho     765:  * @param = search parameter
                    766:  * @hook = custom cleanup hook function, may be NULL
1.3       misho     767:  * return: -1 error, -2 error in sub-stage cancel execution, -3 error from custom hook or 0 ok
1.1       misho     768:  */
                    769: int
1.5       misho     770: schedCancelby(sched_root_task_t * __restrict root, sched_task_type_t type, 
1.1       misho     771:                u_char criteria, void *param, sched_hook_func_t hook)
                    772: {
1.8       misho     773:        sched_task_t *task, *tmp;
1.5       misho     774:        sched_queue_t *queue;
1.8       misho     775:        register int flg = 0;
1.1       misho     776: 
                    777:        if (!root)
                    778:                return -1;
1.10      misho     779:        /* if type == taskMAX check in all queues */
1.5       misho     780:        if (type == taskMAX) {
                    781:                if (schedCancelby(root, taskREAD, criteria, param, hook))
1.1       misho     782:                        return -2;
1.5       misho     783:                if (schedCancelby(root, taskWRITE, criteria, param, hook))
1.1       misho     784:                        return -2;
1.10      misho     785:                if (schedCancelby(root, taskTIMER, criteria, param, hook))
                    786:                        return -2;
1.9       misho     787:                if (schedCancelby(root, taskALARM, criteria, param, hook))
                    788:                        return -2;
1.19      misho     789:                if (schedCancelby(root, taskRTC, criteria, param, hook))
                    790:                        return -2;
1.10      misho     791:                if (schedCancelby(root, taskNODE, criteria, param, hook))
                    792:                        return -2;
                    793:                if (schedCancelby(root, taskPROC, criteria, param, hook))
                    794:                        return -2;
1.12      misho     795:                if (schedCancelby(root, taskSIGNAL, criteria, param, hook))
                    796:                        return -2;
                    797:                if (schedCancelby(root, taskAIO, criteria, param, hook))
                    798:                        return -2;
                    799:                if (schedCancelby(root, taskLIO, criteria, param, hook))
                    800:                        return -2;
1.10      misho     801:                if (schedCancelby(root, taskUSER, criteria, param, hook))
                    802:                        return -2;
1.5       misho     803:                if (schedCancelby(root, taskEVENT, criteria, param, hook))
1.1       misho     804:                        return -2;
1.13      misho     805:                if (schedCancelby(root, taskTASK, criteria, param, hook))
1.1       misho     806:                        return -2;
1.11      misho     807:                if (schedCancelby(root, taskSUSPEND, criteria, param, hook))
                    808:                        return -2;
1.5       misho     809:                if (schedCancelby(root, taskREADY, criteria, param, hook))
1.1       misho     810:                        return -2;
1.15      misho     811:                if (schedCancelby(root, taskTHREAD, criteria, param, hook))
                    812:                        return -2;
1.1       misho     813:                return 0;
                    814:        }
1.10      misho     815:        /* choosen queue */
1.5       misho     816:        switch (type) {
                    817:                case taskREAD:
                    818:                        queue = &root->root_read;
                    819:                        break;
                    820:                case taskWRITE:
                    821:                        queue = &root->root_write;
                    822:                        break;
1.10      misho     823:                case taskTIMER:
                    824:                        queue = &root->root_timer;
                    825:                        break;
1.9       misho     826:                case taskALARM:
                    827:                        queue = &root->root_alarm;
                    828:                        break;
1.19      misho     829:                case taskRTC:
                    830:                        queue = &root->root_rtc;
                    831:                        break;
1.10      misho     832:                case taskNODE:
                    833:                        queue = &root->root_node;
                    834:                        break;
                    835:                case taskPROC:
                    836:                        queue = &root->root_proc;
                    837:                        break;
1.12      misho     838:                case taskSIGNAL:
                    839:                        queue = &root->root_signal;
                    840:                        break;
                    841:                case taskAIO:
                    842:                        queue = &root->root_aio;
                    843:                        break;
                    844:                case taskLIO:
                    845:                        queue = &root->root_lio;
                    846:                        break;
1.10      misho     847:                case taskUSER:
                    848:                        queue = &root->root_user;
                    849:                        break;
1.5       misho     850:                case taskEVENT:
                    851:                        queue = &root->root_event;
                    852:                        break;
1.13      misho     853:                case taskTASK:
                    854:                        queue = &root->root_task;
1.5       misho     855:                        break;
1.11      misho     856:                case taskSUSPEND:
                    857:                        queue = &root->root_suspend;
                    858:                        break;
1.5       misho     859:                case taskREADY:
                    860:                        queue = &root->root_ready;
                    861:                        break;
1.15      misho     862:                case taskTHREAD:
                    863:                        queue = &root->root_thread;
                    864:                        break;
1.5       misho     865:                default:
                    866:                        return 0;
                    867:        }
1.1       misho     868: 
1.5       misho     869: #ifdef HAVE_LIBPTHREAD
                    870:        pthread_mutex_lock(&root->root_mtx[type]);
                    871: #endif
1.8       misho     872:        TAILQ_FOREACH_SAFE(task, queue, task_node, tmp) {
                    873:                flg ^= flg;
                    874:                switch (criteria) {
1.10      misho     875:                        case CRITERIA_ANY:
                    876:                                flg = 1;
                    877:                                break;
1.8       misho     878:                        case CRITERIA_CALL:
                    879:                                if (TASK_FUNC(task) == (sched_task_func_t) param)
                    880:                                        flg = 1;
1.1       misho     881:                                break;
1.8       misho     882:                        case CRITERIA_ARG:
                    883:                                if (TASK_ARG(task) == param)
                    884:                                        flg = 1;
1.1       misho     885:                                break;
1.8       misho     886:                        case CRITERIA_FD:
                    887:                                if (TASK_FD(task) == (intptr_t) param)
                    888:                                        flg = 1;
1.1       misho     889:                                break;
1.11      misho     890:                        case CRITERIA_ID:
1.8       misho     891:                        case CRITERIA_VAL:
                    892:                                if (TASK_VAL(task) == (u_long) param)
                    893:                                        flg = 1;
1.1       misho     894:                                break;
1.8       misho     895:                        case CRITERIA_TS:
                    896:                                if (!sched_timespeccmp(&TASK_TS(task), (struct timespec*) param, -))
                    897:                                        flg = 1;
1.1       misho     898:                                break;
1.10      misho     899:                        case CRITERIA_DATA:
                    900:                                if (TASK_DATA(task) == param)
                    901:                                        flg = 1;
                    902:                                break;
1.23      misho     903:                        case CRITERIA_DATLEN:
                    904:                                if (TASK_DATLEN(task) == (size_t) param)
                    905:                                        flg = 1;
                    906:                                break;
1.8       misho     907:                        default:
                    908:                                sched_SetErr(EINVAL, "Invalid parameter criteria %d", criteria);
                    909:                                flg = -1;
                    910:                }
1.10      misho     911:                if (flg < 0)            /* error */
1.8       misho     912:                        break;
                    913:                /* cancel choosen task */
                    914:                if (flg > 0) {
                    915:                        if (TASK_ROOT(task)->root_hooks.hook_exec.cancel)
                    916:                                if (TASK_ROOT(task)->root_hooks.hook_exec.cancel(task, NULL)) {
                    917:                                        flg = -1;
                    918:                                        break;
                    919:                                }
                    920:                        /* custom hook */
                    921:                        if (hook)
                    922:                                if (hook(task, NULL)) {
                    923:                                        flg = -3;
                    924:                                        break;
                    925:                                }
                    926: 
                    927:                        TAILQ_REMOVE(queue, task, task_node);
                    928:                        if (TASK_TYPE(task) != taskUNUSE)
1.15      misho     929:                                sched_unuseTask(task);
1.8       misho     930: 
                    931:                        flg ^= flg;     /* ok */
1.1       misho     932:                }
1.8       misho     933:        }
1.5       misho     934: #ifdef HAVE_LIBPTHREAD
                    935:        pthread_mutex_unlock(&root->root_mtx[type]);
                    936: #endif
1.8       misho     937:        return flg;
1.1       misho     938: }
                    939: 
                    940: /*
                    941:  * schedRun() - Scheduler *run loop*
1.6       misho     942:  *
1.1       misho     943:  * @root = root task
1.2       misho     944:  * @killState = kill condition variable, if !=0 stop scheduler loop
1.1       misho     945:  * return: -1 error or 0 ok
                    946:  */
                    947: int
1.7       misho     948: schedRun(sched_root_task_t *root, volatile intptr_t * __restrict killState)
1.1       misho     949: {
                    950:        sched_task_t *task;
                    951: 
                    952:        if (!root)
                    953:                return -1;
                    954: 
                    955:        if (root->root_hooks.hook_exec.run)
                    956:                if (root->root_hooks.hook_exec.run(root, NULL))
                    957:                        return -1;
1.7       misho     958: 
                    959:        if (killState) {
                    960:                if (root->root_hooks.hook_exec.condition)
                    961:                        /* condition scheduler loop */
                    962:                        while (root && root->root_hooks.hook_exec.fetch && 
                    963:                                        root->root_hooks.hook_exec.condition && 
                    964:                                        root->root_hooks.hook_exec.condition(root, (void*) killState)) {
                    965:                                if ((task = root->root_hooks.hook_exec.fetch(root, NULL)))
1.12      misho     966:                                        root->root_ret = schedCall(task);
1.7       misho     967:                        }
                    968:                else
                    969:                        /* trigger scheduler loop */
                    970:                        while (!*killState && root && root->root_hooks.hook_exec.fetch) {
                    971:                                if ((task = root->root_hooks.hook_exec.fetch(root, NULL)))
1.12      misho     972:                                        root->root_ret = schedCall(task);
1.7       misho     973:                        }
                    974:        } else
                    975:                /* infinite scheduler loop */
                    976:                while (root && root->root_hooks.hook_exec.fetch)
                    977:                        if ((task = root->root_hooks.hook_exec.fetch(root, NULL)))
1.12      misho     978:                                root->root_ret = schedCall(task);
1.1       misho     979: 
                    980:        return 0;
                    981: }
1.5       misho     982: 
                    983: /*
                    984:  * schedPolling() - Polling timeout period if no timer task is present
1.6       misho     985:  *
1.5       misho     986:  * @root = root task
                    987:  * @ts = timeout polling period, if ==NULL INFINIT timeout
                    988:  * @tsold = old timeout polling if !=NULL
                    989:  * return: -1 error or 0 ok
                    990:  */
1.18      misho     991: int
1.5       misho     992: schedPolling(sched_root_task_t * __restrict root, struct timespec * __restrict ts, 
                    993:                struct timespec * __restrict tsold)
                    994: {
                    995:        if (!root)
                    996:                return -1;
                    997: 
                    998:        if (tsold)
                    999:                *tsold = root->root_poll;
                   1000: 
                   1001:        if (!ts)
                   1002:                sched_timespecinf(&root->root_poll);
                   1003:        else
                   1004:                root->root_poll = *ts;
                   1005: 
                   1006:        return 0;
                   1007: }
1.6       misho    1008: 
                   1009: /*
                   1010:  * schedTermCondition() - Activate hook for scheduler condition kill
                   1011:  *
                   1012:  * @root = root task
                   1013:  * @condValue = condition value, kill schedRun() if condValue == killState
1.13      misho    1014:  * return: -1 error or 0 ok
1.6       misho    1015:  */
1.18      misho    1016: int
1.6       misho    1017: schedTermCondition(sched_root_task_t * __restrict root, intptr_t condValue)
                   1018: {
                   1019:        if (!root)
                   1020:                return -1;
                   1021: 
                   1022:        root->root_cond = condValue;
                   1023:        root->root_hooks.hook_exec.condition = sched_hook_condition;
                   1024:        return 0;
                   1025: }
1.11      misho    1026: 
                   1027: /*
                   1028:  * schedResumeby() - Resume suspended task
                   1029:  *
                   1030:  * @root = root task
                   1031:  * @criteria = find task by criteria 
1.23      misho    1032:  *     [CRITERIA_ANY|CRITERIA_ID|CRITERIA_VAL|CRITERIA_DATA]
1.20      misho    1033:  * @param = search parameter (sched_task_t *task| unsigned long id)
1.11      misho    1034:  * return: -1 error or 0 resumed ok
                   1035:  */
                   1036: int
                   1037: schedResumeby(sched_root_task_t * __restrict root, u_char criteria, void *param)
                   1038: {
                   1039:        sched_task_t *task, *tmp;
                   1040:        register int flg = 0;
                   1041: 
                   1042:        if (!root)
                   1043:                return -1;
                   1044: 
                   1045: #ifdef HAVE_LIBPTHREAD
                   1046:        pthread_mutex_lock(&root->root_mtx[taskSUSPEND]);
                   1047: #endif
                   1048:        TAILQ_FOREACH_SAFE(task, &root->root_suspend, task_node, tmp) {
                   1049:                flg ^= flg;
                   1050:                switch (criteria) {
                   1051:                        case CRITERIA_ANY:
                   1052:                                flg = 1;
                   1053:                                break;
                   1054:                        case CRITERIA_ID:
1.23      misho    1055:                        case CRITERIA_VAL:
1.11      misho    1056:                                if (TASK_VAL(task) == (u_long) param)
                   1057:                                        flg = 1;
                   1058:                                break;
                   1059:                        case CRITERIA_DATA:
                   1060:                                if (TASK_ID(task) == (sched_task_t*) param)
                   1061:                                        flg = 1;
                   1062:                                break;
                   1063:                        default:
                   1064:                                sched_SetErr(EINVAL, "Invalid parameter criteria %d", criteria);
                   1065:                                flg = -1;
                   1066:                }
                   1067:                if (flg < 0)
                   1068:                        break;
                   1069:                /* resume choosen task */
                   1070:                if (flg > 0) {
                   1071:                        if (root->root_hooks.hook_exec.resume)
                   1072:                                if (root->root_hooks.hook_exec.resume(task, NULL)) {
                   1073:                                        flg = -1;
                   1074:                                        break;
                   1075:                                }
                   1076: 
                   1077:                        TAILQ_REMOVE(&root->root_suspend, task, task_node);
                   1078: 
                   1079:                        task->task_type = taskREADY;
                   1080: #ifdef HAVE_LIBPTHREAD
                   1081:                        pthread_mutex_lock(&root->root_mtx[taskREADY]);
                   1082: #endif
                   1083:                        TAILQ_INSERT_TAIL(&root->root_ready, task, task_node);
                   1084: #ifdef HAVE_LIBPTHREAD
                   1085:                        pthread_mutex_unlock(&root->root_mtx[taskREADY]);
                   1086: #endif
                   1087: 
                   1088:                        flg ^= flg;     /* ok */
                   1089:                }
                   1090:        }
                   1091: #ifdef HAVE_LIBPTHREAD
                   1092:        pthread_mutex_unlock(&root->root_mtx[taskSUSPEND]);
                   1093: #endif
                   1094: 
                   1095:        return flg;
                   1096: }

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