summaryrefslogtreecommitdiff
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
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.
-rw-r--r--ChangeLog6
-rw-r--r--condvar.c16
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 <bje@cygnus.com>
+
+ * condvar.c (cond_wait): Use POSIX, not Win32 mutex calls.
+ (pthread_cond_broadcast): Likewise.
+ (pthread_cond_signal): Likewise.
+
1998-10-05 Ben Elliston <bje@cygnus.com>
* 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]);