Deleted Added
full compact
kern_synch.c (177010) kern_synch.c (177085)
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/kern_synch.c 177010 2008-03-10 03:16:51Z jeff $");
38__FBSDID("$FreeBSD: head/sys/kern/kern_synch.c 177085 2008-03-12 06:31:06Z jeff $");
39
40#include "opt_ktrace.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/condvar.h>
45#include <sys/kdb.h>
46#include <sys/kernel.h>

--- 108 unchanged lines hidden (view full) ---

155 * splx(s);" to give interrupts a chance, but there is
156 * no way to give interrupts a chance now.
157 */
158 if (lock != NULL && priority & PDROP)
159 class->lc_unlock(lock);
160 return (0);
161 }
162 catch = priority & PCATCH;
39
40#include "opt_ktrace.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/condvar.h>
45#include <sys/kdb.h>
46#include <sys/kernel.h>

--- 108 unchanged lines hidden (view full) ---

155 * splx(s);" to give interrupts a chance, but there is
156 * no way to give interrupts a chance now.
157 */
158 if (lock != NULL && priority & PDROP)
159 class->lc_unlock(lock);
160 return (0);
161 }
162 catch = priority & PCATCH;
163 pri = priority & PRIMASK;
163 rval = 0;
164
165 /*
166 * If we are already on a sleep queue, then remove us from that
167 * sleep queue first. We have to do this to handle recursive
168 * sleeps.
169 */
170 if (TD_ON_SLEEPQ(td))

--- 31 unchanged lines hidden (view full) ---

202 if (timo)
203 sleepq_set_timeout(ident, timo);
204 if (lock != NULL && class->lc_flags & LC_SLEEPABLE) {
205 sleepq_release(ident);
206 WITNESS_SAVE(lock, lock_witness);
207 lock_state = class->lc_unlock(lock);
208 sleepq_lock(ident);
209 }
164 rval = 0;
165
166 /*
167 * If we are already on a sleep queue, then remove us from that
168 * sleep queue first. We have to do this to handle recursive
169 * sleeps.
170 */
171 if (TD_ON_SLEEPQ(td))

--- 31 unchanged lines hidden (view full) ---

203 if (timo)
204 sleepq_set_timeout(ident, timo);
205 if (lock != NULL && class->lc_flags & LC_SLEEPABLE) {
206 sleepq_release(ident);
207 WITNESS_SAVE(lock, lock_witness);
208 lock_state = class->lc_unlock(lock);
209 sleepq_lock(ident);
210 }
210
211 /*
212 * Adjust this thread's priority, if necessary.
213 */
214 pri = priority & PRIMASK;
215 if (pri != 0 && pri != td->td_priority) {
216 thread_lock(td);
217 sched_prio(td, pri);
218 thread_unlock(td);
219 }
220
221 if (timo && catch)
211 if (timo && catch)
222 rval = sleepq_timedwait_sig(ident);
212 rval = sleepq_timedwait_sig(ident, pri);
223 else if (timo)
213 else if (timo)
224 rval = sleepq_timedwait(ident);
214 rval = sleepq_timedwait(ident, pri);
225 else if (catch)
215 else if (catch)
226 rval = sleepq_wait_sig(ident);
216 rval = sleepq_wait_sig(ident, pri);
227 else {
217 else {
228 sleepq_wait(ident);
218 sleepq_wait(ident, pri);
229 rval = 0;
230 }
231#ifdef KTRACE
232 if (KTRPOINT(td, KTR_CSW))
233 ktrcsw(0, 0);
234#endif
235 PICKUP_GIANT();
236 if (lock != NULL && !(priority & PDROP)) {

--- 65 unchanged lines hidden (view full) ---

302#endif
303#ifdef WITNESS
304 sleepq_release(ident);
305 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "Sleeping on \"%s\"",
306 wmesg);
307 sleepq_lock(ident);
308#endif
309 if (timo)
219 rval = 0;
220 }
221#ifdef KTRACE
222 if (KTRPOINT(td, KTR_CSW))
223 ktrcsw(0, 0);
224#endif
225 PICKUP_GIANT();
226 if (lock != NULL && !(priority & PDROP)) {

--- 65 unchanged lines hidden (view full) ---

292#endif
293#ifdef WITNESS
294 sleepq_release(ident);
295 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "Sleeping on \"%s\"",
296 wmesg);
297 sleepq_lock(ident);
298#endif
299 if (timo)
310 rval = sleepq_timedwait(ident);
300 rval = sleepq_timedwait(ident, 0);
311 else {
301 else {
312 sleepq_wait(ident);
302 sleepq_wait(ident, 0);
313 rval = 0;
314 }
315#ifdef KTRACE
316 if (KTRPOINT(td, KTR_CSW))
317 ktrcsw(0, 0);
318#endif
319 PICKUP_GIANT();
320 mtx_lock_spin(mtx);

--- 21 unchanged lines hidden (view full) ---

342 * Make all threads sleeping on the specified identifier runnable.
343 */
344void
345wakeup(ident)
346 register void *ident;
347{
348
349 sleepq_lock(ident);
303 rval = 0;
304 }
305#ifdef KTRACE
306 if (KTRPOINT(td, KTR_CSW))
307 ktrcsw(0, 0);
308#endif
309 PICKUP_GIANT();
310 mtx_lock_spin(mtx);

--- 21 unchanged lines hidden (view full) ---

332 * Make all threads sleeping on the specified identifier runnable.
333 */
334void
335wakeup(ident)
336 register void *ident;
337{
338
339 sleepq_lock(ident);
350 sleepq_broadcast(ident, SLEEPQ_SLEEP, -1, 0);
340 sleepq_broadcast(ident, SLEEPQ_SLEEP, 0, 0);
341 sleepq_release(ident);
351}
352
353/*
354 * Make a thread sleeping on the specified identifier runnable.
355 * May wake more than one thread if a target thread is currently
356 * swapped out.
357 */
358void
359wakeup_one(ident)
360 register void *ident;
361{
362
363 sleepq_lock(ident);
342}
343
344/*
345 * Make a thread sleeping on the specified identifier runnable.
346 * May wake more than one thread if a target thread is currently
347 * swapped out.
348 */
349void
350wakeup_one(ident)
351 register void *ident;
352{
353
354 sleepq_lock(ident);
364 sleepq_signal(ident, SLEEPQ_SLEEP, -1, 0);
355 sleepq_signal(ident, SLEEPQ_SLEEP, 0, 0);
365 sleepq_release(ident);
366}
367
368static void
369kdb_switch(void)
370{
371 thread_unlock(curthread);
372 kdb_backtrace();

--- 198 unchanged lines hidden ---
356 sleepq_release(ident);
357}
358
359static void
360kdb_switch(void)
361{
362 thread_unlock(curthread);
363 kdb_backtrace();

--- 198 unchanged lines hidden ---