Question

In: Computer Science

Briefly explain the deadlock situation that can occur in the dining philosophers and how we could...

Briefly explain the deadlock situation that can occur in the dining philosophers and how we could resolve the problem.

Solutions

Expert Solution

In Dining Philosphers Problem , there are 5 philosphers sitting around a circle and they only have 5 forks to eat which are placed on right and left of each philospher. A philospher has to use 2 forks to eat. Pphilospher thinks and eats alternatively. So we have to solve when a philospher can eat ie. when the forks are available. So we solve this problem , using semaphores which are binary variables. So when a philospher has to eat, he takes left fork first and then takes up the right fork and eats .After eating , he places forks back. If a philospher is not getting a fork ie. when some other philospher has taken that fork, then he waits for the availability of fork.

Deadlock Situation:-

Now suppose all the philosphers have picked their left fork , so right forks are not available to any of them and they starts waiting for the fork. This will create a deadlock situation ie everyone is waiting for the fork on right.

To solve this problem we change the sequence of picking up fork for one of the philospher. We change it for one of the philospher that he will pick up the right fork first and the left fork. So this situation will never go on deadlock as if 4 has taken up their left fork 1st and the 5th won't able to take up the fork to his right as its already taken. So the fork on his left will be available to another philospher. Thus there will be no deadlock.


Related Solutions

ExpIain how can deadlock prevention and avoidance be applied to solve the Five Philosophers Problem. (b)...
ExpIain how can deadlock prevention and avoidance be applied to solve the Five Philosophers Problem. (b) What are the differences between deadlock and starvation? Explain.
ExpIain how can deadlock prevention and avoidance be applied to solve the Five Philosophers Problem. (b)...
ExpIain how can deadlock prevention and avoidance be applied to solve the Five Philosophers Problem. (b) What are the differences between deadlock and starvation? Explain.
Operating Systems: We have learned two methods for the Dining Philosophers Problem. Can you come up...
Operating Systems: We have learned two methods for the Dining Philosophers Problem. Can you come up with other solutions? Make sure your solution works. Wrong solution does not count. (20 points)
Explain negative amortization and how such a situation can occur. explain in atleast 300 words.
Explain negative amortization and how such a situation can occur. explain in atleast 300 words.
Explain negative amortization and how such a situation can occur. D) In creating a plan to...
Explain negative amortization and how such a situation can occur. D) In creating a plan to buy your life insurance, what factors should you consider before buying? Also, describe from whom you should buy, including the sources.
explain how photosynthesis can occur without the production of oxygen, and how respiration can occur without...
explain how photosynthesis can occur without the production of oxygen, and how respiration can occur without requiring oxygen
How and when does sex differentiation occur prenatally? What changes can occur inutero that could lead...
How and when does sex differentiation occur prenatally? What changes can occur inutero that could lead a child to experience gender dysphoria and/or gender non-conforming behavior? Do you agree with the biological perspective of gender development/sexual orientation?
How can you apply the Bill of Rights to mordern situation that the founders could not...
How can you apply the Bill of Rights to mordern situation that the founders could not have considered ?
How can you apply the Bill of Rights to mordern situation that the founders could not...
How can you apply the Bill of Rights to mordern situation that the founders could not have considered ?
1. Briefly explain how we can use the production possibilities frontier (PPF) to explain economic growth .
1. Briefly explain how we can use the production possibilities frontier (PPF) to explain economic growth . 2. Eunhee works at a bank and receives $30,000 a year as her annual salary. She decided to quit this job and study at a graduate school for 2 years. If she gets admitted to the school, her annual cost of attending school will be the tuition of $9,000
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT