|
From: <sv...@va...> - 2011-08-12 15:12:00
|
Author: florian
Date: 2011-08-12 16:07:10 +0100 (Fri, 12 Aug 2011)
New Revision: 11967
Log:
Check return code of pthread_create and bail out if
the function failed. This helps on systems which don't
have lots of memory.
Suggested by Christian Borntraeger.
Modified:
trunk/drd/tests/pth_barrier.c
Modified: trunk/drd/tests/pth_barrier.c
===================================================================
--- trunk/drd/tests/pth_barrier.c 2011-08-11 17:00:15 UTC (rev 11966)
+++ trunk/drd/tests/pth_barrier.c 2011-08-12 15:07:10 UTC (rev 11967)
@@ -13,6 +13,8 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
/*********************/
@@ -81,7 +83,11 @@
t[i].b = &b;
t[i].array = array;
t[i].iterations = iterations;
- pthread_create(&t[i].tid, 0, (void*(*)(void*))threadfunc, &t[i]);
+ if (pthread_create(&t[i].tid, 0, (void*(*)(void*))threadfunc, &t[i])) {
+ fprintf(stderr, "Could not create thread #%d (of %d): %s\n",
+ i, nthread, strerror(errno));
+ exit(1);
+ }
}
for (i = 0; i < nthread; i++)
|