FreeBSD/Linux Kernel Cross Reference
sys/kern/time_out.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: time_out.h,v $
29 * Revision 2.5 91/07/31 17:51:15 dbg
30 * Fix race condition.
31 * [91/07/30 17:08:00 dbg]
32 *
33 * Revision 2.4 91/05/14 16:49:27 mrt
34 * Correcting copyright
35 *
36 * Revision 2.3 91/02/05 17:30:51 mrt
37 * Changed to new Mach copyright
38 * [91/02/01 16:20:31 mrt]
39 *
40 * Revision 2.2 90/11/05 14:32:00 rpd
41 * Changed untimeout to return boolean.
42 * [90/10/29 rpd]
43 *
44 * Revision 2.1 89/08/03 15:57:24 rwd
45 * Created.
46 *
47 * 14-Jun-88 David Golub (dbg) at Carnegie-Mellon University
48 * Created.
49 *
50 */
51
52 #ifndef _KERN_TIME_OUT_H_
53 #define _KERN_TIME_OUT_H_
54
55 /*
56 * Mach time-out and time-of-day facility.
57 */
58
59 #include <mach/boolean.h>
60 #include <kern/lock.h>
61 #include <kern/queue.h>
62 #include <kern/zalloc.h>
63
64 /*
65 * Timers in kernel:
66 */
67 extern unsigned long elapsed_ticks; /* number of ticks elapsed since bootup */
68 extern int hz; /* number of ticks per second */
69 extern int tick; /* number of usec per tick */
70
71 /*
72 * Time-out element.
73 */
74 struct timer_elt {
75 queue_chain_t chain; /* chain in order of expiration */
76 int (*fcn)(); /* function to call */
77 char * param; /* with this parameter */
78 unsigned long ticks; /* expiration time, in ticks */
79 int set; /* unset | set | allocated */
80 };
81 #define TELT_UNSET 0 /* timer not set */
82 #define TELT_SET 1 /* timer set */
83 #define TELT_ALLOC 2 /* timer allocated from pool */
84
85 typedef struct timer_elt timer_elt_data_t;
86 typedef struct timer_elt *timer_elt_t;
87
88 /* for 'private' timer elements */
89 extern void set_timeout();
90 extern boolean_t reset_timeout();
91
92 /* for public timer elements */
93 extern void timeout();
94 extern boolean_t untimeout();
95
96 #define set_timeout_setup(telt,fcn,param,interval) \
97 ((telt)->fcn = (fcn), \
98 (telt)->param = (param), \
99 (telt)->private = TRUE, \
100 set_timeout((telt), (interval)))
101
102 #define reset_timeout_check(t) \
103 MACRO_BEGIN \
104 if ((t)->set) \
105 reset_timeout((t)); \
106 MACRO_END
107
108 #endif _KERN_TIME_OUT_H_
Cache object: 56013480e8296db025b296a98ad3373d
|