diff options
author | jasone <jasone@FreeBSD.org> | 2000-06-14 17:17:41 +0000 |
---|---|---|
committer | jasone <jasone@FreeBSD.org> | 2000-06-14 17:17:41 +0000 |
commit | 9f479e9f39861a77981b3e6234e796caa25cfe0f (patch) | |
tree | 25b4c819ee7794359e6c426e91cd15c2c56a2f49 /lib/libkse/thread/thr_suspend_np.c | |
parent | cc22f14b179a55f7686e798febd938bfef76c982 (diff) | |
download | FreeBSD-src-9f479e9f39861a77981b3e6234e796caa25cfe0f.zip FreeBSD-src-9f479e9f39861a77981b3e6234e796caa25cfe0f.tar.gz |
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
Diffstat (limited to 'lib/libkse/thread/thr_suspend_np.c')
-rw-r--r-- | lib/libkse/thread/thr_suspend_np.c | 14 |
1 files changed, 12 insertions, 2 deletions
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__); } |