Provide some real-liv...
Provide some real-liv...
Livelock is a concurrency problem where two or more processes or threads continuously change their state in response to each other without making any progress. Here are some real-life examples of livelock:
A classic example of livelock is when two people meet in a narrow corridor and each tries to be polite by moving aside to let the other pass. They end up swaying from side to side without making any progress because they both repeatedly move the same way at the same time[2][9][8].
In a more illustrative example, imagine a husband and wife trying to eat soup but only have one spoon between them. Each spouse is too polite and will pass the spoon if the other has not yet eaten. As a result, they keep passing the spoon back and forth without either of them eating[10].
Consider two processes, A and B, that need to access two shared resources, X and Y. Process A holds resource X and needs resource Y, while process B holds resource Y and needs resource X. Both processes use a backoff strategy to avoid deadlock, releasing their held resource and retrying after a random delay. If they happen to choose the same backoff time repeatedly, they will keep retrying and failing to acquire the needed resources, resulting in a livelock[1][6][12].
Another real-world example is when two people try to call each other at the same time and both find the line busy. They both decide to hang up and attempt to call again after the same time interval. This can go on indefinitely, with neither party successfully making the call[11].
Imagine two cars approaching a narrow bridge from opposite directions. Both drivers decide to back up to let the other pass, ...
senior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào