diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 6acb0437b243..59b52306800d 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -733,10 +733,14 @@ sched_fork(struct thread *td, struct thread *childtd) void sched_fork_thread(struct thread *td, struct thread *childtd) { + struct td_sched *ts; + childtd->td_estcpu = td->td_estcpu; childtd->td_lock = &sched_lock; childtd->td_cpuset = cpuset_ref(td->td_cpuset); - sched_newthread(childtd); + ts = childtd->td_sched; + bzero(ts, sizeof(*ts)); + ts->ts_thread = childtd; } void diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 85c6e2b6b297..04dc63a2f7a8 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -488,7 +488,6 @@ tdq_load_rem(struct tdq *tdq, struct td_sched *ts) ("tdq_load_rem: Removing with 0 load on queue %d", TDQ_ID(tdq))); tdq->tdq_load--; CTR1(KTR_SCHED, "load: %d", tdq->tdq_load); - ts->ts_runq = NULL; } /* @@ -1905,17 +1904,17 @@ sched_fork_thread(struct thread *td, struct thread *child) struct td_sched *ts; struct td_sched *ts2; + THREAD_LOCK_ASSERT(td, MA_OWNED); /* * Initialize child. */ - THREAD_LOCK_ASSERT(td, MA_OWNED); - sched_newthread(child); - child->td_lock = TDQ_LOCKPTR(TDQ_SELF()); - child->td_cpuset = cpuset_ref(td->td_cpuset); ts = td->td_sched; ts2 = child->td_sched; + child->td_lock = TDQ_LOCKPTR(TDQ_SELF()); + child->td_cpuset = cpuset_ref(td->td_cpuset); + ts2->ts_thread = child; ts2->ts_cpu = ts->ts_cpu; - ts2->ts_runq = NULL; + ts2->ts_flags = 0; /* * Grab our parents cpu estimation information and priority. */