I'm using a pthread_barrier_t
from C/C++ on my code to synchronize 3 different threads. When I'm using the Debug, through gdb, it works just fine, but when I run the binary directly from the board, all 3 threads get stuck on the pthread_barrier_wait
. It seems that the barrier can't see that all of the 3 threads are there.
I'm cross-compiling the code to ARM using Ubuntu 14.10, with g++4.9, arm-linux-gnueabihf. The board is a BBB similar with TI AM3352 and Debian 8.
the code is thread 1
case stRecv :
pthread_barrier_wait(&IonEntCommBarrier[client]);
if(IonFillAnswer[client])
state = stSend;
else
state = stStop;
break;
thread 2
case stRecv :
pthread_barrier_wait(&IonEntCommBarrier[client]);
if(IonFillAnswer[client])
state = stSend;
else
state = stStop;
break;
thread 3
case stRecv :
IonEntCommData[client].RequestLen = Recv(client, EthernetObj->getRXBufAddr(client));
IonFillAnswer[client] = false;
if(IonEntCommData[client].RequestLen > 1) {
IonFillAnswer[client] = true;
state = stSend; // Msg Ok!
} else {
EthernetObj->setEthernetFlag(client, ETH_START);
}
if(IonEntCommData[client].RequestLen <= 1) break;
IonEntToutTSyssec[client] = TIMEOUT_S_ION; // Timer zerado
pthread_barrier_wait(&IonEntCommBarrier[client]);
break;
i`m initializing the barrier using
pthread_barrier_init(&IonEntCommBarrier[client],NULL,3);
Anyone knows what its going on here?
PS: Other functions of the same library are working well, like pthread_mutex, just the barrier doesn't.