Thanks for the exposition! I thought this is some boring problem computer scientistis made up, but then I realize that 1) there could be a deadlock for naive implementation 2) there are many different ways to address the deadlock 3) different solutions have different pro and cons under different metrics
I think the second remedy was best in a deadlock condition. Because in the first remedy, we are just decreasing the processes and in the last remedy, 1 and 5 sit adjacent but both are odd numbers, so it still creates deadlock as both will pick the left first.
Why? If philosipher 1 and 5 pick up left at same time philosipher 1 will be blocked because of it's right chopstick is used by philosipher 5. Philosipher 5 chopstick could also be blocked but only in case philosipher 4 is eating(because philosipher 4 picks *right* first). So there is no deadlock, 4 will finish eating then 5 will eat then 1.
Even if this is true, no deadlock will occur because eventually the one holding the common fork will get to eat and then place it down for the other to eat To get a deadlock here all 5 philosophers have to be involved, by reducing them to 4 which the first solution does, there will always be a free fork since there are still 5 forks
i don't understand how you can specify the parameters of the problem at the beginning, for over 5 minutes, and then change those parameters at the end. yes, you can allow at most 4 philosophers to sit at the table, but that changes the actual problem you're being asked to solve. if you can reduce the maximum philosophers allowed at the table to solve this problem, then why can't you just increase the maximum forks allowed at the table to solve this problem? how is changing the parameters of the problem to solve it an acceptable solution?
I'm guessing that the processes and resources vary but it was not clear in this video. Sometimes the problem occurs(but not always), and when it does one way is avoid the problem all together by seting a max allowed "philosophers"(processes). Tho adding more "chopsticks"(resources) is not always possible. What I can not understand is why a "mutex" solution isn't used here. It has been the go to sollution for other problems.
This is because think the philosophers as processes and the forks as resources. Resources are often limited but processes can be unlimited. So we cannot increase the no. of forks in a normal case
so, for the the i=4 philosopher you get 4th and 4+1% 5 = 0th chopstick which is mess. i suggest count the philosophers from 0 to 4 same for chopsticks 0 to 4 and now mod with 5(number of philosophers).... for philosopher 0 you get 0th and 0+1 % 5= 1th chopstick for philosopher 1 you get 1th and 1+1 % 5= 2th chopstick for philosopher 2 you get 2th and 2+1 % 5= 3th chopstick for philosopher 3 you get 3th and 3+1 % 5= 4th chopstick for philosopher 4 you get 4th and 4+1 % 5= 0th chopstick
Sir, how could, if there are 5 philosophers, then if limited, how will one fork be handled with one chopstick? Do work run time ready with the elapsed time, where the relapsed time remains quicker, is that a small confusion? Do maintain the relapsed time, is that part to be kept in mind for the problem to be resolved. Thank you.
hey man are you sure it's not a Mutex instead of a semaphore? Semaphore when initialized (available) are set to 0. And when someone enters the critical ssection to work on some shared resource the semaphore counter increases to 1. Maybe I'm wrong
@@himahelmy6206No. It has 5 elements. But the numbering will be from 0 to 4. Will declaring the array, it will be chopstick[5] however while accessing the last variable later in the code, it will be chopstick[4]
Thank you sir. I am new to your channel and currently I am watching your videos about digital electronics. Sir can you please suggest me a channel about optics , electricity and magnetism (English medium) . Thank you sir once again.
The algorithm would be correct if you start counting from zero [0,1,2,3,4] for both forks and philosophers. Philosopher #4 will execute wait(4) and wait (1+4%5) = wait(0) which is correct in this case.
Even i was listening to this topic in my class I was thinking that chopsticks 🥢 r of 2 but y they hv kept one for each how can they eat with one chopstick 😂
everyone should have their own fork. Using other's fork is not good practice
😄😄😄😄
If everyone starts taking their own fork then there will be the shortage of forks!!
Relate it with the processess and resource allocation
, 😂😂
By that logic you could also tell that one of the philosopher could eat directly from thier hand, why the fork
The first thing i thought about what covid 19
Its really very tough to explain such complicated problems so clearly and also the explanation is so perfect and point to point. Hats offf!!!!!
I owe my CE degree to this channel. THANK YOU!
Three minutes into this video and already like your explanation. Thanks a lot for the content
what? but three minutes in he is still just describing the problem?
in fact he doesnt start going into the problem until 5 minutes in
@@bowserjrsoutsidestory7125that's the way how clearly explained pin to pin again and again reached to our brain what he is saying right
I wanna be a philosopher, just spend my whole life thinking or eating.
Thanks for the exposition! I thought this is some boring problem computer scientistis made up, but then I realize that 1) there could be a deadlock for naive implementation 2) there are many different ways to address the deadlock 3) different solutions have different pro and cons under different metrics
"There is no free lunch" is particularly relevant in this problem :)
At first entered into ur vedio i just switched to another channel but continuously wateching 3minutes i automatically liked ur way of explanation
Very Beautifully explained! Thanks, Neso Academy
Wonderful explanation ❤️
What a life
Eating🍴&
Thinking 🤔
🤣
I want that life.
I think the second remedy was best in a deadlock condition. Because in the first remedy, we are just decreasing the processes and in the last remedy, 1 and 5 sit adjacent but both are odd numbers, so it still creates deadlock as both will pick the left first.
The pick up action is mutual exclusive, so only one philosopher can pick up the chopstick
11:10 when i = 4 then [(i+1)%5] will give 0
How to solve this???
@@Ayush37262 Why would you mod by 5 when the no. of philosophers are 4 ?
Why? If philosipher 1 and 5 pick up left at same time philosipher 1 will be blocked because of it's right chopstick is used by philosipher 5. Philosipher 5 chopstick could also be blocked but only in case philosipher 4 is eating(because philosipher 4 picks *right* first). So there is no deadlock, 4 will finish eating then 5 will eat then 1.
Even if this is true, no deadlock will occur because eventually the one holding the common fork will get to eat and then place it down for the other to eat
To get a deadlock here all 5 philosophers have to be involved, by reducing them to 4 which the first solution does, there will always be a free fork since there are still 5 forks
your teaching method is amazing
One of the most Important and famous problem with easiest solution
i like the way Indians talking in English. And, thanks for the explanation.
Great explanation sir. Thank you🙂🙂
why philosopher? why it isn't dining family or friends?
Because they think that's why
Excellent explanation 🎉🎉
So is it rice or noodles? Forks or chopsticks?
thank you for the great explanation
Nicely explained problem
Thank u so much for this topic❤❤❤
very well explained!
Sir please make videos on software engineering subject sir please 🥺🥺
A really clean explanation, thx
Thank you so much
That's why a famous quote is famous in India "अपना हाथ जगन्नाथ" 😂
Yeah 😆
Great lecture sir...
Numbering should have started from 0 rest is correct
is one fork not enough to eat noodles??
😂😂
That's just to explain it easily. Actually chopsticks are used to explain this 🤓🏃
I would like to see the same problem solved with threads. Any plans on making it happen ?
11:10 when i = 4 then [(i+1)%5] will give 0
How to solve this???
Really helpful...thanks
Thank You
i don't understand how you can specify the parameters of the problem at the beginning, for over 5 minutes, and then change those parameters at the end. yes, you can allow at most 4 philosophers to sit at the table, but that changes the actual problem you're being asked to solve. if you can reduce the maximum philosophers allowed at the table to solve this problem, then why can't you just increase the maximum forks allowed at the table to solve this problem? how is changing the parameters of the problem to solve it an acceptable solution?
I'm guessing that the processes and resources vary but it was not clear in this video.
Sometimes the problem occurs(but not always), and when it does one way is avoid the problem all together by seting a max allowed "philosophers"(processes). Tho adding more "chopsticks"(resources) is not always possible.
What I can not understand is why a "mutex" solution isn't used here. It has been the go to sollution for other problems.
This is because think the philosophers as processes and the forks as resources. Resources are often limited but processes can be unlimited. So we cannot increase the no. of forks in a normal case
Guys better eat with ur hands problem solve 💯
please give me the c program code of this dining philosopher problem
Thank you. Very well done!
If I am there in place of philosopher, I would have eaten without even thinking about deadlock 🤣
great video! I hope the philosophers washed their hands before sitting down to eat.
Legends say that they are still eating and thinking
Amazing explanation!!!
so, for the the i=4 philosopher you get 4th and 4+1% 5 = 0th chopstick which is mess. i suggest count the philosophers from 0 to 4 same for chopsticks 0 to 4 and now mod with 5(number of philosophers)....
for philosopher 0 you get 0th and 0+1 % 5= 1th chopstick
for philosopher 1 you get 1th and 1+1 % 5= 2th chopstick
for philosopher 2 you get 2th and 2+1 % 5= 3th chopstick
for philosopher 3 you get 3th and 3+1 % 5= 4th chopstick
for philosopher 4 you get 4th and 4+1 % 5= 0th chopstick
Thanks sir
When will u complete DBMS lectures in neso fuel
I think every body must have hand practice eating
But sir, if all odd philosophers pick their left for first then where is the chance for the even philosophers to pick their right for first??
I think the image should show alternating knife and fork or fork and spoon
thnk you
Sir, how could, if there are 5 philosophers, then if limited, how will one fork be handled with one chopstick? Do work run time ready with the elapsed time, where the relapsed time remains quicker, is that a small confusion? Do maintain the relapsed time, is that part to be kept in mind for the problem to be resolved. Thank you.
Thanks ❤️
Why don't they eat with just one fork? Do they think forks have separation anxiety?
hey man are you sure it's not a Mutex instead of a semaphore? Semaphore when initialized (available) are set to 0. And when someone enters the critical ssection to work on some shared resource the semaphore counter increases to 1. Maybe I'm wrong
what about philosopher 4 , which fork will he use , as per the formula 4 and 0 ? but he should use 4 and 5 ?
Another solution: Can't we just start with 1 to 5, 1 will eat and give back the chopstick, and then 2 will eat, and so on.
That's what the second remedy is saying
Can this be Solved using Graph theory and Hamiltonian Graph Conceot?
for those of you looking for the code that's deadlock free look up the Tannenbaum's solution.
Naattil evida sire veed
Best ❤
Second scenario is good I think, to allow philosopher to pick the chopsticks only if both chopsticks are free....
But I think the third scenario is better
perfect
thanks a lot for your videos. i just watch for one straight and already know with the problem
so, when i=4 , 4+1=5 then 5 mod 5 will be 0 right ? is there a 0 copstick?
the first chopstick corresponds to chopstick[0]. Array indexing starts with 0.
@@tushman278 he initialized it as semaphore chopstick [5], so in that case the array has 6 elements tho
@@himahelmy6206No. It has 5 elements. But the numbering will be from 0 to 4. Will declaring the array, it will be chopstick[5] however while accessing the last variable later in the code, it will be chopstick[4]
Thank you sir. I am new to your channel and currently I am watching your videos about digital electronics. Sir can you please suggest me a channel about optics , electricity and magnetism (English medium) . Thank you sir once again.
Engineering funda
And what about chopstick[0]?
The algorithm would be correct if you start counting from zero [0,1,2,3,4] for both forks and philosophers. Philosopher #4 will execute wait(4) and wait (1+4%5) = wait(0) which is correct in this case.
What if they just started eating or consuming with hand 👌🏻
Noodles should have been yellow colored 🤣🤣
if chopstick[i] is the left chopstick then how chopstick[i+1] is the right chopstick....in @13:18
But if i=4. We need 5 in the 2nd wait.
But
(4+1) % 5 =0....
So isn't this a problem?
Learn array indexing
it actually is chopsticks instead of folks. 2 folks won't make much sense.
chopstick[4] will call chopstick[(4+1)%5] ie. chopstick[0] that is not correct..😥
its an array -indexing starts at zero. so its correct, first chopstick is labeled chopstick[0].
I'm still confused what are the philosophers eating.. 😂
11:10 when i = 4 then [(i+1)%5] will give 0
How to solve this???
Isiliye ham Hindustani haath se khate hain
Magkinamot nalang tag kaun uy HAHAHAHA
haha, I'm better than these philosophers, I need just one fork to eat!
🙏🏻🙏🏻🙏🏻💯
But one fork is enough know😂
lol it makes more sense with chopsticks, why would a philosipher need 2 forks
computer science degree check
💪💪
This is a naive solution. This is not the right solution for dining philosopher
what do you mean by "this" ? he goes through many different subtopics (avoid deadlock, using semaphores...) which one are you talking about?
just so let u know u can also eat noodles with one fork thank me later xd
Are hath se khalo yaar 😑
they shouldn't share the fork its unhealthy lol
adamsin
very unhygienic imho
Lovelelyyyyy
O my god, it's not "tinking" it's "thinking" :)))
and also noodles with out soup is really unhealthy to eat take care of your health thank me later :)
You talk silly too much....same thing repeats
Even i was listening to this topic in my class I was thinking that chopsticks 🥢 r of 2 but y they hv kept one for each how can they eat with one chopstick 😂