The robust mutex attribute

Glancing at the preceding table, one spies the robustness column; what does it mean? Recall that only the owner thread of a mutex lock can possibly unlock the mutex; now, we ask, what if, by some chance, the owner thread dies? (Well, firstly, good design will ensure this never happens; secondly, even if it does, there are ways to protect against thread cancellation, a topic we will cover in the next chapter.) On the face of it, there is no help for it; any other threads waiting on the lock will now just deadlock (effectively, they will just hang). This behavior is in fact the default; it's also the behavior that's set up by the robust attribute known as PTHREAD_MUTEX_STALLED. To the (possible) rescue in such a situation, ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.