summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_thread.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2002-07-24 19:50:08 +0000
committerjulian <julian@FreeBSD.org>2002-07-24 19:50:08 +0000
commit1308e5a426480bccb3e246a0d52983ae875113a8 (patch)
tree5bb11c2bc686d4944afeba079dfd28ee41afd120 /sys/kern/kern_thread.c
parent0d2eba51d0b1eeb99cd7d641212db6fe858e512d (diff)
downloadFreeBSD-src-1308e5a426480bccb3e246a0d52983ae875113a8.zip
FreeBSD-src-1308e5a426480bccb3e246a0d52983ae875113a8.tar.gz
When single threading a multithreaded program, awaken the
'single threading thread' when the last other thread suspends. I had this code in there before but it seems to have been accidentally deleted somewhere along the way. This would only affect multithreaded processes. Reviewed by: David Xu <bsddiy@yahoo.com>
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r--sys/kern/kern_thread.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index c44139d..2772abb 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -749,6 +749,13 @@ thread_suspend_check(int return_instead)
td->td_state = TDS_SUSPENDED;
TAILQ_INSERT_TAIL(&p->p_suspended, td, td_runq);
PROC_UNLOCK(p);
+ if (P_SHOULDSTOP(p) == P_STOPPED_SNGL) {
+ if (p->p_numthreads == p->p_suspcount) {
+ TAILQ_REMOVE(&p->p_suspended,
+ p->p_singlethread, td_runq);
+ setrunqueue(p->p_singlethread);
+ }
+ }
p->p_stats->p_ru.ru_nivcsw++;
mi_switch();
mtx_unlock_spin(&sched_lock);
OpenPOWER on IntegriCloud