Talk:Dining philosophers

Revision as of 13:07, 8 November 2008 by rosettacode>Dmitry-kazakov (Livelock in Phyton solution)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Phyton solution "If a philosopher acquires one fork but can't acquire the second, he releases the first fork before waiting to acquire the other (which then becomes the first fork acquired)."

Without some additional actions this solution is exposed to livelock. That is far less probable than deadlock, yet it may happen.

Livelock: all philosopher grab one fork. Then they see that another one is out of reach. They drop their forks one by one, and then start to grab other forks, in the same order. Under a scheduling policy that keeps philosophers to act in this order, this circle will repeat itself forever. Even if the circle gets actually broken, it is actually a sort of busy waiting, which is not good.

One possible solution to this could be to introduce some policy that would prevent the same fork from being dropped when it was once acquired through waiting, like in the dirty/clean forks solution --Dmitry-kazakov 13:07, 8 November 2008 (UTC)

Return to "Dining philosophers" page.