From 5b826fe110d9cde198d2aae27e144ac635ad921f Mon Sep 17 00:00:00 2001 From: rpj Date: Sun, 3 Jun 2001 16:41:27 +0000 Subject: pthreads: 2001-06-03 Ross Johnson Contributed by - Alexander Terekhov - Louis Thomas * condvar.c (pthread_cond_init): Completely revamped. (pthread_cond_destroy): Likewise. (ptw32_cond_wait_cleanup): Likewise. (ptw32_cond_timedwait): Likewise. (ptw32_cond_unblock): New general signaling routine. (pthread_cond_signal): Now calls ptw32_cond_unblock. (pthread_cond_broadcast): Likewise. * implement.h (pthread_cond_t_): Revamped. * README.CV: New; explanation of the above changes. pthreads/tests: 2001-06-3 Ross Johnson * condvar2_1.c: New test. * condvar3_1.c: New test. * condvar3_2.c: New test. --- implement.h | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'implement.h') diff --git a/implement.h b/implement.h index fa02444..1b57b60 100644 --- a/implement.h +++ b/implement.h @@ -27,10 +27,14 @@ #ifndef _IMPLEMENT_H #define _IMPLEMENT_H -#if defined(__MINGW32__) +#if !defined(malloc) #include #endif +#if !defined(INT_MAX) +#include +#endif + /* changed include from to use local file during development */ #include "semaphore.h" @@ -153,18 +157,18 @@ struct ThreadParms { struct pthread_cond_t_ { - long waiters; /* # waiting threads */ - pthread_mutex_t waitersLock; /* Mutex that guards access to - waiter count */ - sem_t sema; /* Queue up threads waiting for the - condition to become signaled */ - HANDLE waitersDone; /* An auto reset event used by the - broadcast/signal thread to wait - for the waiting thread(s) to wake - up and get a chance at the - semaphore */ - int wasBroadcast; /* keeps track if we are signaling - or broadcasting */ + long nWaitersBlocked; /* Number of threads blocked */ + long nWaitersGone; /* Number of threads timed out */ + long nWaitersUnblocked; /* Number of threads unblocked */ + long nWaitersToUnblock; /* Number of threads to unblock */ + sem_t semBlockQueue; /* Queue up threads waiting for the */ + /* condition to become signalled */ + sem_t semBlockLock; /* Semaphore that guards access to */ + /* | waiters blocked count/block queue */ + /* +-> Mandatory Sync.LEVEL-1 */ + pthread_mutex_t mtxUnblockLock; /* Mutex that guards access to */ + /* | waiters (to)unblock(ed) counts */ + /* +-> Optional* Sync.LEVEL-2 */ }; -- cgit v1.2.3