Deadlock 3: Dining Philosophers
HTML-код
- Опубликовано: 7 авг 2016
- The Dining Philosophers problem is discussed, in which 5 philosopher processes compete for 5 fork resources in order to eat. An incorrect solution leading to deadlock is discussed, and then a simple fix based on a global ordering of resources is presented.
More english videos on youtube about OSs and I would be happy
Thank you so much, you have explained this problem very thoroughly
Thanks for these videos. I have been studying by reading a chapter in the Stallings book first and then watching the corresponding video(s) on your channel. I wish you had a video for every subject!
beautiful !
Thanks for the clear explanation!
Excellent explanation, thanks!
Thanks for this simple solution!
well explained, thank you!
Thank you 🙏
If you make fork = 5 and change code to have just one wait and signal where the wait decrements by two and the signal increments by 2 that would fix it as well.
Best explaination
Great video!
Elegant solution!
Thanks.
awesome explanation
this leads to P4 leading to starvation as he eats less often. Thanks you for the video.
Grant Wilson Could you explain why please?
this is because P0 will always have priority over F0, therefore it it's not first come first serve. so P4 will eat less often then the rest leading to the thread being "starved". starved in the concurrent definition, not literally starved.
But no philosopher has "priority", they just have a fork that they will go for first. In the same way that P0 will go for F0 first, P4 will also go for F0 first. It's true that in this way F0 is unique as it has two philosophers that will go for it first, whereas F1, 2, and 3 only each have one philosopher that will go for them first. No philosopher will go for F4 first. I can't figure out if all that means some philosophers may be starved vs others, or whether it all evens out in the end as all philosophers always need to acquire two forks to eat anyway. I'd appreciate it if someone could provide a definitive answer.
If p4 is waiting to take f0 because p0 claimed it (or vice-versa), then it will be able to immediately take f0 as soon as the other philosopher is done because the semSignal command is an explicit invitation to take the newly released resource. There may be some small bias in who gets f0 first, but from that point onward, if demand for f0 is high, then the two philosophers will simply be taking turns, which is as fair as you can expect.
You are correct- Thank you
Nice!
perfect
thanks for explanation ,have you a code in java or c of dining philosophers ?
What if P3 eats so fast and also fast in grabbing the fork, will it also create deadlock? I'm just trying to consider all the edge cases.
That is starvation not deadlock. But you are right, it is possible.
Infinite supply of spaghetti, I'm hungry now lol
Probably being philosopher they figure that two forks would allow them to shove more spaghetti down their pie holes, increasing concurrency.
OMG
prof g brought me here
Philosophers need 2 forks to eat how inefficient! Get more forks
while ( true ) { fork(); }
Fork bomb baby!