* Fork a new thread, may be within the same process. */
| 2259 | * Fork a new thread, may be within the same process. |
| 2260 | */ |
| 2261 | void |
| 2262 | sched_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. |
no test coverage detected