diff options
-rw-r--r-- | tests/ChangeLog | 1 | ||||
-rw-r--r-- | tests/runall.bat | 1 | ||||
-rw-r--r-- | tests/rwlock3.c | 2 | ||||
-rw-r--r-- | tests/rwlock4.c | 2 | ||||
-rw-r--r-- | tests/rwlock5.c | 46 |
5 files changed, 50 insertions, 2 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 4ee832c..7150435 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -4,6 +4,7 @@ Sep 15 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * rwlock2.c: New test. * rwlock3.c: New test. * rwlock4.c: New test. + * rwlock5.c: New test. Aug 22 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> diff --git a/tests/runall.bat b/tests/runall.bat index 78a94b6..daa6c7b 100644 --- a/tests/runall.bat +++ b/tests/runall.bat @@ -29,3 +29,4 @@ call runtest cl rwlock1 call runtest cl rwlock2 call runtest cl rwlock3 call runtest cl rwlock4 +call runtest cl rwlock5 diff --git a/tests/rwlock3.c b/tests/rwlock3.c index 92e8286..3861447 100644 --- a/tests/rwlock3.c +++ b/tests/rwlock3.c @@ -1,7 +1,7 @@ /* * rwlock3.c * - * Declare a static rwlock object, lock it, trylock it, + * Declare a static rwlock object, wrlock it, trywrlock it, * and then unlock it again. * * Depends on API functions: diff --git a/tests/rwlock4.c b/tests/rwlock4.c index 07e4cff..8cae52e 100644 --- a/tests/rwlock4.c +++ b/tests/rwlock4.c @@ -1,5 +1,5 @@ /* - * rwlock3.c + * rwlock4.c * * Declare a static rwlock object, rdlock it, trywrlock it, * and then unlock it again. diff --git a/tests/rwlock5.c b/tests/rwlock5.c new file mode 100644 index 0000000..55a4f35 --- /dev/null +++ b/tests/rwlock5.c @@ -0,0 +1,46 @@ +/* + * rwlock5.c + * + * Declare a static rwlock object, rdlock it, tryrdlock it, + * and then unlock it again. + * + * Depends on API functions: + * pthread_rwlock_rdlock() + * pthread_rwlock_tryrdlock() + * pthread_rwlock_unlock() + */ + +#include "test.h" + +pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; + +static int washere = 0; + +void * func(void * arg) +{ + assert(pthread_rwlock_tryrdlock(&rwlock1) == 0); + + assert(pthread_rwlock_unlock(&rwlock1) == 0); + + washere = 1; + + return 0; +} + +int +main() +{ + pthread_t t; + + assert(pthread_rwlock_rdlock(&rwlock1) == 0); + + assert(pthread_create(&t, NULL, func, NULL) == 0); + + Sleep(2000); + + assert(pthread_rwlock_unlock(&rwlock1) == 0); + + assert(washere == 1); + + return 0; +} |