From 192816ba99360385792625b8baff5f9597724b5a Mon Sep 17 00:00:00 2001 From: bje Date: Tue, 6 Oct 1998 01:25:34 +0000 Subject: 1998-10-06 Ben Elliston * condvar.c (cond_wait): Use POSIX, not Win32 mutex calls. (pthread_cond_broadcast): Likewise. (pthread_cond_signal): Likewise. --- ChangeLog | 6 ++++++ condvar.c | 16 ++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 966a130..51b81cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +1998-10-06 Ben Elliston + + * condvar.c (cond_wait): Use POSIX, not Win32 mutex calls. + (pthread_cond_broadcast): Likewise. + (pthread_cond_signal): Likewise. + 1998-10-05 Ben Elliston * pthread.def: Update. Some functions aren't available yet, others diff --git a/condvar.c b/condvar.c index 2615756..2b78b55 100644 --- a/condvar.c +++ b/condvar.c @@ -85,9 +85,9 @@ cond_wait(pthread_cond_t *cv, pthread_mutex_t *mutex, DWORD abstime) pthread_testcancel(); /* Avoid race conditions. */ - EnterCriticalSection (&cv->waiters_count_lock); + pthread_mutex_lock(&cv->waiters_count_lock); cv->waiters_count++; - LeaveCriticalSection (&cv->waiters_count_lock); + pthread_mutex_unlock(&cv->waiters_count_lock); /* It's okay to release the mutex here since Win32 manual-reset events maintain state when used with SetEvent(). This avoids the @@ -101,10 +101,10 @@ cond_wait(pthread_cond_t *cv, pthread_mutex_t *mutex, DWORD abstime) result = WaitForMultipleObjects (2, cv->events, FALSE, abstime); - EnterCriticalSection (&cv->waiters_count_lock); + pthread_mutex_lock (&cv->waiters_count_lock); cv->waiters_count--; last_waiter = cv->waiters_count == 0; - LeaveCriticalSection (&cv->waiters_count_lock); + pthread_mutex_unlock (&cv->waiters_count_lock); /* Some thread called pthread_cond_broadcast(). */ if ((result = WAIT_OBJECT_0 + BROADCAST) && last_waiter) @@ -158,9 +158,9 @@ pthread_cond_broadcast (pthread_cond_t *cv) } /* Avoid race conditions. */ - EnterCriticalSection (&cv->waiters_count_lock); + pthread_mutex_lock (&cv->waiters_count_lock); have_waiters = (cv->waiters_count > 0); - LeaveCriticalSection (&cv->waiters_count_lock); + pthread_mutex_unlock (&cv->waiters_count_lock); if (have_waiters) { SetEvent(cv->events[BROADCAST]); @@ -181,9 +181,9 @@ pthread_cond_signal (pthread_cond_t *cv) } /* Avoid race conditions. */ - EnterCriticalSection (&cv->waiters_count_lock); + pthread_mutex_lock (&cv->waiters_count_lock); have_waiters = (cv->waiters_count > 0); - LeaveCriticalSection (&cv->waiters_count_lock); + pthread_mutex_unlock (&cv->waiters_count_lock); if (have_waiters) { SetEvent(cv->events[SIGNAL]); -- cgit v1.2.3