Is anybody else having problems with Barriers when using Linux kernel
2.6 and the new posix thread library in recent libc? I just get a
deadlock with both threads waiting on the same barrier.
I have attached a test program.
--
Michael Babcock
Jim Henson's Creature Shop
#include <OpenSG/OSGThread.h>
#include <OpenSG/OSGBarrier.h>
#include <OpenSG/OSGBaseFunctions.h>
#include <iostream>
using namespace std;
osg::Thread * thread1 = 0;
osg::Thread * thread2 = 0;
osg::Barrier * barrier = 0;
void thread1_fn (void*) {
int count = 0;
while (true) {
barrier->enter(2);
cout << "thread1\t" << count++ << endl;
}
}
void thread2_fn (void*) {
int count = 0;
while (true) {
barrier->enter(2);
cout << "thread2\t" << count++ << endl;
}
}
int main (int argc, char **argv) {
osg::osgInit(argc, argv);
barrier = osg::Barrier::get("Barrier");
thread1 = osg::Thread::get("Thread1");
thread2 = osg::Thread::get("Thread2");
thread1->runFunction(thread1_fn, 0, 0);
thread2->runFunction(thread2_fn, 0, 0);
osg::Thread::join(thread1);
osg::Thread::join(thread2);
}