summaryrefslogtreecommitdiff
path: root/tests/detach1.c
diff options
context:
space:
mode:
authorrpj <rpj>2005-05-18 14:35:16 +0000
committerrpj <rpj>2005-05-18 14:35:16 +0000
commit2f7259b53b446762a1178150b0762c734b85c206 (patch)
tree517e8077e3f4689d2ac331d7000757994cebfd2b /tests/detach1.c
parent2531397c796d14f5fb934ae3fcf3c5327bd41bc9 (diff)
''
Diffstat (limited to 'tests/detach1.c')
-rw-r--r--tests/detach1.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/detach1.c b/tests/detach1.c
index b0835c5..165c8c1 100644
--- a/tests/detach1.c
+++ b/tests/detach1.c
@@ -38,12 +38,17 @@
#include "test.h"
+
+enum {
+ NUMTHREADS = 100
+};
+
void *
func(void * arg)
{
int i = (int) arg;
- Sleep(i * 100);
+ Sleep(i * 10);
pthread_exit(arg);
@@ -54,31 +59,31 @@ func(void * arg)
int
main(int argc, char * argv[])
{
- pthread_t id[4];
+ pthread_t id[NUMTHREADS];
int i;
/* Create a few threads and then exit. */
- for (i = 0; i < 4; i++)
+ for (i = 0; i < NUMTHREADS; i++)
{
assert(pthread_create(&id[i], NULL, func, (void *) i) == 0);
}
/* Some threads will finish before they are detached, some after. */
- Sleep(2 * 100 + 50);
+ Sleep(NUMTHREADS/2 * 10 + 50);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < NUMTHREADS; i++)
{
assert(pthread_detach(id[i]) == 0);
}
- Sleep(6 * 100);
+ Sleep(NUMTHREADS * 10 + 100);
/*
* Check that all threads are now invalid.
* This relies on unique thread IDs - e.g. works with
* pthreads-w32 or Solaris, but may not work for Linux, BSD etc.
*/
- for (i = 0; i < 4; i++)
+ for (i = 0; i < NUMTHREADS; i++)
{
assert(pthread_kill(id[i], 0) == ESRCH);
}