From owner-p4-projects Tue Jun 18 23:13:32 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EF12D37B409; Tue, 18 Jun 2002 23:13:23 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 2DC2137B403 for ; Tue, 18 Jun 2002 23:13:23 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g5J6DMD03368 for perforce@freebsd.org; Tue, 18 Jun 2002 23:13:22 -0700 (PDT) (envelope-from julian@freebsd.org) Date: Tue, 18 Jun 2002 23:13:22 -0700 (PDT) Message-Id: <200206190613.g5J6DMD03368@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to julian@freebsd.org using -f From: Julian Elischer Subject: PERFORCE change 13135 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=13135 Change 13135 by julian@julian_jules1 on 2002/06/18 23:13:11 More cleaning up of thread suspension code. Affected files ... ... //depot/projects/kse/sys/kern/kern_exit.c#55 edit ... //depot/projects/kse/sys/kern/kern_fork.c#71 edit ... //depot/projects/kse/sys/sys/proc.h#111 edit Differences ... ==== //depot/projects/kse/sys/kern/kern_exit.c#55 (text+ko) ==== @@ -148,9 +148,8 @@ PROC_LOCK(p); if (p->p_flag & P_KSES) { /* - * First kill off the other threads. This requires - * Some co-operation from other parts of the kernel - * so it may not be instant. + * First check if some other thread got here before us.. + * if so, act apropriatly, (exit or suspend); */ thread_suspend_check(0); /* @@ -164,15 +163,33 @@ * (or even an exit(2) from the UTS). */ td->td_flags |= TDF_UNBOUND; + + /* + * Kill off the other threads. This requires + * Some co-operation from other parts of the kernel + * so it may not be instant. + * With this state set: + * Any thread entering the kernel from userspace will + * thread_exit() in trap(). Any thread attempting to + * sleep will return immediatly + * with EINTR or EWOULDBLOCK, which will hopefully force them + * to back out to userland, freeing resources as they go, and + * anything attempting to return to userland will thread_exit() + * from userret(). thread_exit() will unsuspend us + * when the last other thread exits. + */ if (thread_single(SNGLE_EXIT)) { - /* This can't happen.. maybe it can XXXKSE */ panic ("Exit: Single threading fouled up"); } - /* All other activity in this process is now stopped. */ - /* Remove excess KSEs and KSEGRPS. */ - /* ... */ - /* Turn off threading support. */ + /* + * All other activity in this process is now stopped. + * Remove excess KSEs and KSEGRPS. XXXKSE (when we have them) + * ... + * Turn off threading support. + */ p->p_flag &= ~P_KSES; + td->td_flags &= ~TDF_UNBOUND; + thread_single_end(); /* Don't need this any more. */ } /* * With this state set: ==== //depot/projects/kse/sys/kern/kern_fork.c#71 (text+ko) ==== @@ -289,7 +289,7 @@ * be aborted in the child. */ PROC_LOCK(p1); - if (thread_single(SNGLE_WAIT)) { + if (thread_single(SNGLE_NO_EXIT)) { /* Abort.. someone else is single threading before us */ PROC_UNLOCK(p1); return (ERESTART); ==== //depot/projects/kse/sys/sys/proc.h#111 (text+ko) ==== @@ -828,7 +828,7 @@ void thread_reap(void); struct thread *thread_schedule_upcall(struct thread *td, struct kse *ke); int thread_single(int how); -#define SNGLE_WAIT 0 /* values for 'how' */ +#define SNGLE_NO_EXIT 0 /* values for 'how' */ #define SNGLE_EXIT 1 void thread_single_end(void); void thread_stash(struct thread *td); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message