From 4133b7f7992a38b19d5bfe47591e932e92d958e8 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 23 Dec 2012 14:59:54 +0100 Subject: Make thread_suspend wait for !TH_UNINT 0a55db5 made thread_suspend return KERN_FAILURE when the target thread is in TH_UNINT state. That however is not currently handled by libc, and it's more useful to just wait for the thread to get interruptible. * kern/sched_prim.c (thread_invoke): Wake NEW_THREAD->STATE for thread_suspend. * kern/thread.c (thread_suspend): Wait on NEW_THREAD->STATE as long as THREAD has TH_UNINT. --- kern/sched_prim.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'kern/sched_prim.c') diff --git a/kern/sched_prim.c b/kern/sched_prim.c index a7b7a4e..ba2dc8a 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -637,6 +637,7 @@ boolean_t thread_invoke( thread_lock(new_thread); new_thread->state &= ~TH_UNINT; thread_unlock(new_thread); + thread_wakeup(&new_thread->state); if (continuation != (void (*)()) 0) { (void) spl0(); @@ -658,6 +659,7 @@ boolean_t thread_invoke( new_thread->state &= ~(TH_SWAPPED | TH_UNINT); thread_unlock(new_thread); + thread_wakeup(&new_thread->state); #if NCPUS > 1 new_thread->last_processor = current_processor(); @@ -787,6 +789,7 @@ boolean_t thread_invoke( new_thread->state &= ~(TH_SWAPPED | TH_UNINT); thread_unlock(new_thread); + thread_wakeup(&new_thread->state); /* * Thread is now interruptible. -- cgit v1.2.3