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
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.
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
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]
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.
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.
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 😂
Its really very tough to explain such complicated problems so clearly and also the explanation is so perfect and point to point. Hats offf!!!!!
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
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 owe my CE degree to this channel. THANK YOU!
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
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
Very Beautifully explained! Thanks, Neso Academy
why philosopher? why it isn't dining family or friends?
Because they think that's why
What a life
Eating🍴&
Thinking 🤔
🤣
I want that life.
One of the most Important and famous problem with easiest solution
Wonderful explanation ❤️
Great explanation sir. Thank you🙂🙂
your teaching method is amazing
So is it rice or noodles? Forks or chopsticks?
i like the way Indians talking in English. And, thanks for the explanation.
Excellent explanation 🎉🎉
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
Sir please make videos on software engineering subject sir please 🥺🥺
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???
is one fork not enough to eat noodles??
😂😂
That's just to explain it easily. Actually chopsticks are used to explain this 🤓🏃
thank you for the great explanation
That's why a famous quote is famous in India "अपना हाथ जगन्नाथ" 😂
Yeah 😆
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.
Thank u so much for this topic❤❤❤
Nicely explained problem
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
please give me the c program code of this dining philosopher problem
very well explained!
Thank you so much
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??
Great lecture sir...
Numbering should have started from 0 rest is correct
A really clean explanation, thx
what about philosopher 4 , which fork will he use , as per the formula 4 and 0 ? but he should use 4 and 5 ?
When will u complete DBMS lectures in neso fuel
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
great video! I hope the philosophers washed their hands before sitting down to eat.
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]
I think the image should show alternating knife and fork or fork and spoon
Can this be Solved using Graph theory and Hamiltonian Graph Conceot?
Really helpful...thanks
If I am there in place of philosopher, I would have eaten without even thinking about deadlock 🤣
Thank you. Very well done!
Thank You
Why don't they eat with just one fork? Do they think forks have separation anxiety?
Guys better eat with ur hands problem solve 💯
for those of you looking for the code that's deadlock free look up the Tannenbaum's solution.
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
Thanks sir
I think every body must have hand practice eating
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.
Legends say that they are still eating and thinking
Thanks ❤️
if chopstick[i] is the left chopstick then how chopstick[i+1] is the right chopstick....in @13:18
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
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
Amazing explanation!!!
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
11:10 when i = 4 then [(i+1)%5] will give 0
How to solve this???
thnk you
What if they just started eating or consuming with hand 👌🏻
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].
Naattil evida sire veed
Best ❤
perfect
it actually is chopsticks instead of folks. 2 folks won't make much sense.
Noodles should have been yellow colored 🤣🤣
Magkinamot nalang tag kaun uy HAHAHAHA
I'm still confused what are the philosophers eating.. 😂
haha, I'm better than these philosophers, I need just one fork to eat!
lol it makes more sense with chopsticks, why would a philosipher need 2 forks
Isiliye ham Hindustani haath se khate hain
thanks a lot for your videos. i just watch for one straight and already know with the problem
But one fork is enough know😂
💪💪
🙏🏻🙏🏻🙏🏻💯
just so let u know u can also eat noodles with one fork thank me later xd
computer science degree check
they shouldn't share the fork its unhealthy lol
Are hath se khalo yaar 😑
adamsin
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?
very unhygienic imho
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 :)
Lovelelyyyyy
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 😂