docs/how-to-build.md: use proper markup for directory names
[unleashed/tickless.git] / include / sys / waitq.h
blob3b925884d06fea95bcb18bd0186b434644f66bb4
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 #pragma ident "%Z%%M% %I% %E% SMI"
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 #ifdef _KERNEL
37 #include <sys/types.h>
38 #include <sys/machlock.h>
39 #include <sys/thread.h>
41 typedef struct waitq {
42 disp_lock_t wq_lock; /* protects all fields */
43 kthread_t *wq_first; /* first thread on the queue */
44 int wq_count; /* number of threads on the queue */
45 boolean_t wq_blocked; /* True if threads can't be enqueued */
46 } waitq_t;
48 extern void waitq_init(waitq_t *);
49 extern void waitq_fini(waitq_t *);
52 * Place the thread on the wait queue. An attempt to enqueue a thread onto a
53 * blocked queue fails and returns zero. Successful enqueue returns non-zero
54 * value.
56 extern int waitq_enqueue(waitq_t *, kthread_t *);
59 * Take thread off its wait queue and make it runnable.
61 extern void waitq_setrun(kthread_t *t);
64 * Change priority for the thread on wait queue.
66 extern void waitq_change_pri(kthread_t *, pri_t);
69 * Take the first thread off the wait queue and make it runnable.
71 extern void waitq_runone(waitq_t *);
74 * Return True if there are no threads on the queue.
76 extern boolean_t waitq_isempty(waitq_t *);
79 * Prevent and allow placing new threads on wait queue.
81 extern void waitq_block(waitq_t *);
82 extern void waitq_unblock(waitq_t *);
84 #endif /* _KERNEL */
86 #ifdef __cplusplus
88 #endif
90 #endif /* _SYS_WAITQ_H */