From: Bart Van Assche Date: Fri, 12 Aug 2011 15:21:31 +0000 (+0000) Subject: drd/tests/pth_barrier: Reduce stack usage X-Git-Tag: svn/VALGRIND_3_7_0~269 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6b3e4178d612b2292e6aa61007bba431ca35617;p=thirdparty%2Fvalgrind.git drd/tests/pth_barrier: Reduce stack usage git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11968 --- diff --git a/drd/tests/pth_barrier.c b/drd/tests/pth_barrier.c index 7bca33a5b6..0aea190289 100644 --- a/drd/tests/pth_barrier.c +++ b/drd/tests/pth_barrier.c @@ -10,11 +10,11 @@ /***********************/ #include +#include #include #include #include #include -#include /*********************/ @@ -65,7 +65,8 @@ static void* threadfunc(struct threadinfo* p) /** Actual test, consisting of nthread threads. */ static void barriers_and_races(const int nthread, const int iterations) { - int i; + int i, res; + pthread_attr_t attr; struct threadinfo* t; pthread_barrier_t b; int* array; @@ -78,18 +79,25 @@ static void barriers_and_races(const int nthread, const int iterations) pthread_barrier_init(&b, 0, nthread); + pthread_attr_init(&attr); + res = pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + 4096); + assert(res == 0); + for (i = 0; i < nthread; i++) { t[i].b = &b; t[i].array = array; t[i].iterations = iterations; - if (pthread_create(&t[i].tid, 0, (void*(*)(void*))threadfunc, &t[i])) { + res = pthread_create(&t[i].tid, &attr, (void*(*)(void*))threadfunc, &t[i]); + if (res != 0) { fprintf(stderr, "Could not create thread #%d (of %d): %s\n", - i, nthread, strerror(errno)); + i, nthread, strerror(res)); exit(1); } } + pthread_attr_destroy(&attr); + for (i = 0; i < nthread; i++) { pthread_join(t[i].tid, 0);