Question

Recently I read this Wikipedia article regarding the Dining Philosophers problem but I am not clear with Chandy / Misra solution.

According to the article, "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." In the context of this question, he passes it if he is eating and keeps it if he has not started eating yet.

According to the scenario, What is the meaning of Dirty? Thread is running or it has yeilded?

Was it helpful?

Solution

Dirty means that processing has started so it can be interrupted.

And you can only process if you have two forks.

OTHER TIPS

Dirty seems to mean 'idle' or 'was available', and clean means 'had to request it' or 'preempted it'.

It says that a fork is 'dirty' if he picked it up (the fork wasn't contended when he wanted it), and 'clean' if he had to request it, and that its initial state is dirty.

  • Pick up an available fork => fork is dirty => clean it and give it up when asked.

  • No available fork => have to ask for it => will receive it cleaned.

It reminds me of the Organizational Pattern called Don't Interrupt an Interrupt.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top