Please post a small example. How are you using pthread_cond_wait()? Try
something like this:
ret = pthread_mutex_lock(&m);
if (ret != 0) {
fprintf(stderr, "lock failed: %d\n", ret);
abort();
}
while (condition == 0) {
ret = pthread_cond_wait(&c, &m);
if (ret != 0) {
fprintf(stderr, "wait failed: %d\n", ret);
abort();
}
}
...
ret = pthread_mutex_unlock(&m);
if (ret != 0) {
fprintf(stderr, "unlock failed: %d\n", ret);
abort();
}
How are the mutexes and conditions initialized? If you attach in gdb,
where is it spinning? This could be due to memory corruption, where one
of the internal pthread spin locks has been set and will never unlock.
matt.
On Tuesday, March 26, 2002, at 04:00 PM, Conrad G T Yoder wrote:
I am porting a (hairy) Solaris app to OS X which makes heavy use of the
pthread libraries (blocking, unblocking, cond vars, mutexes, etc.).
When
I try to have the main thread sleep somehow (I have tried sleep(),
sem_wait(),
pthread_cond_wait()) after spawning and starting all the other pthreads,
the program just pegs the CPU when the main thread gets to this call.
Is there something in the pthread libs which might not yet be complete
which would cause something like this? Is this a matter of setting
priorities correctly? Any other bells going off because of this
behavior?
TIA.
-Conrad
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.
_______________________________________________
unix-porting mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/unix-porting
Do not post admin requests to the list. They will be ignored.