| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sleepq.h,v 1.37 2023/09/23 18:48:05 ad Exp $ */ | | 1 | /* $NetBSD: sleepq.h,v 1.38 2023/09/25 18:55:53 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2019, 2020, 2023 | | 4 | * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2019, 2020, 2023 |
5 | * The NetBSD Foundation, Inc. | | 5 | * The NetBSD Foundation, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to The NetBSD Foundation | | 8 | * This code is derived from software contributed to The NetBSD Foundation |
9 | * by Jason R. Thorpe and Andrew Doran. | | 9 | * by Jason R. Thorpe and Andrew Doran. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -28,50 +28,52 @@ | | | @@ -28,50 +28,52 @@ |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | * POSSIBILITY OF SUCH DAMAGE. | | 30 | * POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #ifndef _SYS_SLEEPQ_H_ | | 33 | #ifndef _SYS_SLEEPQ_H_ |
34 | #define _SYS_SLEEPQ_H_ | | 34 | #define _SYS_SLEEPQ_H_ |
35 | | | 35 | |
36 | #include <sys/lwp.h> | | 36 | #include <sys/lwp.h> |
37 | #include <sys/mutex.h> | | 37 | #include <sys/mutex.h> |
38 | #include <sys/pool.h> | | 38 | #include <sys/pool.h> |
39 | #include <sys/queue.h> | | 39 | #include <sys/queue.h> |
40 | #include <sys/sched.h> | | 40 | #include <sys/sched.h> |
41 | #include <sys/syncobj.h> | | 41 | #include <sys/syncobj.h> /* XXX remove me */ |
42 | #include <sys/param.h> | | 42 | #include <sys/param.h> |
43 | | | 43 | |
| | | 44 | struct syncobj; |
| | | 45 | |
44 | /* | | 46 | /* |
45 | * Generic sleep queues. | | 47 | * Generic sleep queues. |
46 | */ | | 48 | */ |
47 | | | 49 | |
48 | typedef struct sleepq sleepq_t; | | 50 | typedef struct sleepq sleepq_t; |
49 | typedef struct syncobj const syncobj_t; | | | |
50 | | | 51 | |
51 | void sleepq_init(sleepq_t *); | | 52 | void sleepq_init(sleepq_t *); |
52 | void sleepq_remove(sleepq_t *, lwp_t *); | | 53 | void sleepq_remove(sleepq_t *, lwp_t *); |
53 | void sleepq_enter(sleepq_t *, lwp_t *, kmutex_t *); | | 54 | void sleepq_enter(sleepq_t *, lwp_t *, kmutex_t *); |
54 | void sleepq_enqueue(sleepq_t *, wchan_t, const char *, syncobj_t *, bool); | | 55 | void sleepq_enqueue(sleepq_t *, wchan_t, const char *, |
| | | 56 | const struct syncobj *, bool); |
55 | void sleepq_transfer(lwp_t *, sleepq_t *, sleepq_t *, wchan_t, const char *, | | 57 | void sleepq_transfer(lwp_t *, sleepq_t *, sleepq_t *, wchan_t, const char *, |
56 | syncobj_t *, kmutex_t *, bool); | | 58 | const struct syncobj *, kmutex_t *, bool); |
57 | void sleepq_uncatch(lwp_t *); | | 59 | void sleepq_uncatch(lwp_t *); |
58 | void sleepq_unsleep(lwp_t *, bool); | | 60 | void sleepq_unsleep(lwp_t *, bool); |
59 | void sleepq_timeout(void *); | | 61 | void sleepq_timeout(void *); |
60 | void sleepq_wake(sleepq_t *, wchan_t, u_int, kmutex_t *); | | 62 | void sleepq_wake(sleepq_t *, wchan_t, u_int, kmutex_t *); |
61 | int sleepq_abort(kmutex_t *, int); | | 63 | int sleepq_abort(kmutex_t *, int); |
62 | void sleepq_changepri(lwp_t *, pri_t); | | 64 | void sleepq_changepri(lwp_t *, pri_t); |
63 | void sleepq_lendpri(lwp_t *, pri_t); | | 65 | void sleepq_lendpri(lwp_t *, pri_t); |
64 | int sleepq_block(int, bool, syncobj_t *); | | 66 | int sleepq_block(int, bool, const struct syncobj *); |
65 | | | 67 | |
66 | #ifdef _KERNEL | | 68 | #ifdef _KERNEL |
67 | | | 69 | |
68 | #include <sys/kernel.h> | | 70 | #include <sys/kernel.h> |
69 | | | 71 | |
70 | typedef union { | | 72 | typedef union { |
71 | kmutex_t lock; | | 73 | kmutex_t lock; |
72 | uint8_t pad[COHERENCY_UNIT]; | | 74 | uint8_t pad[COHERENCY_UNIT]; |
73 | } sleepqlock_t; | | 75 | } sleepqlock_t; |
74 | | | 76 | |
75 | /* | | 77 | /* |
76 | * Return non-zero if it is unsafe to sleep. | | 78 | * Return non-zero if it is unsafe to sleep. |
77 | * | | 79 | * |