Date: Tue, 18 Jun 2002 23:13:22 -0700 (PDT) From: Julian Elischer <julian@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 13135 for review Message-ID: <200206190613.g5J6DMD03368@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206190613.g5J6DMD03368>