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