dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / fm / fmd / common / fmd_timerq.h
blob6f9edfe52a31fd672ca659f1e8a4cdd34f706b2c
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _FMD_TIMERQ_H
28 #define _FMD_TIMERQ_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <pthread.h>
33 #include <time.h>
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 #include <fmd_idspace.h>
40 #include <fmd_thread.h>
41 #include <fmd_event.h>
42 #include <fmd_list.h>
44 typedef void fmd_timer_f(void *, id_t, hrtime_t);
46 typedef struct fmd_timer {
47 fmd_list_t tmr_list; /* expiry or free list next/prev pointers */
48 hrtime_t tmr_hrt; /* high-res time at which timer should fire */
49 fmd_idspace_t *tmr_ids; /* idspace that contains the timer id */
50 id_t tmr_id; /* client identifier for this timer */
51 fmd_timer_f *tmr_func; /* function that should be called on expiry */
52 void *tmr_arg; /* argument to pass back to tmr_func */
53 pthread_cond_t tmr_cv; /* condition variable for waiting on tmr_func */
54 } fmd_timer_t;
56 typedef struct fmd_timerq {
57 fmd_thread_t *tmq_thread; /* thread handling timer expiry for queue */
58 uint_t tmq_abort; /* flag indicating tmq_thread should abort */
59 pthread_mutex_t tmq_lock; /* lock protecting timer queue contents */
60 pthread_cond_t tmq_cv; /* condition variable for tmq_list, abort */
61 fmd_list_t tmq_list; /* list of active timers, sorted by tmr_hrt */
62 fmd_list_t tmq_free; /* list of free timers */
63 } fmd_timerq_t;
65 extern id_t fmd_timerq_install(fmd_timerq_t *,
66 fmd_idspace_t *, fmd_timer_f *, void *, fmd_event_t *, hrtime_t);
68 extern void *fmd_timerq_remove(fmd_timerq_t *, fmd_idspace_t *, id_t);
69 extern fmd_timerq_t *fmd_timerq_create(void);
70 extern void fmd_timerq_destroy(fmd_timerq_t *);
72 #ifdef __cplusplus
74 #endif
76 #endif /* _FMD_TIMERQ_H */