summaryrefslogtreecommitdiff
path: root/tests/count1.c
diff options
context:
space:
mode:
authorrpj <rpj>1999-03-14 05:29:18 +0000
committerrpj <rpj>1999-03-14 05:29:18 +0000
commitf8af93c39f8deebc46aee1b25be9d5c40035d0d8 (patch)
tree6874f918fe82259682384ccfd2539cf62e6cd217 /tests/count1.c
parentc181e5bb2ccf9d351553eaadf66578df441024a6 (diff)
Mon Mar 15 00:20:13 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au>snap-1999-03-15
* condvar.c (pthread_cond_init): fix possible uninitialised use of cv. Sun Mar 14 21:01:59 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * condvar.c (pthread_cond_destroy): don't do full cleanup if static initialised cv has never been used. (cond_timedwait): check result of auto-initialisation. tests/ChangeLog Mon Mar 15 00:17:55 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * mutex1.c: only test mutex init and destroy; add assertions. * count1.c: raise number of spawned threads to 60 (appears to be the limit under Win98). Sun Mar 14 21:31:02 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * test.h (assert): add assertion trace option. Use: "#define ASSERT_TRACE 1" to turn it on, "#define ASSERT_TRACE 0" to turn it off (default). * condvar3.c (main): add more assertions. * condvar4.c (main): add more assertions. * condvar1.c (main): add more assertions.
Diffstat (limited to 'tests/count1.c')
-rw-r--r--tests/count1.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/tests/count1.c b/tests/count1.c
index 61e82e0..9783fcc 100644
--- a/tests/count1.c
+++ b/tests/count1.c
@@ -1,17 +1,17 @@
/*
* count1.c
*
- * Written by Ben Elliston <bje@cygnus.com>.
- *
* Description:
* Test some basic assertions about the number of threads at runtime.
*/
#include "test.h"
+#define NUMTHREADS (60)
+
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_t threads[10];
-static unsigned numThreads = 1;
+static pthread_t threads[NUMTHREADS];
+static unsigned numThreads = 0;
void *
myfunc(void *arg)
@@ -30,9 +30,8 @@ main()
int maxThreads = sizeof(threads) / sizeof(pthread_t);
/*
- * Spawn ten threads. Each thread should increment the numThreads
- * variable, sleep for one second, decrement the variable and then
- * exit. The final result of numThreads should be 1 again.
+ * Spawn NUMTHREADS threads. Each thread should increment the
+ * numThreads variable, sleep for one second.
*/
for (i = 0; i < maxThreads; i++)
{
@@ -45,15 +44,12 @@ main()
for (i = 0; i < maxThreads; i++)
{
assert(pthread_join(threads[i], NULL) == 0);
- assert(pthread_mutex_lock(&lock) == 0);
- numThreads--;
- assert(pthread_mutex_unlock(&lock) == 0);
}
/*
- * Check the number of live threads.
+ * Check the number of threads created.
*/
- assert(numThreads == 1);
+ assert(numThreads == maxThreads);
/*
* Success.