Annotation of coherent/d/PS2_KERNEL/coh.386/timeout.c, revision 1.1

1.1     ! root        1: /* $Header: /y/coh.386/RCS/timeout.c,v 1.3 92/07/16 16:33:38 hal Exp $ */
        !             2: /* (lgl-
        !             3:  *     The information contained herein is a trade secret of Mark Williams
        !             4:  *     Company, and  is confidential information.  It is provided  under a
        !             5:  *     license agreement,  and may be  copied or disclosed  only under the
        !             6:  *     terms of  that agreement.  Any  reproduction or disclosure  of this
        !             7:  *     material without the express written authorization of Mark Williams
        !             8:  *     Company or persuant to the license agreement is unlawful.
        !             9:  *
        !            10:  *     COHERENT Version 2.3.37
        !            11:  *     Copyright (c) 1982, 1983, 1984.
        !            12:  *     An unpublished work by Mark Williams Company, Chicago.
        !            13:  *     All rights reserved.
        !            14:  -lgl) */
        !            15: /*
        !            16:  * Coherent.
        !            17:  * Timeout management.
        !            18:  *
        !            19:  * $Log:       timeout.c,v $
        !            20:  * Revision 1.3  92/07/16  16:33:38  hal
        !            21:  * Kernel #58
        !            22:  * 
        !            23:  * Revision 1.2  92/01/06  12:01:05  hal
        !            24:  * Compile with cc.mwc.
        !            25:  * 
        !            26:  * Revision 1.2        89/08/01  13:56:42      src
        !            27:  * Bug:        #include <timeout.h> not accurate; timeout.h now in /usr/include/sys.
        !            28:  * Fix:        #include <sys/timeout.h> now used. (ABC)
        !            29:  * 
        !            30:  * Revision 1.1        88/03/24  08:14:38      src
        !            31:  * Initial revision
        !            32:  * 
        !            33:  * 87/07/23    Allan Cornish           /usr/src/sys/coh/timeout.c
        !            34:  * Timeout2 function now cancels timer if delay value is 0.
        !            35:  *
        !            36:  * 87/07/08    Allan Cornish           /usr/src/sys/coh/timeout.c
        !            37:  * Timeout2 function added to support long timeouts.
        !            38:  *
        !            39:  * 87/07/07    Allan Cornish           /usr/src/sys/coh/timeout.c
        !            40:  * Support for multiple timing queues ported from RTX.
        !            41:  *
        !            42:  * 86/11/24    Allan Cornish           /usr/src/sys/coh/timeout.c
        !            43:  * Added support for new t_last field in tim struct.
        !            44:  */
        !            45: #include <sys/coherent.h>
        !            46: #include <sys/timeout.h>
        !            47: #include <sys/fun.h>
        !            48: 
        !            49: /*
        !            50:  * Given a pointer to a timeout structure, `tp', call the function `f'
        !            51:  * with integer argument `a' in `n' ticks of the clock. The list is
        !            52:  * searched to see if the specified timeout structure is already in a
        !            53:  * list, and it is removed if already there.
        !            54:  */
        !            55: void
        !            56: timeout(tp, n, f, a)
        !            57: register TIM *tp;
        !            58: unsigned n;
        !            59: int (*f)();
        !            60: char *a;
        !            61: {
        !            62:        register TIM ** qp;
        !            63:        int s;
        !            64: 
        !            65:        /*
        !            66:         * Already on a timing queue.
        !            67:         */
        !            68:        s = sphi();
        !            69:        if ( qp = tp->t_last ) {
        !            70:                tp->t_last = NULL;
        !            71:                if ( *qp = tp->t_next )
        !            72:                        tp->t_next->t_last = qp;
        !            73:        }
        !            74:        spl( s );
        !            75: 
        !            76:        if ( f == NULL )
        !            77:                return;
        !            78: 
        !            79:        /*
        !            80:         * Calculate clock tick at which timeout is to occur.
        !            81:         * Record function and argument to be invoked upon timeout.
        !            82:         */
        !            83:        tp->t_lbolt = lbolt + n;
        !            84:        tp->t_func  = f;
        !            85:        tp->t_farg  = a;
        !            86: 
        !            87:        /*
        !            88:         * Identify timeout queue.
        !            89:         */
        !            90:        qp = &timq[ tp->t_lbolt % nel(timq) ];
        !            91: 
        !            92:        /*
        !            93:         * Insert at head of timeout queue.
        !            94:         */
        !            95:        s = sphi();
        !            96:        if ( tp->t_next = *qp )
        !            97:                tp->t_next->t_last = tp;
        !            98:        tp->t_last = qp;
        !            99:        *qp = tp;
        !           100:        spl(s);
        !           101: }
        !           102: 
        !           103: void
        !           104: timeout2(tp, n, f, a)
        !           105: register TIM *tp;
        !           106: long n;
        !           107: int (*f)();
        !           108: char *a;
        !           109: {
        !           110:        register TIM ** qp;
        !           111:        int s;
        !           112: 
        !           113:        /*
        !           114:         * Already on a timing queue.
        !           115:         */
        !           116:        s = sphi();
        !           117:        if ( qp = tp->t_last ) {
        !           118:                tp->t_last = NULL;
        !           119:                if ( *qp = tp->t_next )
        !           120:                        tp->t_next->t_last = qp;
        !           121:        }
        !           122:        spl( s );
        !           123: 
        !           124:        /*
        !           125:         * Do not schedule new timer if no function or delay interval.
        !           126:         */
        !           127:        if ( (f == NULL) || (n == 0) )
        !           128:                return;
        !           129: 
        !           130:        /*
        !           131:         * Calculate clock tick at which timeout is to occur.
        !           132:         * Record function and argument to be invoked upon timeout.
        !           133:         */
        !           134:        tp->t_lbolt = lbolt + n;
        !           135:        tp->t_func  = f;
        !           136:        tp->t_farg  = a;
        !           137: 
        !           138:        /*
        !           139:         * Identify timeout queue.
        !           140:         */
        !           141:        qp = &timq[ tp->t_lbolt % nel(timq) ];
        !           142: 
        !           143:        /*
        !           144:         * Insert at head of timeout queue.
        !           145:         */
        !           146:        s = sphi();
        !           147:        if ( tp->t_next = *qp )
        !           148:                tp->t_next->t_last = tp;
        !           149:        tp->t_last = qp;
        !           150:        *qp = tp;
        !           151:        spl(s);
        !           152: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.