diff options
Diffstat (limited to 'sys/kern/kern_thr.c')
-rw-r--r-- | sys/kern/kern_thr.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index 63b8f3c..6a5f220 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -76,6 +76,7 @@ thr_create(struct thread *td, struct thr_create_args *uap) int error; struct ksegrp *kg, *newkg; struct proc *p; + int scope_sys; p = td->td_proc; kg = td->td_ksegrp; @@ -87,9 +88,11 @@ thr_create(struct thread *td, struct thr_create_args *uap) (p->p_numthreads >= max_threads_per_proc)) { return (EPROCLIM); } + + scope_sys = thr_scope_sys; /* Initialize our td and new ksegrp.. */ newtd = thread_alloc(); - if (thr_scope_sys) + if (scope_sys) newkg = ksegrp_alloc(); else newkg = kg; @@ -99,7 +102,7 @@ thr_create(struct thread *td, struct thr_create_args *uap) */ id = newtd->td_tid; if ((error = copyout(&id, uap->id, sizeof(long)))) { - if (thr_scope_sys) + if (scope_sys) ksegrp_free(newkg); thread_free(newtd); return (error); @@ -110,7 +113,7 @@ thr_create(struct thread *td, struct thr_create_args *uap) bcopy(&td->td_startcopy, &newtd->td_startcopy, (unsigned) RANGEOF(struct thread, td_startcopy, td_endcopy)); - if (thr_scope_sys) { + if (scope_sys) { bzero(&newkg->kg_startzero, (unsigned)RANGEOF(struct ksegrp, kg_startzero, kg_endzero)); bcopy(&kg->kg_startcopy, &newkg->kg_startcopy, @@ -124,7 +127,7 @@ thr_create(struct thread *td, struct thr_create_args *uap) cpu_set_upcall(newtd, td); error = set_mcontext(newtd, &ctx.uc_mcontext); if (error != 0) { - if (thr_scope_sys) + if (scope_sys) ksegrp_free(newkg); thread_free(newtd); crfree(td->td_ucred); @@ -133,7 +136,7 @@ thr_create(struct thread *td, struct thr_create_args *uap) /* Link the thread and kse into the ksegrp and make it runnable. */ PROC_LOCK(td->td_proc); - if (thr_scope_sys) { + if (scope_sys) { sched_init_concurrency(newkg); } else { if ((td->td_proc->p_flag & P_HADTHREADS) == 0) { @@ -145,7 +148,7 @@ thr_create(struct thread *td, struct thr_create_args *uap) td->td_proc->p_flag |= P_HADTHREADS; newtd->td_sigmask = td->td_sigmask; mtx_lock_spin(&sched_lock); - if (thr_scope_sys) + if (scope_sys) ksegrp_link(newkg, p); thread_link(newtd, newkg); mtx_unlock_spin(&sched_lock); @@ -153,7 +156,7 @@ thr_create(struct thread *td, struct thr_create_args *uap) /* let the scheduler know about these things. */ mtx_lock_spin(&sched_lock); - if (thr_scope_sys) + if (scope_sys) sched_fork_ksegrp(td, newkg); sched_fork_thread(td, newtd); |