FreeBSD/sys/kern/sched_ule.c
/*
 * Fork a new thread, may be within the same process.
 */
Fork a new thread, may be within the same process.
Fork a new thread may be within the same process .
void
sched_fork_thread(struct thread *td, struct thread *child)
{
	struct td_sched *ts;
	struct td_sched *ts2;
	struct tdq *tdq;
	tdq = TDQ_SELF();
	THREAD_LOCK_ASSERT(td, MA_OWNED);
	ts = td_get_sched(td);
	ts2 = td_get_sched(child);
	child->td_oncpu = NOCPU;
	child->td_lastcpu = NOCPU;
	child->td_lock = TDQ_LOCKPTR(tdq);
	child->td_cpuset = cpuset_ref(td->td_cpuset);
	ts2->ts_cpu = ts->ts_cpu;
	ts2->ts_flags = 0;
	ts2->ts_ticks = ts->ts_ticks;
	ts2->ts_ltick = ts->ts_ltick;
	ts2->ts_ftick = ts->ts_ftick;
	child->td_priority = child->td_base_pri;
	ts2->ts_slptime = ts->ts_slptime;
	ts2->ts_runtime = ts->ts_runtime;
	ts2->ts_slice = tdq_slice(tdq) - sched_slice_min;
#ifdef KTR
	bzero(ts2->ts_name, sizeof(ts2->ts_name));
#endif
}
void sched_fork_thread ( struct thread * td , struct thread * child ) { struct td_sched * ts ; struct td_sched * ts2 ; struct tdq * tdq ; tdq = TDQ_SELF ( ) ; THREAD_LOCK_ASSERT ( td , MA_OWNED ) ; ts = td_get_sched ( td ) ; ts2 = td_get_sched ( child ) ; child -> td_oncpu = NOCPU ; child -> td_lastcpu = NOCPU ; child -> td_lock = TDQ_LOCKPTR ( tdq ) ; child -> td_cpuset = cpuset_ref ( td -> td_cpuset ) ; ts2 -> ts_cpu = ts -> ts_cpu ; ts2 -> ts_flags = 0 ; ts2 -> ts_ticks = ts -> ts_ticks ; ts2 -> ts_ltick = ts -> ts_ltick ; ts2 -> ts_ftick = ts -> ts_ftick ; child -> td_priority = child -> td_base_pri ; ts2 -> ts_slptime = ts -> ts_slptime ; ts2 -> ts_runtime = ts -> ts_runtime ; ts2 -> ts_slice = tdq_slice ( tdq ) - sched_slice_min ; #ifdef KTR bzero ( ts2 -> ts_name , sizeof ( ts2 -> ts_name ) ) ; #endif }
Fork a new thread, may be within the same process.
Fork a new thread may be within the same process .
/*
	 * Initialize child.
	 */ /*
	 * Grab our parents cpu estimation information.
	 */ /*
	 * Do not inherit any borrowed priority from the parent.
	 */ /*
	 * And update interactivity score.
	 */ /* Attempt to quickly learn interactivity. */