Self deadlock (relock)
Knowing the aforementioned information, visualize this scenario: there is one lock (we just call it L1) and three threads in competition for it (let's just call them threads A, B, and C); let's say thread B is the winner. That's fine, but what happens if thread B, within its critical section, again attempts to take the same lock, L1? Well, think about it: lock L1 is currently in the locked state, thus forcing thread B to block (wait) upon it getting unlocked. However, no thread but thread B itself can possibly perform the unlock operation, so thread B will end up waiting forever! There we have it: deadlock. This type of deadlock is termed the self deadlock, or the relock error.
One might argue, and indeed the case does ...
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