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/libpthread/thread/thr_private.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/libpthread/thread/thr_private.h') diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h index a86cfc6..6b48f23 100644 --- a/lib/libpthread/thread/thr_private.h +++ b/lib/libpthread/thread/thr_private.h @@ -350,6 +350,17 @@ struct pthread_attr { #define PTHREAD_CREATE_SUSPENDED 1 /* + * Additional state for a thread suspended with pthread_suspend_np(). + */ +enum pthread_susp { + SUSP_NO, /* Not suspended. */ + SUSP_YES, /* Suspended. */ + SUSP_NOWAIT, /* Suspended, was in a mutex or condition queue. */ + SUSP_MUTEX_WAIT,/* Suspended, still in a mutex queue. */ + SUSP_COND_WAIT /* Suspended, still in a condition queue. */ +}; + +/* * Miscellaneous definitions. */ #define PTHREAD_STACK_DEFAULT 65536 @@ -577,7 +588,7 @@ struct pthread { #define PTHREAD_CANCEL_NEEDED 0x0010 int cancelflags; - int suspended; + enum pthread_susp suspended; thread_continuation_t continuation; -- cgit v1.1