summaryrefslogtreecommitdiff
path: root/condvar.c
diff options
context:
space:
mode:
authorbje <bje>1998-10-06 01:25:34 +0000
committerbje <bje>1998-10-06 01:25:34 +0000
commit192816ba99360385792625b8baff5f9597724b5a (patch)
treea0892729af5690e65a601d184c9ba22c77cb5877 /condvar.c
parent498a7979aa94b4cf8c93c5e0634a527a234a2839 (diff)
1998-10-06 Ben Elliston <bje@cygnus.com>
* condvar.c (cond_wait): Use POSIX, not Win32 mutex calls. (pthread_cond_broadcast): Likewise. (pthread_cond_signal): Likewise.
Diffstat (limited to 'condvar.c')
-rw-r--r--condvar.c16
1 files changed, 8 insertions, 8 deletions
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]);