16683 pthread_cond_timedwait broken when using static initializer
[illumos-gate.git] / usr / src / uts / common / sys / waitq.h
blob4846837496d6085c1115a3b6f3fb335e86fe726b
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
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]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_WAITQ_H
27 #define _SYS_WAITQ_H
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 #ifdef _KERNEL
35 #include <sys/types.h>
36 #include <sys/machlock.h>
37 #include <sys/thread.h>
39 typedef struct waitq {
40 disp_lock_t wq_lock; /* protects all fields */
41 kthread_t *wq_first; /* first thread on the queue */
42 int wq_count; /* number of threads on the queue */
43 boolean_t wq_blocked; /* True if threads can't be enqueued */
44 } waitq_t;
46 extern void waitq_init(waitq_t *);
47 extern void waitq_fini(waitq_t *);
50 * Place the thread on the wait queue. An attempt to enqueue a thread onto a
51 * blocked queue fails and returns zero. Successful enqueue returns non-zero
52 * value.
54 extern int waitq_enqueue(waitq_t *, kthread_t *);
57 * Take thread off its wait queue and make it runnable.
59 extern void waitq_setrun(kthread_t *t);
62 * Change priority for the thread on wait queue.
64 extern void waitq_change_pri(kthread_t *, pri_t);
67 * Take the first thread off the wait queue and make it runnable.
69 extern void waitq_runone(waitq_t *);
72 * Return True if there are no threads on the queue.
74 extern boolean_t waitq_isempty(waitq_t *);
77 * Prevent and allow placing new threads on wait queue.
79 extern void waitq_block(waitq_t *);
80 extern void waitq_unblock(waitq_t *);
82 #endif /* _KERNEL */
84 #ifdef __cplusplus
86 #endif
88 #endif /* _SYS_WAITQ_H */