Date: Fri, 17 Sep 2004 05:41:55 GMT From: Julian Elischer <julian@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 61663 for review Message-ID: <200409170541.i8H5ft84065804@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=61663 Change 61663 by julian@julian_ref on 2004/09/17 05:41:18 create a separate thread_unthread() that we can call from places where we are turning off threading so that we canbe sure we are doing it properly. Affected files ... .. //depot/projects/nsched/sys/kern/kern_kse.c#28 edit .. //depot/projects/nsched/sys/kern/kern_thr.c#18 edit .. //depot/projects/nsched/sys/kern/kern_thread.c#37 edit .. //depot/projects/nsched/sys/sys/proc.h#33 edit Differences ... ==== //depot/projects/nsched/sys/kern/kern_kse.c#28 (text+ko) ==== @@ -346,8 +346,7 @@ * One possibility is to return to the user. It may not cope well. * The other possibility would be to let the process exit. */ - p->p_flag &= ~(P_SA|P_HADTHREADS); - sched_set_concurrency(td->td_ksegrp, 1); + thread_unthread(td); mtx_unlock_spin(&sched_lock); PROC_UNLOCK(p); #if 1 ==== //depot/projects/nsched/sys/kern/kern_thr.c#18 (text+ko) ==== ==== //depot/projects/nsched/sys/kern/kern_thread.c#37 (text+ko) ==== @@ -709,6 +709,31 @@ } /* + * Convert a process with one thread to an unthreaded process. + * Called from: + * thread_single(exit) (called from execve and exit) + * kse_exit() XXX may need cleaning up wrt KSE stuff + */ +void +thread_unthread(struct thread *td) +{ + struct proc *p = td->td_proc; + + KASSERT((p->p_numthreads == 1), ("Unthreading with >1 threads")); + upcall_remove(td); + p->p_flag &= ~(P_SA|P_HADTHREADS); + td->td_mailbox = NULL; + td->td_pflags &= ~(TDP_SA | TDP_CAN_UNBIND); + p->p_flag &= ~(P_STOPPED_SINGLE | P_SINGLE_EXIT); /* maybe not */ + p->p_singlethread = NULL; + if (td->td_standin != NULL) { + thread_stash(td->td_standin); + td->td_standin = NULL; + } + sched_set_concurrency(td->td_ksegrp, 1); +} + +/* * Called from: * thread_exit() */ @@ -835,21 +860,10 @@ * we try our utmost to revert to being a non-threaded * process. */ - upcall_remove(td); - p->p_flag &= ~(P_SA|P_HADTHREADS); - td->td_mailbox = NULL; - td->td_pflags &= ~(TDP_SA | TDP_CAN_UNBIND); + thread_unthread(td); p->p_flag &= ~(P_STOPPED_SINGLE | P_SINGLE_EXIT); - p->p_singlethread = NULL; - if (td->td_standin != NULL) { - thread_stash(td->td_standin); - td->td_standin = NULL; - } - sched_set_concurrency(td->td_ksegrp, 1); - mtx_unlock_spin(&sched_lock); - } else { - mtx_unlock_spin(&sched_lock); } + mtx_unlock_spin(&sched_lock); return (0); } ==== //depot/projects/nsched/sys/sys/proc.h#33 (text+ko) ==== @@ -892,6 +892,7 @@ void thread_unlink(struct thread *td); void thread_unsuspend(struct proc *p); void thread_unsuspend_one(struct thread *td); +void thread_unthread(struct thread *td); int thread_userret(struct thread *td, struct trapframe *frame); int thread_upcall_check(struct thread *td); void thread_user_enter(struct thread *td);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200409170541.i8H5ft84065804>