This answer claims there is no guarantee that pthread_mutex_lock
ever returns, even if no deadlock occurs, and likewise there is no guarantee that pthread_cond_wait
ever returns, even if the condition variable is signalled by another thread. Worse, this answer claims that the chance that these functions never return is realistic and not purely theoretical.
Now I’m sorry to post a question that questions an answer I was already given. But tbh I find this pretty strange. If this is the state of affairs, then this whole interface would seem pretty much unusable for me, as there seems to be no way for the programmer to prevent the application from freezing, even if the code is free of bugs!
Can it really happen that phread_mutex_lock
never returns even if no deadlock occurs? Can it really happen that pthread_cond_wait
never returns even if the condition variable is signalled? If so, how to prevent the app from sudden freezes?