Hello to all,
During my long journey of porting a novel application on DCE I encountered the following strange behavior.
I managed to reduce the problem to a very simple binary :
#include <iostream>
#include <thread>
#include <cstdlib>
#include <pthread.h>
using namespace std;
#define NUM_THREADS 1
void *PrintHello(void *threadid) {
long tid;
tid = (long)threadid;
while(1) {
std::cout << "Hello from thread with id " << tid << std::flush;
}
pthread_exit(NULL);
}
int main () {
pthread_t threads[NUM_THREADS];
int rc;
int i;
cout << "main() : creating thread, " << i << endl;
rc = pthread_create(&threads[i], NULL, PrintHello, (void *)i);
if (rc){
cout << "Error:unable to create thread," << rc << endl;
exit(-1);
}
while(true) {
std::cout << "Hello from main!\n";
}
pthread_exit(NULL);
}
The DCE execution hangs, at the line 347 of pthread-fiber-manager.cc . In this line, a call to pthread_cond_wait (&fiber->thread->condvar, &fiber->thread->mutex) is performed.
The inline comments say " // and wait until the target thread completes.". However, the thread I create never ends it just loops and prints.
Is this the expected behavior of the DCE threading management? If yes, isn't that very limited?
Thanks,
Andreas Pantelopoulos