The Dining Philosophers Problem
ฝัง
- เผยแพร่เมื่อ 11 มิ.ย. 2024
- Operating System: The Dining Philosophers Problem
Topics discussed:
Classic Problems of Synchronization:
1. The Dining Philosophers Problem.
2. Solution to the Dining Philosophers Problem using Semaphores.
3. Remedies to prevent Deadlocks.
Follow Neso Academy on Instagram: @nesoacademy (bit.ly/2XP63OE)
Follow me on Instagram: @jaiz_itech (bit.ly/2M3xyOa)
Contribute: www.nesoacademy.org/donate
Memberships: bit.ly/2U7YSPI
Books: www.nesoacademy.org/recommend...
Website ► www.nesoacademy.org/
Forum ► forum.nesoacademy.org/
Facebook ► goo.gl/Nt0PmB
Twitter ► / nesoacademy
Music:
Axol x Alex Skrindo - You [NCS Release]
#OperatingSystemByNeso #OperatingSystem #ProcessSynchronization #DiningPhilosophersProblem
I wanna be a philosopher, just spend my whole life thinking or eating.
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!!!!!
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
Very Beautifully explained! Thanks, Neso Academy
Great explanation sir. Thank you🙂🙂
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 ❤️
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 :)
Thank u so much for this topic❤❤❤
One of the most Important and famous problem with easiest solution
A really clean explanation, thx
thanks a lot for your videos. i just watch for one straight and already know with the problem
I owe my CE degree to this channel. THANK YOU!
Nicely explained problem
Great lecture sir...
Really helpful...thanks
Thank you. Very well done!
Thank You
Excellent lecture!
Thanks sir
What a life
Eating🍴&
Thinking 🤔
🤣
I want that life.
Thanks ❤️
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
Amazing explanation!!!
thnk you
why philosopher? why it isn't dining family or friends?
Can this be Solved using Graph theory and Hamiltonian Graph Conceot?
please give me the c program code of this dining philosopher problem
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.
Sir please make videos on software engineering subject sir please 🥺🥺
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
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
When will u complete DBMS lectures in neso fuel
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???
i like the way Indians talking in English. And, thanks for the explanation.
perfect
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.
is one fork not enough to eat noodles??
😂😂
Best ❤
That's why a famous quote is famous in India "अपना हाथ जगन्नाथ" 😂
great video! I hope the philosophers washed their hands before sitting down to eat.
Naattil evida sire veed
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
if chopstick[i] is the left chopstick then how chopstick[i+1] is the right chopstick....in @13:18
Guys better eat with ur hands problem solve 💯
11:10 when i = 4 then [(i+1)%5] will give 0
How to solve this???
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]
Why don't they eat with just one fork? Do they think forks have separation anxiety?
So is it rice or noodles? Forks or chopsticks?
for those of you looking for the code that's deadlock free look up the Tannenbaum's solution.
If I am there in place of philosopher, I would have eaten without even thinking about deadlock 🤣
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.
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
Noodles should have been yellow colored 🤣🤣
You only need one fork for spaghetti! :)
💪💪
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
🙏🏻🙏🏻🙏🏻💯
I think every body must have hand practice eating
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.. 😂
But one fork is enough know😂
adamsin
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.
Isiliye ham Hindustani haath se khate hain
lol it makes more sense with chopsticks, why would a philosipher need 2 forks
Lovelelyyyyy
computer science degree check
just so let u know u can also eat noodles with one fork thank me later xd
they shouldn't share the fork its unhealthy lol
Are hath se khalo yaar 😑
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?
O my god, it's not "tinking" it's "thinking" :)))
very unhygienic imho
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 😂