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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access