|
|
1.1 ! root 1: /* $Header: /src386/kernel/coh.386/RCS/timeout.c,v 1.3 93/04/16 06:50:21 bin Exp Locker: bin $ */ ! 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 93/04/16 06:50:21 bin ! 21: * Hal: kernel 76 update ! 22: * ! 23: * Revision 1.4 93/04/14 10:08:12 root ! 24: * r75 ! 25: * ! 26: * Revision 1.3 92/07/16 16:33:38 hal ! 27: * Kernel #58 ! 28: * ! 29: * Revision 1.2 92/01/06 12:01:05 hal ! 30: * Compile with cc.mwc. ! 31: * ! 32: * Revision 1.2 89/08/01 13:56:42 src ! 33: * Bug: #include <timeout.h> not accurate; timeout.h now in /usr/include/sys. ! 34: * Fix: #include <sys/timeout.h> now used. (ABC) ! 35: * ! 36: * Revision 1.1 88/03/24 08:14:38 src ! 37: * Initial revision ! 38: * ! 39: * 87/07/23 Allan Cornish /usr/src/sys/coh/timeout.c ! 40: * Timeout2 function now cancels timer if delay value is 0. ! 41: * ! 42: * 87/07/08 Allan Cornish /usr/src/sys/coh/timeout.c ! 43: * Timeout2 function added to support long timeouts. ! 44: * ! 45: * 87/07/07 Allan Cornish /usr/src/sys/coh/timeout.c ! 46: * Support for multiple timing queues ported from RTX. ! 47: * ! 48: * 86/11/24 Allan Cornish /usr/src/sys/coh/timeout.c ! 49: * Added support for new t_last field in tim struct. ! 50: */ ! 51: #include <sys/coherent.h> ! 52: #include <sys/timeout.h> ! 53: #include <sys/fun.h> ! 54: ! 55: /* ! 56: * Given a pointer to a timeout structure, `tp', call the function `f' ! 57: * with integer argument `a' in `n' ticks of the clock. The list is ! 58: * searched to see if the specified timeout structure is already in a ! 59: * list, and it is removed if already there. ! 60: */ ! 61: void ! 62: timeout(tp, n, f, a) ! 63: register TIM *tp; ! 64: unsigned n; ! 65: int (*f)(); ! 66: char *a; ! 67: { ! 68: register TIM ** qp; ! 69: int s; ! 70: ! 71: /* ! 72: * Already on a timing queue. ! 73: */ ! 74: s = sphi(); ! 75: if ( qp = tp->t_last ) { ! 76: tp->t_last = NULL; ! 77: if ( *qp = tp->t_next ) ! 78: tp->t_next->t_last = qp; ! 79: } ! 80: spl( s ); ! 81: ! 82: if ( (tp->t_func = f) == NULL ) ! 83: return; ! 84: ! 85: /* ! 86: * Calculate clock tick at which timeout is to occur. ! 87: * Record function and argument to be invoked upon timeout. ! 88: */ ! 89: tp->t_lbolt = lbolt + n; ! 90: tp->t_farg = a; ! 91: ! 92: /* ! 93: * Identify timeout queue. ! 94: */ ! 95: qp = &timq[ tp->t_lbolt % nel(timq) ]; ! 96: ! 97: /* ! 98: * Insert at head of timeout queue. ! 99: */ ! 100: s = sphi(); ! 101: if ( tp->t_next = *qp ) ! 102: tp->t_next->t_last = tp; ! 103: tp->t_last = qp; ! 104: *qp = tp; ! 105: spl(s); ! 106: } ! 107: ! 108: void ! 109: timeout2(tp, n, f, a) ! 110: register TIM *tp; ! 111: long n; ! 112: int (*f)(); ! 113: char *a; ! 114: { ! 115: register TIM ** qp; ! 116: int s; ! 117: ! 118: /* ! 119: * Already on a timing queue. ! 120: */ ! 121: s = sphi(); ! 122: if ( qp = tp->t_last ) { ! 123: tp->t_last = NULL; ! 124: if ( *qp = tp->t_next ) ! 125: tp->t_next->t_last = qp; ! 126: } ! 127: spl( s ); ! 128: ! 129: /* ! 130: * Do not schedule new timer if no function or delay interval. ! 131: */ ! 132: if ( (f == NULL) || (n == 0) ) ! 133: return; ! 134: ! 135: /* ! 136: * Calculate clock tick at which timeout is to occur. ! 137: * Record function and argument to be invoked upon timeout. ! 138: */ ! 139: tp->t_lbolt = lbolt + n; ! 140: tp->t_func = f; ! 141: tp->t_farg = a; ! 142: ! 143: /* ! 144: * Identify timeout queue. ! 145: */ ! 146: qp = &timq[ tp->t_lbolt % nel(timq) ]; ! 147: ! 148: /* ! 149: * Insert at head of timeout queue. ! 150: */ ! 151: s = sphi(); ! 152: if ( tp->t_next = *qp ) ! 153: tp->t_next->t_last = tp; ! 154: tp->t_last = qp; ! 155: *qp = tp; ! 156: spl(s); ! 157: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.