From owner-p4-projects@FreeBSD.ORG Fri Sep 17 05:41:56 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3271816A4D0; Fri, 17 Sep 2004 05:41:56 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB5D316A4CF for ; Fri, 17 Sep 2004 05:41:55 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C2A0543D41 for ; Fri, 17 Sep 2004 05:41:55 +0000 (GMT) (envelope-from julian@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i8H5ftYa065807 for ; Fri, 17 Sep 2004 05:41:55 GMT (envelope-from julian@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i8H5ft84065804 for perforce@freebsd.org; Fri, 17 Sep 2004 05:41:55 GMT (envelope-from julian@freebsd.org) Date: Fri, 17 Sep 2004 05:41:55 GMT Message-Id: <200409170541.i8H5ft84065804@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to julian@freebsd.org using -f From: Julian Elischer To: Perforce Change Reviews Subject: PERFORCE change 61663 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Sep 2004 05:41:56 -0000 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);