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