docs/how-to-build.md: use proper markup for directory names
[unleashed/tickless.git] / include / sys / sleepq.h
blob2c980303f4d75919070b9b871db0c0f16c07adb9
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 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_SLEEPQ_H
27 #define _SYS_SLEEPQ_H
29 #include <sys/machlock.h>
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
36 * Common definition for a sleep queue,
37 * be it an old-style sleep queue, or
38 * a constituent of a turnstile.
41 typedef struct sleepq {
42 struct _kthread *sq_first;
43 } sleepq_t;
46 * Definition of the head of a sleep queue hash bucket.
48 typedef struct _sleepq_head {
49 sleepq_t sq_queue;
50 disp_lock_t sq_lock;
51 } sleepq_head_t;
53 #ifdef _KERNEL
55 #define NSLEEPQ 2048
56 #define SQHASHINDEX(X) \
57 ((((uintptr_t)(X) >> 2) ^ ((uintptr_t)(X) >> 13) ^ \
58 ((uintptr_t)(X) >> 24)) & (NSLEEPQ - 1))
59 #define SQHASH(X) (&sleepq_head[SQHASHINDEX(X)])
61 extern sleepq_head_t sleepq_head[NSLEEPQ];
63 extern void sleepq_insert(sleepq_t *, struct _kthread *);
64 extern struct _kthread *sleepq_wakeone_chan(sleepq_t *, void *);
65 extern void sleepq_wakeall_chan(sleepq_t *, void *);
66 extern void sleepq_unsleep(struct _kthread *);
67 extern void sleepq_dequeue(struct _kthread *);
68 extern void sleepq_unlink(struct _kthread **, struct _kthread *);
70 #endif /* _KERNEL */
72 #ifdef __cplusplus
74 #endif
76 #endif /* _SYS_SLEEPQ_H */