FreeBSD/sys/kern/sched_ule.c
/*
 * Bind a thread to a target cpu.
 */
Bind a thread to a target cpu.
Bind a thread to a target cpu .
void
sched_bind(struct thread *td, int cpu)
{
	struct td_sched *ts;
	THREAD_LOCK_ASSERT(td, MA_OWNED|MA_NOTRECURSED);
	KASSERT(td == curthread, ("sched_bind: can only bind curthread"));
	ts = td_get_sched(td);
	if (ts->ts_flags & TSF_BOUND)
		sched_unbind(td);
	KASSERT(THREAD_CAN_MIGRATE(td), ("%p must be migratable", td));
	ts->ts_flags |= TSF_BOUND;
	sched_pin();
	if (PCPU_GET(cpuid) == cpu)
		return;
	ts->ts_cpu = cpu;
	mi_switch(SW_VOL, NULL);
}
void sched_bind ( struct thread * td , int cpu ) { struct td_sched * ts ; THREAD_LOCK_ASSERT ( td , MA_OWNED | MA_NOTRECURSED ) ; KASSERT ( td == curthread , ( " " ) ) ; ts = td_get_sched ( td ) ; if ( ts -> ts_flags & TSF_BOUND ) sched_unbind ( td ) ; KASSERT ( THREAD_CAN_MIGRATE ( td ) , ( " " , td ) ) ; ts -> ts_flags |= TSF_BOUND ; sched_pin ( ) ; if ( PCPU_GET ( cpuid ) == cpu ) return ; ts -> ts_cpu = cpu ; mi_switch ( SW_VOL , NULL ) ; }
Bind a thread to a target cpu.
Bind a thread to a target cpu .
/* When we return from mi_switch we'll be on the correct cpu. */