From e7578c3795e2978e62ac24580afb7f9486ddf33b Mon Sep 17 00:00:00 2001 From: davidxu Date: Fri, 21 May 2004 14:50:23 +0000 Subject: [PATCH] Clear KSE thread flags after KSE thread mode is ended. The side effect of not clearing the flags for execv() syscall will result that a new program runs in KSE thread mode without enabling it. Submitted by: tjr Modified by: davidxu --- sys/kern/kern_exec.c | 3 +++ sys/kern/kern_exit.c | 3 +++ sys/kern/kern_kse.c | 2 +- sys/kern/kern_thread.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index dac4475112d4..44f5e75977c4 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -266,6 +266,9 @@ kern_execve(td, fname, argv, envv, mac_p) */ p->p_flag &= ~P_SA; td->td_mailbox = NULL; + mtx_lock_spin(&sched_lock); + td->td_flags &= ~TDF_SA; + mtx_unlock_spin(&sched_lock); thread_single_end(); } p->p_flag |= P_INEXEC; diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 8a2b511a8e8c..c39ed6f622d1 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -162,6 +162,9 @@ exit1(struct thread *td, int rv) * Turn off threading support. */ p->p_flag &= ~P_SA; + mtx_lock_spin(&sched_lock); + td->td_flags &= ~TDF_SA; + mtx_unlock_spin(&sched_lock); thread_single_end(); /* Don't need this any more. */ } diff --git a/sys/kern/kern_kse.c b/sys/kern/kern_kse.c index 43b0f741aa2a..88b2689c05eb 100644 --- a/sys/kern/kern_kse.c +++ b/sys/kern/kern_kse.c @@ -2217,7 +2217,7 @@ thread_single_end(void) td = curthread; p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); - p->p_flag &= ~P_STOPPED_SINGLE; + p->p_flag &= ~(P_STOPPED_SINGLE | P_SINGLE_EXIT); mtx_lock_spin(&sched_lock); p->p_singlethread = NULL; /* diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 43b0f741aa2a..88b2689c05eb 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -2217,7 +2217,7 @@ thread_single_end(void) td = curthread; p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); - p->p_flag &= ~P_STOPPED_SINGLE; + p->p_flag &= ~(P_STOPPED_SINGLE | P_SINGLE_EXIT); mtx_lock_spin(&sched_lock); p->p_singlethread = NULL; /*