Pick up their lower numbered fork only the highest

This preview shows page 3 - 5 out of 7 pages.

pick up their lower-numbered fork, only the highest-numbered fork will remain on the table, sothe fifth philosopher will not be able to pick up any fork. Moreover, only one philosopher willhave access to that highest-numbered fork, so they will be able to eat using two forks. While theresource hierarchy solution avoids deadlocks, it is not always practical, especially when the listof required resources is not completely known in advance.Arbitrator solutionAnother approach is to guarantee that a philosopher can only pick up both forks or none byintroducing an arbitrator, e.g., a waiter. In order to pick up the forks, a philosopher must askpermission of the waiter. The waiter gives permission to only one philosopher at a time until thephilosopher has picked up both of their forks. Putting down a fork is always allowed. In additionto introducing a new central entity (the waiter), this approach can result in reduced parallelism: ifa philosopher is eating and one of their neighbors is requesting the forks, all other philosophersmust wait until this request has been fulfilled even if forks for them are still available.Chandy/Misra solutionIn 1984,K. Mani Chandyand J. Misraproposed a different solution to the dining philosopher’sproblem to allow for arbitrary agents (numberedP1...Pn) to contend for an arbitrary number ofresources, unlike Dijkstra's solution. It is also completely distributed and requires no centralauthority after initialization. However, it violates the requirement that "the philosophers do notspeak to each other" (due to the request messages).1.For every pair of philosophers contending for a resource, create a fork and give it to thephilosopher with the lower ID (nfor agentPn). Each fork can either bedirtyorclean.Initially, all forks are dirty.2.When a philosopher wants to use a set of resources (i.e.eat), said philosopher must obtainthe forks from their contending neighbors. For all such forks the philosopher does nothave, they send a request message.3.When a philosopher with a fork receives a request message, they keep the fork if it isclean, but give it up when it is dirty. If the philosopher sends the fork over, they clean thefork before doing so.4.After a philosopher is done eating, all their forks become dirty. If another philosopher hadpreviously requested one of the forks, the philosopher that has just finished eating cleansthe fork and sends it.
This solution also allows for a large degree of concurrency, and will solve an arbitrarily largeproblem. It also solves the starvation problem. The clean / dirty labels act as a way of givingpreference to the most "starved" processes, and a disadvantage to processes that have just"eaten". One could compare their solution to one where philosophers are not allowed to eat twicein a row without letting others use the forks in between. Chandy and Misra's solution is moreflexible than that, but has an element tending in that direction.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 7 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
DR.Morara
Tags
Operating Systems, Virtual memory, Edsger Dijkstra

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture