From 98c3b7810be7cc90496c01d13f078d7964f7dcde Mon Sep 17 00:00:00 2001 From: David Xu Date: Wed, 2 Jul 2003 14:12:37 +0000 Subject: [PATCH] Set unlock_mutex to 1 after locked mutex. Use THR_CONDQ_CLEAR not THR_COND_SET in cond_queue_deq, current cond_queue_deq is not used. --- lib/libkse/thread/thr_cond.c | 6 ++++-- lib/libpthread/thread/thr_cond.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/libkse/thread/thr_cond.c b/lib/libkse/thread/thr_cond.c index 59db00fc8dae..9e73c61c4ee4 100644 --- a/lib/libkse/thread/thr_cond.c +++ b/lib/libkse/thread/thr_cond.c @@ -539,8 +539,10 @@ _pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, /* The wait timedout. */ rval = ETIMEDOUT; (void)_mutex_cv_lock(mutex); - } else if (interrupted || done) + } else if (interrupted || done) { rval = _mutex_cv_lock(mutex); + unlock_mutex = 1; + } } } break; @@ -738,7 +740,7 @@ cond_queue_deq(pthread_cond_t cond) while ((pthread = TAILQ_FIRST(&cond->c_queue)) != NULL) { TAILQ_REMOVE(&cond->c_queue, pthread, sqe); - THR_CONDQ_SET(pthread); + THR_CONDQ_CLEAR(pthread); if ((pthread->timeout == 0) && (pthread->interrupted == 0)) /* * Only exit the loop when we find a thread diff --git a/lib/libpthread/thread/thr_cond.c b/lib/libpthread/thread/thr_cond.c index 59db00fc8dae..9e73c61c4ee4 100644 --- a/lib/libpthread/thread/thr_cond.c +++ b/lib/libpthread/thread/thr_cond.c @@ -539,8 +539,10 @@ _pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, /* The wait timedout. */ rval = ETIMEDOUT; (void)_mutex_cv_lock(mutex); - } else if (interrupted || done) + } else if (interrupted || done) { rval = _mutex_cv_lock(mutex); + unlock_mutex = 1; + } } } break; @@ -738,7 +740,7 @@ cond_queue_deq(pthread_cond_t cond) while ((pthread = TAILQ_FIRST(&cond->c_queue)) != NULL) { TAILQ_REMOVE(&cond->c_queue, pthread, sqe); - THR_CONDQ_SET(pthread); + THR_CONDQ_CLEAR(pthread); if ((pthread->timeout == 0) && (pthread->interrupted == 0)) /* * Only exit the loop when we find a thread