Similar Posts

Subscribe
Notify of
1 Answer
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Destranix
1 year ago

Not at all.

A life lock would be, for example:

 while(!tryConsumeBuf(&evProduced)){ yield(); } setEvent(&evConsumed); ______ while(!tryFillBuf(&evConsumed)){ yield(); } setEvent(&evProduced);

What's relevant here is that the state of the threads isn't static but is constantly changing. This doesn't happen often, but it can happen. It's ultimately the case when the deadlock condition is met, but code is still being executed (in this case, the yield or the loop itself).

A more complicated example would be a list. When inserting, the program attempts to find the end and insert the new element there. If that fails, the program tries to find the end again and inserts the element.
If another thread locks the last element (thereby preventing insertion) and then gets into a deadlock or stops running, then the thread attempting the insertion would be in a life lock (because it keeps trying to insert the element, but this doesn't work because the last element is locked).