IPhone -Pthread Status Signal Does Not Unblock Pending Thread

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;  //Reset outstanding signals
  pthread_mutex_unlock(&mutex);

 // process data
}

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?

+3
source share
1 answer

Have you reached the end or found a job? I think I have a similar problem with hanging on pthread_cond_wait on an iPhone device.

iOS, iPhone. , .

, pthread_cond_wait .

iPhone:

libsystem_c.dylib'pthread_cond_wait

iOS Simulator:

libsystem_c.dylib'pthread_cond_wait $UNIX2003

0

All Articles