From f17d0128796f76027851590299f1f43e48ec71b6 Mon Sep 17 00:00:00 2001 From: rpj Date: Wed, 15 Sep 1999 01:11:56 +0000 Subject: Sep 15 1999 Ross Johnson * rwlock5.c: New test. --- tests/ChangeLog | 1 + tests/runall.bat | 1 + tests/rwlock3.c | 2 +- tests/rwlock4.c | 2 +- tests/rwlock5.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tests/rwlock5.c (limited to 'tests') 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 * rwlock2.c: New test. * rwlock3.c: New test. * rwlock4.c: New test. + * rwlock5.c: New test. Aug 22 1999 Ross Johnson 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; +} -- cgit v1.2.3