diff options
Diffstat (limited to 'lib/libc_r/uthread/uthread_suspend_np.c')
-rw-r--r-- | lib/libc_r/uthread/uthread_suspend_np.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/libc_r/uthread/uthread_suspend_np.c b/lib/libc_r/uthread/uthread_suspend_np.c index 871683a..6a6eaf4 100644 --- a/lib/libc_r/uthread/uthread_suspend_np.c +++ b/lib/libc_r/uthread/uthread_suspend_np.c @@ -51,8 +51,21 @@ pthread_suspend_np(pthread_t thread) thread->interrupted = 1; } + /* + * Guard against preemption by a scheduling signal. + * A change of thread state modifies the waiting + * and priority queues. + */ + _thread_kern_sched_defer(); + /* Suspend the thread. */ PTHREAD_NEW_STATE(thread,PS_SUSPENDED); + + /* + * Reenable preemption and yield if a scheduling signal + * occurred while in the critical region. + */ + _thread_kern_sched_undefer(); } return(ret); } |