MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sched_fork_thread

Function sched_fork_thread

freebsd/kern/sched_ule.c:2261–2302  ·  view source on GitHub ↗

* Fork a new thread, may be within the same process. */

Source from the content-addressed store, hash-verified

2259 * Fork a new thread, may be within the same process.
2260 */
2261void
2262sched_fork_thread(struct thread *td, struct thread *child)
2263{
2264 struct td_sched *ts;
2265 struct td_sched *ts2;
2266 struct tdq *tdq;
2267
2268 tdq = TDQ_SELF();
2269 THREAD_LOCK_ASSERT(td, MA_OWNED);
2270 /*
2271 * Initialize child.
2272 */
2273 ts = td_get_sched(td);
2274 ts2 = td_get_sched(child);
2275 child->td_oncpu = NOCPU;
2276 child->td_lastcpu = NOCPU;
2277 child->td_lock = TDQ_LOCKPTR(tdq);
2278 child->td_cpuset = cpuset_ref(td->td_cpuset);
2279 child->td_domain.dr_policy = td->td_cpuset->cs_domain;
2280 ts2->ts_cpu = ts->ts_cpu;
2281 ts2->ts_flags = 0;
2282 /*
2283 * Grab our parents cpu estimation information.
2284 */
2285 ts2->ts_ticks = ts->ts_ticks;
2286 ts2->ts_ltick = ts->ts_ltick;
2287 ts2->ts_ftick = ts->ts_ftick;
2288 /*
2289 * Do not inherit any borrowed priority from the parent.
2290 */
2291 child->td_priority = child->td_base_pri;
2292 /*
2293 * And update interactivity score.
2294 */
2295 ts2->ts_slptime = ts->ts_slptime;
2296 ts2->ts_runtime = ts->ts_runtime;
2297 /* Attempt to quickly learn interactivity. */
2298 ts2->ts_slice = tdq_slice(tdq) - sched_slice_min;
2299#ifdef KTR
2300 bzero(ts2->ts_name, sizeof(ts2->ts_name));
2301#endif
2302}
2303
2304/*
2305 * Adjust the priority class of a thread.

Callers 3

sched_forkFunction · 0.70
thread_createFunction · 0.70
kthread_addFunction · 0.70

Calls 4

td_get_schedFunction · 0.85
cpuset_refFunction · 0.85
tdq_sliceFunction · 0.85
bzeroFunction · 0.85

Tested by

no test coverage detected