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