FreeBSD/sys/kern/sched_ule.c
/*
 * Handle migration from sched_switch().  This happens only for
 * cpu binding.
 */
Handle migration from sched_switch().  This happens only for
cpu binding.
Handle migration from sched_switch () . This happens only for cpu binding .
static struct mtx *
sched_switch_migrate(struct tdq *tdq, struct thread *td, int flags)
{
	struct tdq *tdn;
	tdn = TDQ_CPU(td_get_sched(td)->ts_cpu);
#ifdef SMP
	tdq_load_rem(tdq, td);
	spinlock_enter();
	thread_lock_block(td);	
	tdq_lock_pair(tdn, tdq);
	tdq_add(tdn, td, flags);
	tdq_notify(tdn, td);
	TDQ_UNLOCK(tdn);
	spinlock_exit();
#endif
	return (TDQ_LOCKPTR(tdn));
}
static struct mtx * sched_switch_migrate ( struct tdq * tdq , struct thread * td , int flags ) { struct tdq * tdn ; tdn = TDQ_CPU ( td_get_sched ( td ) -> ts_cpu ) ; #ifdef SMP tdq_load_rem ( tdq , td ) ; spinlock_enter ( ) ; thread_lock_block ( td ) ; tdq_lock_pair ( tdn , tdq ) ; tdq_add ( tdn , td , flags ) ; tdq_notify ( tdn , td ) ; TDQ_UNLOCK ( tdn ) ; spinlock_exit ( ) ; #endif return ( TDQ_LOCKPTR ( tdn ) ) ; }
Handle migration from sched_switch().
Handle migration from sched_switch () .
/*
	 * Do the lock dance required to avoid LOR.  We grab an extra
	 * spinlock nesting to prevent preemption while we're
	 * not holding either run-queue lock.
	 */ /* This releases the lock on tdq. */ /*
	 * Acquire both run-queue locks before placing the thread on the new
	 * run-queue to avoid deadlocks created by placing a thread with a
	 * blocked lock on the run-queue of a remote processor.  The deadlock
	 * occurs when a third processor attempts to lock the two queues in
	 * question while the target processor is spinning with its own
	 * run-queue lock held while waiting for the blocked lock to clear.
	 */