# Chandy/Misra dining philosophers solution

So based on the Chandy/Misra section in this Wikipedia article we've got 5 philosophers numbered P1-P5.

Based on this quote:

For every pair of philosophers contending for a resource, create a fork and give it to the philosopher with the lower ID (n for agent Pn). Each fork can either be dirty or clean. Initially, all forks are dirty

When a philosopher with a fork receives a request message, he keeps the fork if it is clean, but gives it up when it is dirty. If he sends the fork over, he cleans the fork before doing so.

So with the knowledge that all forks are initially dirty, regard the following quote and the image underneath it.

For every pair of Swansons, give the fork to the guy with the smaller id.

My question is if P3 now requests a second fork from his neighbor P4, will P4 give up his single fork beacause it was dirty, even though he just picked it up?

• This question could use some editing to make it more self-contained. I would guess that most people aren't familiar with the Chandy-Misra solution to the dining philosophers problem and I'm confident that pretty much nobody is familiar with the blog post you link. So I had to read two large sections of webpage before I could even figure out what you were asking about. – David Richerby May 13 '15 at 10:01
• I don't know what else I could add. The wikipedia article should be sufficient to understand how the solution works. The second link was essentially there to provide an illustration so that it's clearer. – Omar Sharaki May 13 '15 at 10:05
• The diagrams in the blog post are incorrect. The protocol requires one fork for each pair of philosophers contending for a resource. The blog has the food in the centre of the table, suggesting that every pair of philosophers is in contention for every resource. This means there should be $\tfrac12n(n+1)=10$ forks, not 5. – David Richerby May 13 '15 at 10:06
• You could add a brief description of the Chanda-Misra solution to the question, to make your question self-contained (and link directly to the relevant section of the Wikipedia article). I actually think the blog post is a very bad illustration, as you can see from the comment I posted a moment ago (but before I read your comment). – David Richerby May 13 '15 at 10:07
• I think the position of the food is irrelevant. The resource that they want to access is that they "want to eat" so they need 2 forks to do that, which means they are competing for the forks not the food. In other words the critical section is the forks. – Omar Sharaki May 13 '15 at 10:29