From 9031537658e89136c6a5bb959f9b9a4338a5d056 Mon Sep 17 00:00:00 2001 From: rpj Date: Wed, 15 Sep 1999 00:56:21 +0000 Subject: Sat Sep 10 12:56:13 1999 Ross Johnson The following code for POSIX read/write locks was contributed by Aurelio Medina. * implement.h (pthread_rwlock_t_): Add. * pthread.h (pthread_rwlock_t): Add. (PTHREAD_RWLOCK_INITIALIZER): Add. Add rwlock function prototypes. * rwlock.c: New module. * pthread.def: Add new rwlock functions. * private.c (_pthread_processInitialize): initialise _pthread_rwlock_test_init_lock critical section. * global.c (_pthread_rwlock_test_init_lock): Add. * mutex.c (pthread_mutex_destroy): Don't free mutex memory if mutex is PTHREAD_MUTEX_INITIALIZER and has not been initialised yet. tests/ChangeLog Sep 15 1999 Ross Johnson * rwlock1.c: New test. * rwlock2.c: New test. * rwlock3.c: New test. * rwlock4.c: New test. --- implement.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'implement.h') diff --git a/implement.h b/implement.h index 11d5b1b..b48b2f2 100644 --- a/implement.h +++ b/implement.h @@ -161,6 +161,22 @@ struct pthread_condattr_t_ { int pshared; }; +#define RW_MAGIC 0x19283746 + +struct pthread_rwlock_t_ { + pthread_mutex_t rw_mutex; /* basic lock on this struct */ + pthread_cond_t rw_condreaders; /* for reader threads waiting */ + pthread_cond_t rw_condwriters; /* for writer threads waiting */ + int rw_magic; /* for error checking */ + int rw_nwaitreaders; /* the number waiting */ + int rw_nwaitwriters; /* the number waiting */ + int rw_refcount; /* -1 if writer has the lock, + else # readers holding the lock */ +}; + +struct pthread_rwlockattr_t_ { + int pshared; +}; struct ThreadKeyAssoc { /* @@ -297,6 +313,7 @@ extern pthread_key_t _pthread_selfThreadKey; extern pthread_key_t _pthread_cleanupKey; extern CRITICAL_SECTION _pthread_mutex_test_init_lock; extern CRITICAL_SECTION _pthread_cond_test_init_lock; +extern CRITICAL_SECTION _pthread_rwlock_test_init_lock; #ifdef __cplusplus -- cgit v1.2.3