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

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.9     ! misho       6: * $Id: aitsched.c,v 1.8.2.1 2012/05/30 08:07:45 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: #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
                     59: inline int
                     60: sched_GetErrno()
                     61: {
                     62:        return sched_Errno;
                     63: }
                     64: 
                     65: // sched_GetError() Get error text of last operation
                     66: inline const char *
                     67: sched_GetError()
                     68: {
                     69:        return sched_Error;
                     70: }
                     71: 
                     72: // sched_SetErr() Set error to variables for internal use!!!
                     73: inline void
                     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: 
                     85: /* Init and prepare scheduler functions */
                     86: 
                     87: /*
1.2       misho      88:  * schedRegisterHooks() - Register IO handles and bind tasks to it
1.6       misho      89:  *
1.2       misho      90:  * @root = root task
                     91:  * return: -1 error or 0 ok
                     92:  */
                     93: int
                     94: schedRegisterHooks(sched_root_task_t * __restrict root)
                     95: {
1.7       misho      96:        assert(root);
1.2       misho      97: 
                     98:        if (root->root_hooks.hook_root.fini)
                     99:                root->root_hooks.hook_root.fini(root, NULL);
                    100:        memset(&root->root_hooks, 0, sizeof root->root_hooks);
                    101: 
                    102:        root->root_hooks.hook_add.read = sched_hook_read;
                    103:        root->root_hooks.hook_add.write = sched_hook_write;
1.9     ! misho     104:        root->root_hooks.hook_add.alarm = sched_hook_alarm;
1.2       misho     105: 
                    106:        root->root_hooks.hook_exec.cancel = sched_hook_cancel;
                    107:        root->root_hooks.hook_exec.fetch = sched_hook_fetch;
1.3       misho     108:        root->root_hooks.hook_exec.exception = sched_hook_exception;
1.2       misho     109: 
                    110:        root->root_hooks.hook_root.init = sched_hook_init;
                    111:        root->root_hooks.hook_root.fini = sched_hook_fini;
                    112:        return 0;
                    113: }
                    114: 
                    115: /*
1.1       misho     116:  * schedInit() - Init scheduler
1.6       misho     117:  *
1.1       misho     118:  * @data = optional data if !=NULL
                    119:  * @datlen = data len if data is set
                    120:  * return: allocated root task if ok or NULL error
                    121:  */
                    122: sched_root_task_t *
                    123: schedInit(void ** __restrict data, size_t datlen)
                    124: {
                    125:        sched_root_task_t *root = NULL;
                    126:        int (*func)(sched_root_task_t *);
1.5       misho     127: #ifdef HAVE_LIBPTHREAD
                    128:        register int i;
                    129: #endif
1.1       misho     130: 
                    131:        root = malloc(sizeof(sched_root_task_t));
1.2       misho     132:        if (!root) {
                    133:                LOGERR;
                    134:        } else {
1.1       misho     135:                memset(root, 0, sizeof(sched_root_task_t));
1.5       misho     136: 
                    137:                /* INFINIT polling period by default */
                    138:                sched_timespecinf(&root->root_poll);
                    139: 
                    140: #ifdef HAVE_LIBPTHREAD
                    141:                for (i = 0; i < taskMAX; i++)
                    142:                        if (pthread_mutex_init(&root->root_mtx[i], NULL)) {
                    143:                                LOGERR;
                    144:                                while (i)
                    145:                                        pthread_mutex_destroy(&root->root_mtx[--i]);
                    146:                                free(root);
                    147:                                return NULL;
                    148:                        }
                    149: 
                    150:                for (i = 0; i < taskMAX; i++)
                    151:                        pthread_mutex_lock(&root->root_mtx[i]);
                    152: #endif
                    153: 
1.2       misho     154:                TAILQ_INIT(&root->root_read);
                    155:                TAILQ_INIT(&root->root_write);
1.9     ! misho     156:                TAILQ_INIT(&root->root_alarm);
1.2       misho     157:                TAILQ_INIT(&root->root_timer);
                    158:                TAILQ_INIT(&root->root_event);
                    159:                TAILQ_INIT(&root->root_eventlo);
                    160:                TAILQ_INIT(&root->root_ready);
                    161:                TAILQ_INIT(&root->root_unuse);
1.1       misho     162: 
1.5       misho     163: #ifdef HAVE_LIBPTHREAD
                    164:                for (i = 0; i < taskMAX; i++)
                    165:                        pthread_mutex_unlock(&root->root_mtx[i]);
                    166: #endif
                    167: 
1.1       misho     168:                if (data && *data) {
                    169:                        if (datlen) {
                    170:                                root->root_data.iov_base = *data;
                    171:                                root->root_data.iov_len = datlen;
1.3       misho     172:                        } else { /* if datlen == 0, switch to callbacks init mode */
                    173:                                 /* little hack :) for correct initialization of scheduler */
1.2       misho     174:                                func = (int(*)(sched_root_task_t*)) data;
1.1       misho     175:                                func(root);
                    176:                        }
                    177:                }
1.2       misho     178: 
                    179:                if (root->root_hooks.hook_root.init)
                    180:                        root->root_hooks.hook_root.init(root, NULL);
1.1       misho     181:        }
                    182: 
                    183:        return root;
                    184: }
                    185: 
                    186: /*
                    187:  * schedEnd() - End scheduler & free all resources
1.6       misho     188:  *
1.1       misho     189:  * @root = root task
                    190:  * return: -1 error or 0 ok
                    191:  */
                    192: int
1.2       misho     193: schedEnd(sched_root_task_t ** __restrict root)
1.1       misho     194: {
1.7       misho     195:        sched_task_t *task, *tmp;
1.5       misho     196: #ifdef HAVE_LIBPTHREAD
                    197:        register int i;
                    198: #endif
1.1       misho     199: 
1.2       misho     200:        if (!root || !*root)
1.1       misho     201:                return -1;
                    202: 
1.7       misho     203:        TAILQ_FOREACH_SAFE(task, &(*root)->root_read, task_node, tmp) {
1.1       misho     204:                schedCancel(task);
                    205:        }
1.7       misho     206:        TAILQ_FOREACH_SAFE(task, &(*root)->root_write, task_node, tmp) {
1.1       misho     207:                schedCancel(task);
                    208:        }
1.9     ! misho     209:        TAILQ_FOREACH_SAFE(task, &(*root)->root_alarm, task_node, tmp) {
        !           210:                schedCancel(task);
        !           211:        }
1.7       misho     212:        TAILQ_FOREACH_SAFE(task, &(*root)->root_timer, task_node, tmp) {
1.1       misho     213:                schedCancel(task);
                    214:        }
1.7       misho     215:        TAILQ_FOREACH_SAFE(task, &(*root)->root_event, task_node, tmp) {
1.1       misho     216:                schedCancel(task);
                    217:        }
1.7       misho     218:        TAILQ_FOREACH_SAFE(task, &(*root)->root_eventlo, task_node, tmp) {
1.5       misho     219:                schedCancel(task);
                    220:        }
1.7       misho     221:        TAILQ_FOREACH_SAFE(task, &(*root)->root_ready, task_node, tmp) {
1.1       misho     222:                schedCancel(task);
                    223:        }
                    224: 
1.5       misho     225: #ifdef HAVE_LIBPTHREAD
                    226:        pthread_mutex_lock(&(*root)->root_mtx[taskUNUSE]);
                    227: #endif
1.2       misho     228:        while ((task = TAILQ_FIRST(&(*root)->root_unuse))) {
                    229:                TAILQ_REMOVE(&(*root)->root_unuse, task, task_node);
1.1       misho     230:                free(task);
                    231:        }
1.5       misho     232: #ifdef HAVE_LIBPTHREAD
                    233:        pthread_mutex_unlock(&(*root)->root_mtx[taskUNUSE]);
                    234: #endif
1.1       misho     235: 
1.2       misho     236:        if ((*root)->root_hooks.hook_root.fini)
                    237:                (*root)->root_hooks.hook_root.fini(*root, NULL);
1.1       misho     238: 
1.5       misho     239: #ifdef HAVE_LIBPTHREAD
                    240:        for (i = 0; i < taskMAX; i++)
                    241:                pthread_mutex_destroy(&(*root)->root_mtx[i]);
                    242: #endif
                    243: 
1.2       misho     244:        free(*root);
                    245:        *root = NULL;
1.1       misho     246:        return 0;
                    247: }
                    248: 
                    249: /*
                    250:  * schedCall() - Call task execution function
1.6       misho     251:  *
1.1       misho     252:  * @task = current task
                    253:  * return: !=NULL error or =NULL ok
                    254:  */
                    255: inline void *
                    256: schedCall(sched_task_t * __restrict task)
                    257: {
1.4       misho     258:        void *ptr = (void*) -1;
                    259: 
1.1       misho     260:        if (!task)
1.4       misho     261:                return ptr;
                    262: 
                    263:        if (!TASK_ISLOCKED(task))
                    264:                TASK_LOCK(task);
1.1       misho     265: 
                    266:        task->task_id++;
1.4       misho     267:        ptr = task->task_func(task);
                    268: 
                    269:        TASK_UNLOCK(task);
                    270:        return ptr;
1.1       misho     271: }
                    272: 
                    273: /*
                    274:  * schedFetch() - Fetch ready task
1.6       misho     275:  *
1.1       misho     276:  * @root = root task
                    277:  * return: =NULL error or !=NULL ready task
                    278:  */
                    279: inline void *
                    280: schedFetch(sched_root_task_t * __restrict root)
                    281: {
                    282:        void *ptr;
                    283: 
                    284:        if (!root)
                    285:                return NULL;
                    286: 
                    287:        if (root->root_hooks.hook_exec.fetch)
                    288:                ptr = root->root_hooks.hook_exec.fetch(root, NULL);
                    289:        else
                    290:                ptr = NULL;
                    291: 
                    292:        return ptr;
                    293: }
                    294: 
                    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
                    302: schedCancel(sched_task_t * __restrict task)
                    303: {
                    304:        sched_queue_t *queue;
                    305: 
1.5       misho     306:        if (!task || !TASK_ROOT(task))
1.1       misho     307:                return -1;
                    308: 
1.5       misho     309:        if (TASK_ROOT(task)->root_hooks.hook_exec.cancel)
                    310:                if (TASK_ROOT(task)->root_hooks.hook_exec.cancel(task, NULL))
1.1       misho     311:                        return -1;
                    312: 
1.5       misho     313:        switch (TASK_TYPE(task)) {
1.1       misho     314:                case taskREAD:
1.5       misho     315:                        queue = &TASK_ROOT(task)->root_read;
1.1       misho     316:                        break;
                    317:                case taskWRITE:
1.5       misho     318:                        queue = &TASK_ROOT(task)->root_write;
1.1       misho     319:                        break;
1.9     ! misho     320:                case taskALARM:
        !           321:                        queue = &TASK_ROOT(task)->root_alarm;
        !           322:                        break;
1.1       misho     323:                case taskTIMER:
1.5       misho     324:                        queue = &TASK_ROOT(task)->root_timer;
1.1       misho     325:                        break;
                    326:                case taskEVENT:
1.5       misho     327:                        queue = &TASK_ROOT(task)->root_event;
                    328:                        break;
                    329:                case taskEVENTLO:
                    330:                        queue = &TASK_ROOT(task)->root_eventlo;
1.1       misho     331:                        break;
                    332:                case taskREADY:
1.5       misho     333:                        queue = &TASK_ROOT(task)->root_ready;
1.1       misho     334:                        break;
                    335:                default:
                    336:                        queue = NULL;
                    337:        }
1.5       misho     338:        if (queue) {
                    339: #ifdef HAVE_LIBPTHREAD
                    340:                pthread_mutex_lock(&TASK_ROOT(task)->root_mtx[TASK_TYPE(task)]);
                    341: #endif
1.1       misho     342:                TAILQ_REMOVE(queue, task, task_node);
1.5       misho     343: #ifdef HAVE_LIBPTHREAD
                    344:                pthread_mutex_unlock(&TASK_ROOT(task)->root_mtx[TASK_TYPE(task)]);
                    345: #endif
                    346:        }
                    347:        if (TASK_TYPE(task) != taskUNUSE)
1.4       misho     348:                _sched_unuseTask(task);
1.1       misho     349: 
                    350:        return 0;
                    351: }
                    352: 
                    353: /*
                    354:  * schedCancelby() - Cancel task from scheduler by criteria
1.6       misho     355:  *
1.1       misho     356:  * @root = root task
1.5       misho     357:  * @type = cancel from queue type, if =taskMAX cancel same task from all queues
1.8       misho     358:  * @criteria = find task by criteria [CRITERIA_CALL|CRITERIA_ARG|CRITERIA_FD|CRITERIA_VAL|CRITERIA_TS]
1.1       misho     359:  * @param = search parameter
                    360:  * @hook = custom cleanup hook function, may be NULL
1.3       misho     361:  * return: -1 error, -2 error in sub-stage cancel execution, -3 error from custom hook or 0 ok
1.1       misho     362:  */
                    363: int
1.5       misho     364: schedCancelby(sched_root_task_t * __restrict root, sched_task_type_t type, 
1.1       misho     365:                u_char criteria, void *param, sched_hook_func_t hook)
                    366: {
1.8       misho     367:        sched_task_t *task, *tmp;
1.5       misho     368:        sched_queue_t *queue;
1.8       misho     369:        register int flg = 0;
1.1       misho     370: 
                    371:        if (!root)
                    372:                return -1;
1.5       misho     373:        if (type == taskMAX) {
                    374:                if (schedCancelby(root, taskREAD, criteria, param, hook))
1.1       misho     375:                        return -2;
1.5       misho     376:                if (schedCancelby(root, taskWRITE, criteria, param, hook))
1.1       misho     377:                        return -2;
1.9     ! misho     378:                if (schedCancelby(root, taskALARM, criteria, param, hook))
        !           379:                        return -2;
1.5       misho     380:                if (schedCancelby(root, taskTIMER, criteria, param, hook))
1.1       misho     381:                        return -2;
1.5       misho     382:                if (schedCancelby(root, taskEVENT, criteria, param, hook))
1.1       misho     383:                        return -2;
1.5       misho     384:                if (schedCancelby(root, taskEVENTLO, criteria, param, hook))
1.1       misho     385:                        return -2;
1.5       misho     386:                if (schedCancelby(root, taskREADY, criteria, param, hook))
1.1       misho     387:                        return -2;
                    388:                return 0;
                    389:        }
1.5       misho     390:        switch (type) {
                    391:                case taskREAD:
                    392:                        queue = &root->root_read;
                    393:                        break;
                    394:                case taskWRITE:
                    395:                        queue = &root->root_write;
                    396:                        break;
1.9     ! misho     397:                case taskALARM:
        !           398:                        queue = &root->root_alarm;
        !           399:                        break;
1.5       misho     400:                case taskTIMER:
                    401:                        queue = &root->root_timer;
                    402:                        break;
                    403:                case taskEVENT:
                    404:                        queue = &root->root_event;
                    405:                        break;
                    406:                case taskEVENTLO:
                    407:                        queue = &root->root_eventlo;
                    408:                        break;
                    409:                case taskREADY:
                    410:                        queue = &root->root_ready;
                    411:                        break;
                    412:                default:
                    413:                        return 0;
                    414:        }
1.1       misho     415: 
1.5       misho     416: #ifdef HAVE_LIBPTHREAD
                    417:        pthread_mutex_lock(&root->root_mtx[type]);
                    418: #endif
1.8       misho     419:        TAILQ_FOREACH_SAFE(task, queue, task_node, tmp) {
                    420:                flg ^= flg;
                    421:                switch (criteria) {
                    422:                        case CRITERIA_CALL:
                    423:                                if (TASK_FUNC(task) == (sched_task_func_t) param)
                    424:                                        flg = 1;
1.1       misho     425:                                break;
1.8       misho     426:                        case CRITERIA_ARG:
                    427:                                if (TASK_ARG(task) == param)
                    428:                                        flg = 1;
1.1       misho     429:                                break;
1.8       misho     430:                        case CRITERIA_FD:
                    431:                                if (TASK_FD(task) == (intptr_t) param)
                    432:                                        flg = 1;
1.1       misho     433:                                break;
1.8       misho     434:                        case CRITERIA_VAL:
                    435:                                if (TASK_VAL(task) == (u_long) param)
                    436:                                        flg = 1;
1.1       misho     437:                                break;
1.8       misho     438:                        case CRITERIA_TS:
                    439:                                if (!sched_timespeccmp(&TASK_TS(task), (struct timespec*) param, -))
                    440:                                        flg = 1;
1.1       misho     441:                                break;
1.8       misho     442:                        default:
                    443:                                sched_SetErr(EINVAL, "Invalid parameter criteria %d", criteria);
                    444:                                flg = -1;
                    445:                }
                    446:                if (flg < 0)
                    447:                        break;
                    448:                /* cancel choosen task */
                    449:                if (flg > 0) {
                    450:                        if (TASK_ROOT(task)->root_hooks.hook_exec.cancel)
                    451:                                if (TASK_ROOT(task)->root_hooks.hook_exec.cancel(task, NULL)) {
                    452:                                        flg = -1;
                    453:                                        break;
                    454:                                }
                    455:                        /* custom hook */
                    456:                        if (hook)
                    457:                                if (hook(task, NULL)) {
                    458:                                        flg = -3;
                    459:                                        break;
                    460:                                }
                    461: 
                    462:                        TAILQ_REMOVE(queue, task, task_node);
                    463:                        if (TASK_TYPE(task) != taskUNUSE)
                    464:                                _sched_unuseTask(task);
                    465: 
                    466:                        flg ^= flg;     /* ok */
1.1       misho     467:                }
1.8       misho     468:        }
1.5       misho     469: #ifdef HAVE_LIBPTHREAD
                    470:        pthread_mutex_unlock(&root->root_mtx[type]);
                    471: #endif
1.8       misho     472:        return flg;
1.1       misho     473: }
                    474: 
                    475: /*
                    476:  * schedRun() - Scheduler *run loop*
1.6       misho     477:  *
1.1       misho     478:  * @root = root task
1.2       misho     479:  * @killState = kill condition variable, if !=0 stop scheduler loop
1.1       misho     480:  * return: -1 error or 0 ok
                    481:  */
                    482: int
1.7       misho     483: schedRun(sched_root_task_t *root, volatile intptr_t * __restrict killState)
1.1       misho     484: {
                    485:        sched_task_t *task;
                    486: 
                    487:        if (!root)
                    488:                return -1;
                    489: 
                    490:        if (root->root_hooks.hook_exec.run)
                    491:                if (root->root_hooks.hook_exec.run(root, NULL))
                    492:                        return -1;
1.7       misho     493: 
                    494:        if (killState) {
                    495:                if (root->root_hooks.hook_exec.condition)
                    496:                        /* condition scheduler loop */
                    497:                        while (root && root->root_hooks.hook_exec.fetch && 
                    498:                                        root->root_hooks.hook_exec.condition && 
                    499:                                        root->root_hooks.hook_exec.condition(root, (void*) killState)) {
                    500:                                if ((task = root->root_hooks.hook_exec.fetch(root, NULL)))
                    501:                                        schedCall(task);
                    502:                        }
                    503:                else
                    504:                        /* trigger scheduler loop */
                    505:                        while (!*killState && root && root->root_hooks.hook_exec.fetch) {
                    506:                                if ((task = root->root_hooks.hook_exec.fetch(root, NULL)))
                    507:                                        schedCall(task);
                    508:                        }
                    509:        } else
                    510:                /* infinite scheduler loop */
                    511:                while (root && root->root_hooks.hook_exec.fetch)
                    512:                        if ((task = root->root_hooks.hook_exec.fetch(root, NULL)))
1.2       misho     513:                                schedCall(task);
1.1       misho     514: 
                    515:        return 0;
                    516: }
1.5       misho     517: 
                    518: /*
                    519:  * schedPolling() - Polling timeout period if no timer task is present
1.6       misho     520:  *
1.5       misho     521:  * @root = root task
                    522:  * @ts = timeout polling period, if ==NULL INFINIT timeout
                    523:  * @tsold = old timeout polling if !=NULL
                    524:  * return: -1 error or 0 ok
                    525:  */
                    526: inline int
                    527: schedPolling(sched_root_task_t * __restrict root, struct timespec * __restrict ts, 
                    528:                struct timespec * __restrict tsold)
                    529: {
                    530:        if (!root)
                    531:                return -1;
                    532: 
                    533:        if (tsold)
                    534:                *tsold = root->root_poll;
                    535: 
                    536:        if (!ts)
                    537:                sched_timespecinf(&root->root_poll);
                    538:        else
                    539:                root->root_poll = *ts;
                    540: 
                    541:        return 0;
                    542: }
1.6       misho     543: 
                    544: /*
                    545:  * schedTermCondition() - Activate hook for scheduler condition kill
                    546:  *
                    547:  * @root = root task
                    548:  * @condValue = condition value, kill schedRun() if condValue == killState
                    549:  * return: -1 error ok 0 ok
                    550:  */
                    551: inline int
                    552: schedTermCondition(sched_root_task_t * __restrict root, intptr_t condValue)
                    553: {
                    554:        if (!root)
                    555:                return -1;
                    556: 
                    557:        root->root_cond = condValue;
                    558:        root->root_hooks.hook_exec.condition = sched_hook_condition;
                    559:        return 0;
                    560: }

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