I can't seem to get netbeans to recognize the pthread_barrier_t type. I can type in #include<pthread.h> okay, but no luck on pthread_barrier_t.
The following is the build and the error:
g++ -lpthread -c -g -MMD -MP -MF build/Debug/GNU-MacOSX/main.o.d -o build/Debug/GNU-MacOSX/main.o main.cpp main.cpp:32: error: 'pthread_barrier_t' does not name a type
I am using Netbeans 7.1 and I am on Mac OSX 10.7.2 I can create threads without any compile issues.
bool isNotInSteadyState()
{
int rc = 0;
threadData threadDataArray[NUM_THREADS];
int dataArrayCount = 0;
if (NUM_THREADS < ((PLATE_SIZE - 2) * (PLATE_SIZE - 2)))
{
for (int i = 1; i < PLATE_SIZE - 1; i += sqrt(NUM_THREADS))
{
for (int j = 1; j < PLATE_SIZE - 1; j += sqrt(NUM_THREADS))
{
threadDataArray[dataArrayCount].endY = i + sqrt(NUM_THREADS) - 1;
threadDataArray[dataArrayCount].x = i;
threadDataArray[dataArrayCount].endY = j + sqrt(NUM_THREADS) - 1;
threadDataArray[dataArrayCount++].y = j;
pthread_t* thread;
int pthread_create(thread, NULL,isNotInSteadyStateCheckRunInParallel, &threadDataArray[dataArrayCount]);
if (dataArrayCount >= NUM_THREADS)
{
//pthread_barrier_init(pthread_barrier_t * barrier,
//const pthread_barrierattr_t *restrict attr, NUM+THREADS);
}
if (rc != 0)
{
fprintf(stderr, "Steady State check failed!\n");
}
}
}
}
}
Thoughts?
Thanks,
According to info about pthread_barriers on opengroup.org, barriers are defined in the optional part of POSIX 1003.1 edition 2004; the name of option is "(ADVANCED REALTIME THREADS)", sometimes more exact referred as "BAR, barriers (real-time)".
All POSIX options are listed here
2.1.3 POSIX Conformance
POSIX System Interfaces
The system may support one or more options (see Options) denoted by the following symbolic constants:
_POSIX_BARRIERS
So, only if the _POSIX_BARRIERS macro is defined as positive number, you can use pthread_barrier_t or pthrad_barrier_wait.
Mac OS X is POSIX Compliant, but I can't find full list of options implemented. I know that Solaris has problems with pthread_barrier too. There is a post in apple mainling list from 2006. It says that there are no barriers in Mac OS X
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With