• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*	$NetBSD: schedule.h,v 1.4.6.1 2007/03/21 14:29:48 vanhu Exp $	*/
2 
3 /* Id: schedule.h,v 1.5 2006/05/03 21:53:42 vanhu Exp */
4 
5 /*
6  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. Neither the name of the project nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33 
34 #ifndef _SCHEDULE_H
35 #define _SCHEDULE_H
36 
37 #include <sys/queue.h>
38 #include "gnuc.h"
39 
40 /* scheduling table */
41 /* the head is the nearest event. */
42 struct sched {
43 	time_t xtime;		/* event time which is as time(3). */
44 				/*
45 				 * if defined FIXY2038PROBLEM, this time
46 				 * is from the time when called sched_init().
47 				 */
48 	void (*func) __P((void *)); /* call this function when timeout. */
49 	void *param;		/* pointer to parameter */
50 
51 	int dead;		/* dead or alive */
52 	long id;		/* for debug */
53 	time_t created;		/* for debug */
54 	time_t tick;		/* for debug */
55 
56 	TAILQ_ENTRY(sched) chain;
57 };
58 
59 /* cancel schedule */
60 #define SCHED_KILL(s)                                                          \
61 do {                                                                           \
62 	if(s != NULL){	   														\
63 		sched_kill(s);                                                         \
64 		s = NULL;                                                              \
65 	}\
66 } while(0)
67 
68 /* must be called after it's called from scheduler. */
69 #define SCHED_INIT(s)	(s) = NULL
70 
71 struct scheddump {
72 	time_t xtime;
73 	long id;
74 	time_t created;
75 	time_t tick;
76 };
77 
78 struct timeval *schedular __P((void));
79 struct sched *sched_new __P((time_t, void (*func) __P((void *)), void *));
80 void sched_kill __P((struct sched *));
81 int sched_dump __P((caddr_t *, int *));
82 void sched_init __P((void));
83 void sched_scrub_param __P((void *));
84 
85 #endif /* _SCHEDULE_H */
86