9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * Copyright (c) 2012 by Delphix. All rights reserved.
28 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
29 */
30
31 /*
32 * condvar.h:
33 *
34 * definitions for thread synchronization primitives: condition variables
35 * This is the public part of the interface to condition variables. The
36 * private (implementation-specific) part is in <arch>/sys/condvar_impl.h.
37 */
38
39 #ifndef _SYS_CONDVAR_H
40 #define _SYS_CONDVAR_H
41
42 #include <sys/types.h>
43 #include <sys/time.h>
44 #include <sys/mutex.h>
45 #include <sys/synch.h> /* lwp_cond_t */
46
47 #ifdef __cplusplus
48 extern "C" {
61
62
63 /*
64 * Time resolution values used in cv_reltimedwait() and cv_reltimedwait_sig()
65 * to specify how accurately a relative timeout must expire - if it can be
66 * anticipated or deferred.
67 */
68 typedef enum {
69 TR_NANOSEC,
70 TR_MICROSEC,
71 TR_MILLISEC,
72 TR_SEC,
73 TR_CLOCK_TICK,
74 TR_COUNT
75 } time_res_t;
76
77 extern time_res_t time_res[];
78
79 #define TIME_RES_VALID(tr) (tr >= TR_NANOSEC && tr < TR_COUNT)
80
81 /*
82 * condition variable function prototypes
83 */
84
85 extern void cv_init(kcondvar_t *, char *, kcv_type_t, void *);
86 extern void cv_destroy(kcondvar_t *);
87 extern void cv_wait(kcondvar_t *, kmutex_t *);
88 extern void cv_wait_stop(kcondvar_t *, kmutex_t *, int);
89 extern clock_t cv_timedwait(kcondvar_t *, kmutex_t *, clock_t);
90 extern clock_t cv_reltimedwait(kcondvar_t *, kmutex_t *, clock_t, time_res_t);
91 extern int cv_wait_sig(kcondvar_t *, kmutex_t *);
92 extern clock_t cv_timedwait_sig(kcondvar_t *, kmutex_t *, clock_t);
93 extern int cv_timedwait_sig_hrtime(kcondvar_t *, kmutex_t *, hrtime_t);
94 extern clock_t cv_reltimedwait_sig(kcondvar_t *, kmutex_t *, clock_t,
95 time_res_t);
96 extern int cv_wait_sig_swap(kcondvar_t *, kmutex_t *);
97 extern int cv_wait_sig_swap_core(kcondvar_t *, kmutex_t *, int *);
98 extern void cv_signal(kcondvar_t *);
99 extern void cv_broadcast(kcondvar_t *);
100 extern int cv_waituntil_sig(kcondvar_t *, kmutex_t *, timestruc_t *, int);
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif /* _SYS_CONDVAR_H */
|
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * Copyright (c) 2012 by Delphix. All rights reserved.
28 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
29 * Copyright 2017 RackTop Systems.
30 */
31
32 /*
33 * condvar.h:
34 *
35 * definitions for thread synchronization primitives: condition variables
36 * This is the public part of the interface to condition variables. The
37 * private (implementation-specific) part is in <arch>/sys/condvar_impl.h.
38 */
39
40 #ifndef _SYS_CONDVAR_H
41 #define _SYS_CONDVAR_H
42
43 #include <sys/types.h>
44 #include <sys/time.h>
45 #include <sys/mutex.h>
46 #include <sys/synch.h> /* lwp_cond_t */
47
48 #ifdef __cplusplus
49 extern "C" {
62
63
64 /*
65 * Time resolution values used in cv_reltimedwait() and cv_reltimedwait_sig()
66 * to specify how accurately a relative timeout must expire - if it can be
67 * anticipated or deferred.
68 */
69 typedef enum {
70 TR_NANOSEC,
71 TR_MICROSEC,
72 TR_MILLISEC,
73 TR_SEC,
74 TR_CLOCK_TICK,
75 TR_COUNT
76 } time_res_t;
77
78 extern time_res_t time_res[];
79
80 #define TIME_RES_VALID(tr) (tr >= TR_NANOSEC && tr < TR_COUNT)
81
82 #define CALLOUT_FLAG_ABSOLUTE 0x2
83
84 /*
85 * condition variable function prototypes
86 */
87
88 extern void cv_init(kcondvar_t *, char *, kcv_type_t, void *);
89 extern void cv_destroy(kcondvar_t *);
90 extern void cv_wait(kcondvar_t *, kmutex_t *);
91 extern void cv_wait_stop(kcondvar_t *, kmutex_t *, int);
92 extern clock_t cv_timedwait(kcondvar_t *, kmutex_t *, clock_t);
93 extern clock_t cv_timedwait_hires(kcondvar_t *, kmutex_t *, hrtime_t, hrtime_t,
94 int);
95 extern clock_t cv_reltimedwait(kcondvar_t *, kmutex_t *, clock_t, time_res_t);
96 extern int cv_wait_sig(kcondvar_t *, kmutex_t *);
97 extern clock_t cv_timedwait_sig(kcondvar_t *, kmutex_t *, clock_t);
98 extern int cv_timedwait_sig_hrtime(kcondvar_t *, kmutex_t *, hrtime_t);
99 extern clock_t cv_reltimedwait_sig(kcondvar_t *, kmutex_t *, clock_t,
100 time_res_t);
101 extern int cv_wait_sig_swap(kcondvar_t *, kmutex_t *);
102 extern int cv_wait_sig_swap_core(kcondvar_t *, kmutex_t *, int *);
103 extern void cv_signal(kcondvar_t *);
104 extern void cv_broadcast(kcondvar_t *);
105 extern int cv_waituntil_sig(kcondvar_t *, kmutex_t *, timestruc_t *, int);
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #endif /* _SYS_CONDVAR_H */
|