Deleted Added
full compact
kern_synch.c (170292) kern_synch.c (170294)
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 170292 2007-06-04 21:45:18Z attilio $");
38__FBSDID("$FreeBSD: head/sys/kern/kern_synch.c 170294 2007-06-04 23:50:56Z 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>

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

208 sleepq_lock(ident);
209 }
210
211 /*
212 * Adjust this thread's priority, if necessary.
213 */
214 pri = priority & PRIMASK;
215 if (pri != 0 && pri != td->td_priority) {
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>

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

208 sleepq_lock(ident);
209 }
210
211 /*
212 * Adjust this thread's priority, if necessary.
213 */
214 pri = priority & PRIMASK;
215 if (pri != 0 && pri != td->td_priority) {
216 mtx_lock_spin(&sched_lock);
216 thread_lock(td);
217 sched_prio(td, pri);
217 sched_prio(td, pri);
218 mtx_unlock_spin(&sched_lock);
218 thread_unlock(td);
219 }
220
221 if (timo && catch)
222 rval = sleepq_timedwait_sig(ident);
223 else if (timo)
224 rval = sleepq_timedwait(ident);
225 else if (catch)
226 rval = sleepq_wait_sig(ident);

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

357 */
358void
359wakeup_one(ident)
360 register void *ident;
361{
362
363 sleepq_lock(ident);
364 sleepq_signal(ident, SLEEPQ_SLEEP, -1, 0);
219 }
220
221 if (timo && catch)
222 rval = sleepq_timedwait_sig(ident);
223 else if (timo)
224 rval = sleepq_timedwait(ident);
225 else if (catch)
226 rval = sleepq_wait_sig(ident);

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

357 */
358void
359wakeup_one(ident)
360 register void *ident;
361{
362
363 sleepq_lock(ident);
364 sleepq_signal(ident, SLEEPQ_SLEEP, -1, 0);
365 sleepq_release(ident);
365}
366
367/*
368 * The machine independent parts of context switching.
369 */
370void
371mi_switch(int flags, struct thread *newtd)
372{
373 uint64_t new_switchtime;
374 struct thread *td;
375 struct proc *p;
376
366}
367
368/*
369 * The machine independent parts of context switching.
370 */
371void
372mi_switch(int flags, struct thread *newtd)
373{
374 uint64_t new_switchtime;
375 struct thread *td;
376 struct proc *p;
377
377 mtx_assert(&sched_lock, MA_OWNED | MA_NOTRECURSED);
378 td = curthread; /* XXX */
378 td = curthread; /* XXX */
379 THREAD_LOCK_ASSERT(td, MA_OWNED | MA_NOTRECURSED);
379 p = td->td_proc; /* XXX */
380 KASSERT(!TD_ON_RUNQ(td), ("mi_switch: called by old code"));
381#ifdef INVARIANTS
382 if (!TD_ON_LOCK(td) && !TD_IS_RUNNING(td))
383 mtx_assert(&Giant, MA_NOTOWNED);
384#endif
385 KASSERT(td->td_critnest == 1 || (td->td_critnest == 2 &&
386 (td->td_owepreempt) && (flags & SW_INVOL) != 0 &&
387 newtd == NULL) || panicstr,
388 ("mi_switch: switch in a critical section"));
389 KASSERT((flags & (SW_INVOL | SW_VOL)) != 0,
390 ("mi_switch: switch must be voluntary or involuntary"));
391 KASSERT(newtd != curthread, ("mi_switch: preempting back to ourself"));
392
393 /*
394 * Don't perform context switches from the debugger.
395 */
396 if (kdb_active) {
380 p = td->td_proc; /* XXX */
381 KASSERT(!TD_ON_RUNQ(td), ("mi_switch: called by old code"));
382#ifdef INVARIANTS
383 if (!TD_ON_LOCK(td) && !TD_IS_RUNNING(td))
384 mtx_assert(&Giant, MA_NOTOWNED);
385#endif
386 KASSERT(td->td_critnest == 1 || (td->td_critnest == 2 &&
387 (td->td_owepreempt) && (flags & SW_INVOL) != 0 &&
388 newtd == NULL) || panicstr,
389 ("mi_switch: switch in a critical section"));
390 KASSERT((flags & (SW_INVOL | SW_VOL)) != 0,
391 ("mi_switch: switch must be voluntary or involuntary"));
392 KASSERT(newtd != curthread, ("mi_switch: preempting back to ourself"));
393
394 /*
395 * Don't perform context switches from the debugger.
396 */
397 if (kdb_active) {
397 mtx_unlock_spin(&sched_lock);
398 thread_unlock(td);
398 kdb_backtrace();
399 kdb_reenter();
400 panic("%s: did not reenter debugger", __func__);
401 }
399 kdb_backtrace();
400 kdb_reenter();
401 panic("%s: did not reenter debugger", __func__);
402 }
402
403 if (flags & SW_VOL)
404 td->td_ru.ru_nvcsw++;
405 else
406 td->td_ru.ru_nivcsw++;
407 /*
408 * Compute the amount of time during which the current
409 * thread was running, and add that to its total so far.
410 */

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

461 * and awakening the swapper if it isn't in memory.
462 */
463void
464setrunnable(struct thread *td)
465{
466 struct proc *p;
467
468 p = td->td_proc;
403 if (flags & SW_VOL)
404 td->td_ru.ru_nvcsw++;
405 else
406 td->td_ru.ru_nivcsw++;
407 /*
408 * Compute the amount of time during which the current
409 * thread was running, and add that to its total so far.
410 */

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

461 * and awakening the swapper if it isn't in memory.
462 */
463void
464setrunnable(struct thread *td)
465{
466 struct proc *p;
467
468 p = td->td_proc;
469 mtx_assert(&sched_lock, MA_OWNED);
469 THREAD_LOCK_ASSERT(td, MA_OWNED);
470 switch (p->p_state) {
471 case PRS_ZOMBIE:
472 panic("setrunnable(1)");
473 default:
474 break;
475 }
476 switch (td->td_state) {
477 case TDS_RUNNING:

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

490 default:
491 printf("state is 0x%x", td->td_state);
492 panic("setrunnable(2)");
493 }
494 if ((p->p_sflag & PS_INMEM) == 0) {
495 if ((p->p_sflag & PS_SWAPPINGIN) == 0) {
496 p->p_sflag |= PS_SWAPINREQ;
497 /*
470 switch (p->p_state) {
471 case PRS_ZOMBIE:
472 panic("setrunnable(1)");
473 default:
474 break;
475 }
476 switch (td->td_state) {
477 case TDS_RUNNING:

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

490 default:
491 printf("state is 0x%x", td->td_state);
492 panic("setrunnable(2)");
493 }
494 if ((p->p_sflag & PS_INMEM) == 0) {
495 if ((p->p_sflag & PS_SWAPPINGIN) == 0) {
496 p->p_sflag |= PS_SWAPINREQ;
497 /*
498 * due to a LOR between sched_lock and
498 * due to a LOR between the thread lock and
499 * the sleepqueue chain locks, use
500 * lower level scheduling functions.
501 */
502 kick_proc0();
503 }
504 } else
505 sched_wakeup(td);
506}

--- 60 unchanged lines hidden ---
499 * the sleepqueue chain locks, use
500 * lower level scheduling functions.
501 */
502 kick_proc0();
503 }
504 } else
505 sched_wakeup(td);
506}

--- 60 unchanged lines hidden ---