| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: scheduler.c,v 1.31 2013/04/27 16:32:57 pooka Exp $ */ | | 1 | /* $NetBSD: scheduler.c,v 1.32 2013/04/27 22:26:57 pooka Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. | | 4 | * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -16,27 +16,27 @@ | | | @@ -16,27 +16,27 @@ |
16 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | | 16 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | | 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | | 18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
25 | * SUCH DAMAGE. | | 25 | * SUCH DAMAGE. |
26 | */ | | 26 | */ |
27 | | | 27 | |
28 | #include <sys/cdefs.h> | | 28 | #include <sys/cdefs.h> |
29 | __KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.31 2013/04/27 16:32:57 pooka Exp $"); | | 29 | __KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.32 2013/04/27 22:26:57 pooka Exp $"); |
30 | | | 30 | |
31 | #include <sys/param.h> | | 31 | #include <sys/param.h> |
32 | #include <sys/atomic.h> | | 32 | #include <sys/atomic.h> |
33 | #include <sys/cpu.h> | | 33 | #include <sys/cpu.h> |
34 | #include <sys/kmem.h> | | 34 | #include <sys/kmem.h> |
35 | #include <sys/mutex.h> | | 35 | #include <sys/mutex.h> |
36 | #include <sys/namei.h> | | 36 | #include <sys/namei.h> |
37 | #include <sys/queue.h> | | 37 | #include <sys/queue.h> |
38 | #include <sys/select.h> | | 38 | #include <sys/select.h> |
39 | #include <sys/systm.h> | | 39 | #include <sys/systm.h> |
40 | | | 40 | |
41 | #include <rump/rumpuser.h> | | 41 | #include <rump/rumpuser.h> |
42 | | | 42 | |
| @@ -155,34 +155,34 @@ void | | | @@ -155,34 +155,34 @@ void |
155 | rump_scheduler_init(int numcpu) | | 155 | rump_scheduler_init(int numcpu) |
156 | { | | 156 | { |
157 | struct rumpcpu *rcpu; | | 157 | struct rumpcpu *rcpu; |
158 | struct cpu_info *ci; | | 158 | struct cpu_info *ci; |
159 | int i; | | 159 | int i; |
160 | | | 160 | |
161 | rumpuser_mutex_init(&lwp0mtx, RUMPUSER_MTX_SPIN); | | 161 | rumpuser_mutex_init(&lwp0mtx, RUMPUSER_MTX_SPIN); |
162 | rumpuser_cv_init(&lwp0cv); | | 162 | rumpuser_cv_init(&lwp0cv); |
163 | for (i = 0; i < numcpu; i++) { | | 163 | for (i = 0; i < numcpu; i++) { |
164 | rcpu = &rcpu_storage[i]; | | 164 | rcpu = &rcpu_storage[i]; |
165 | ci = &rump_cpus[i]; | | 165 | ci = &rump_cpus[i]; |
166 | rcpu->rcpu_ci = ci; | | 166 | rcpu->rcpu_ci = ci; |
167 | ci->ci_schedstate.spc_mutex = | | 167 | ci->ci_schedstate.spc_mutex = |
168 | mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE); | | 168 | mutex_obj_alloc(MUTEX_DEFAULT, IPL_SCHED); |
169 | ci->ci_schedstate.spc_flags = SPCF_RUNNING; | | 169 | ci->ci_schedstate.spc_flags = SPCF_RUNNING; |
170 | rcpu->rcpu_wanted = 0; | | 170 | rcpu->rcpu_wanted = 0; |
171 | rumpuser_cv_init(&rcpu->rcpu_cv); | | 171 | rumpuser_cv_init(&rcpu->rcpu_cv); |
172 | rumpuser_mutex_init(&rcpu->rcpu_mtx, RUMPUSER_MTX_SPIN); | | 172 | rumpuser_mutex_init(&rcpu->rcpu_mtx, RUMPUSER_MTX_SPIN); |
173 | } | | 173 | } |
174 | | | 174 | |
175 | mutex_init(&unruntime_lock, MUTEX_DEFAULT, IPL_NONE); | | 175 | mutex_init(&unruntime_lock, MUTEX_DEFAULT, IPL_SCHED); |
176 | } | | 176 | } |
177 | | | 177 | |
178 | /* | | 178 | /* |
179 | * condvar ops using scheduler lock as the rumpuser interlock. | | 179 | * condvar ops using scheduler lock as the rumpuser interlock. |
180 | */ | | 180 | */ |
181 | void | | 181 | void |
182 | rump_schedlock_cv_wait(struct rumpuser_cv *cv) | | 182 | rump_schedlock_cv_wait(struct rumpuser_cv *cv) |
183 | { | | 183 | { |
184 | struct lwp *l = curlwp; | | 184 | struct lwp *l = curlwp; |
185 | struct rumpcpu *rcpu = &rcpu_storage[l->l_cpu-&rump_cpus[0]]; | | 185 | struct rumpcpu *rcpu = &rcpu_storage[l->l_cpu-&rump_cpus[0]]; |
186 | | | 186 | |
187 | /* mutex will be taken and released in cpu schedule/unschedule */ | | 187 | /* mutex will be taken and released in cpu schedule/unschedule */ |
188 | rumpuser_cv_wait(cv, rcpu->rcpu_mtx); | | 188 | rumpuser_cv_wait(cv, rcpu->rcpu_mtx); |