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