From ce75e095891d0e7855c5b4c94f24393cf7c2b610 Mon Sep 17 00:00:00 2001 From: David Leonard Date: Wed, 26 May 1999 00:18:27 +0000 Subject: sync with FreeBSD --- lib/libc_r/uthread/uthread_resume_np.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lib/libc_r/uthread/uthread_resume_np.c') diff --git a/lib/libc_r/uthread/uthread_resume_np.c b/lib/libc_r/uthread/uthread_resume_np.c index 6e211f34ece..e4be286bde6 100644 --- a/lib/libc_r/uthread/uthread_resume_np.c +++ b/lib/libc_r/uthread/uthread_resume_np.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: uthread_resume_np.c,v 1.2 1999/01/06 05:29:26 d Exp $ + * $OpenBSD: uthread_resume_np.c,v 1.3 1999/05/26 00:18:25 d Exp $ */ #include #ifdef _THREAD_SAFE @@ -46,8 +46,21 @@ pthread_resume_np(pthread_t thread) if ((ret = _find_thread(thread)) == 0) { /* The thread exists. Is it suspended? */ if (thread->state != PS_SUSPENDED) { + /* + * Guard against preemption by a scheduling signal. + * A change of thread state modifies the waiting + * and priority queues. + */ + _thread_kern_sched_defer(); + /* Allow the thread to run. */ PTHREAD_NEW_STATE(thread,PS_RUNNING); + + /* + * Reenable preemption and yield if a scheduling + * signal occurred while in the critical region. + */ + _thread_kern_sched_undefer(); } } return(ret); -- cgit v1.2.3