From 9f479e9f39861a77981b3e6234e796caa25cfe0f Mon Sep 17 00:00:00 2001 From: jasone Date: Wed, 14 Jun 2000 17:17:41 +0000 Subject: pthread_mutex_lock(), pthread_cond_trywait(), and pthread_cond_wait() are not allowed to return EINTR, but use of pthread_suspend_np() could cause EINTR to be returned. To fix this, restructure pthread_suspend_np() so that it does not interrupt a thread that is waiting on a mutex or condition, and keep enough state around that pthread_resume_np() can fix things up afterwards. Reviewed by: deischen --- lib/libkse/thread/thr_suspend_np.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/libkse/thread/thr_suspend_np.c') diff --git a/lib/libkse/thread/thr_suspend_np.c b/lib/libkse/thread/thr_suspend_np.c index 9b08115..083f552 100644 --- a/lib/libkse/thread/thr_suspend_np.c +++ b/lib/libkse/thread/thr_suspend_np.c @@ -91,13 +91,23 @@ pthread_suspend_np(pthread_t thread) break; case PS_MUTEX_WAIT: + /* Mark the thread as suspended and still in a queue. */ + thread->suspended = SUSP_MUTEX_WAIT; + + PTHREAD_SET_STATE(thread, PS_SUSPENDED); + break; case PS_COND_WAIT: + /* Mark the thread as suspended and still in a queue. */ + thread->suspended = SUSP_COND_WAIT; + + PTHREAD_SET_STATE(thread, PS_SUSPENDED); + break; case PS_FDLR_WAIT: case PS_FDLW_WAIT: case PS_FILE_WAIT: case PS_JOIN: /* Mark the thread as suspended: */ - thread->suspended = 1; + thread->suspended = SUSP_YES; /* * Threads in these states may be in queues. @@ -134,7 +144,7 @@ pthread_suspend_np(pthread_t thread) static void finish_suspension(void *arg) { - if (_thread_run->suspended != 0) + if (_thread_run->suspended != SUSP_NO) _thread_kern_sched_state(PS_SUSPENDED, __FILE__, __LINE__); } -- cgit v1.1