I have two threads that execute as follows. The code works fine on the iPhone simulator, but not on the device. On the iPhone (there is ios 5.1 running), thread A signals a status, but thread B waits indefinitely.
In stream A, when the data is ready for processing:
pthread_mutex_lock(&mutex);
outstandingSig++;
pthread_cond_signal(&condVar);
pthread_mutex_unlock(&mutex);
In stream B:
while(1)
{
pthread_mutex_lock(&mutex);
while(outstandingSig == 0)
{
pthread_cond_wait(&condVar, &mutex);
}
outstandingSig = 0;
pthread_mutex_unlock(&mutex);
}
Any suggestions why it behaves differently on the device? What could cause stream B to not consume a signal? And why the different behavior on the simulator and device?
source
share