The Dining Philosophers Problem

  Рет қаралды 310,095

Neso Academy

Neso Academy

Күн бұрын

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

Пікірлер: 138
@aakashbiju.v8548
@aakashbiju.v8548 Жыл бұрын
I wanna be a philosopher, just spend my whole life thinking or eating.
@PythonisLove
@PythonisLove 2 жыл бұрын
everyone should have their own fork. Using other's fork is not good practice
@01.abhishekkumar33
@01.abhishekkumar33 2 жыл бұрын
😄😄😄😄
@siddharth2954
@siddharth2954 2 жыл бұрын
If everyone starts taking their own fork then there will be the shortage of forks!! Relate it with the processess and resource allocation
@hungertv3988
@hungertv3988 2 жыл бұрын
, 😂😂
@areezmuhammed
@areezmuhammed 2 жыл бұрын
By that logic you could also tell that one of the philosopher could eat directly from thier hand, why the fork
@ounissaslimi8412
@ounissaslimi8412 2 жыл бұрын
The first thing i thought about what covid 19
@devbhuva9798
@devbhuva9798 Жыл бұрын
Its really very tough to explain such complicated problems so clearly and also the explanation is so perfect and point to point. Hats offf!!!!!
@lalithav3079
@lalithav3079 4 ай бұрын
Very Beautifully explained! Thanks, Neso Academy
@caamedyyyy
@caamedyyyy 4 ай бұрын
At first entered into ur vedio i just switched to another channel but continuously wateching 3minutes i automatically liked ur way of explanation
@ROSHAN-bf5bj
@ROSHAN-bf5bj 2 жыл бұрын
Great explanation sir. Thank you🙂🙂
@pranavbakare8922
@pranavbakare8922 3 жыл бұрын
One of the most Important and famous problem with easiest solution
@mdnghbrs1283
@mdnghbrs1283 2 жыл бұрын
Three minutes into this video and already like your explanation. Thanks a lot for the content
@bowserjrsoutsidestory7125
@bowserjrsoutsidestory7125 10 ай бұрын
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
@caamedyyyy
@caamedyyyy 4 ай бұрын
​@@bowserjrsoutsidestory7125that's the way how clearly explained pin to pin again and again reached to our brain what he is saying right
@theuglycat16
@theuglycat16 Жыл бұрын
thanks a lot for your videos. i just watch for one straight and already know with the problem
@ramzeilahi7917
@ramzeilahi7917 3 жыл бұрын
Thank u so much for this topic❤❤❤
@barisballi70
@barisballi70 Жыл бұрын
A really clean explanation, thx
@xsilverx1198
@xsilverx1198 6 ай бұрын
I owe my CE degree to this channel. THANK YOU!
@dhaneshjandhyala5685
@dhaneshjandhyala5685 3 жыл бұрын
Wonderful explanation ❤️
@rex123z
@rex123z 9 күн бұрын
thank you for the great explanation
@brucelamb6060
@brucelamb6060 2 жыл бұрын
Thank you. Very well done!
@xigong3009
@xigong3009 2 жыл бұрын
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
@fernandobedoyaortecho2330
@fernandobedoyaortecho2330 7 ай бұрын
"There is no free lunch" is particularly relevant in this problem :)
@susmitamaity8576
@susmitamaity8576 Жыл бұрын
Really helpful...thanks
@balashivuduu2101
@balashivuduu2101 Жыл бұрын
Great lecture sir...
@darshil-oh2le
@darshil-oh2le 8 ай бұрын
Nicely explained problem
@niteeshtechminister126
@niteeshtechminister126 2 жыл бұрын
What a life Eating🍴& Thinking 🤔
@manjunathn2096
@manjunathn2096 2 жыл бұрын
🤣
@hammadahmad100
@hammadahmad100 2 жыл бұрын
I want that life.
@mohsinkalander3986
@mohsinkalander3986 Жыл бұрын
Thank You
@shikarikumar
@shikarikumar Жыл бұрын
Thanks sir
@ujefmalek77
@ujefmalek77 2 жыл бұрын
Thanks ❤️
@justkflesh
@justkflesh 2 жыл бұрын
Excellent lecture!
@TheExhilaratedMan
@TheExhilaratedMan Жыл бұрын
Amazing explanation!!!
@nutislucky4904
@nutislucky4904 4 ай бұрын
why philosopher? why it isn't dining family or friends?
@aashirsiddiqui5203
@aashirsiddiqui5203 18 күн бұрын
Because they think that's why
@astrovishalthakur
@astrovishalthakur 2 жыл бұрын
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.
@tienngocnguyen5567
@tienngocnguyen5567 Жыл бұрын
The pick up action is mutual exclusive, so only one philosopher can pick up the chopstick
@Ayush37262
@Ayush37262 Жыл бұрын
11:10 when i = 4 then [(i+1)%5] will give 0 How to solve this???
@anonymous1306
@anonymous1306 Жыл бұрын
@@Ayush37262 Why would you mod by 5 when the no. of philosophers are 4 ?
@ruzreuben9755
@ruzreuben9755 6 ай бұрын
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.
@ahmedrateb5867
@ahmedrateb5867 3 ай бұрын
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
@hayethamez2671
@hayethamez2671 2 ай бұрын
thnk you
@feritcan5992
@feritcan5992 2 жыл бұрын
i like the way Indians talking in English. And, thanks for the explanation.
@ABHINDHU
@ABHINDHU 3 жыл бұрын
Sir please make videos on software engineering subject sir please 🥺🥺
@DSA_Coding
@DSA_Coding 5 ай бұрын
perfect
@deepa6332
@deepa6332 9 ай бұрын
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.
@kavyabanka4482
@kavyabanka4482 3 жыл бұрын
When will u complete DBMS lectures in neso fuel
@BLcomicsShorts
@BLcomicsShorts Жыл бұрын
please give me the c program code of this dining philosopher problem
@psayush2844
@psayush2844 25 күн бұрын
Legends say that they are still eating and thinking
@simaobonvalot9141
@simaobonvalot9141 Жыл бұрын
I would like to see the same problem solved with threads. Any plans on making it happen ?
@Ayush37262
@Ayush37262 Жыл бұрын
11:10 when i = 4 then [(i+1)%5] will give 0 How to solve this???
@tadm123
@tadm123 3 ай бұрын
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
@mohammedirfan8651
@mohammedirfan8651 Жыл бұрын
Guys better eat with ur hands problem solve 💯
@thecodeshala
@thecodeshala 2 ай бұрын
That's why a famous quote is famous in India "अपना हाथ जगन्नाथ" 😂
@orgho2044
@orgho2044 11 сағат бұрын
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
@archer8629
@archer8629 Жыл бұрын
great video! I hope the philosophers washed their hands before sitting down to eat.
@priyadharzhini4181
@priyadharzhini4181 2 жыл бұрын
is one fork not enough to eat noodles??
@Harish_00007
@Harish_00007 Жыл бұрын
😂😂
@KodaBunnyLillySlush
@KodaBunnyLillySlush 18 күн бұрын
what about philosopher 4 , which fork will he use , as per the formula 4 and 0 ? but he should use 4 and 5 ?
@miracle3825
@miracle3825 3 жыл бұрын
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.
@laxmandholakiya7616
@laxmandholakiya7616 3 жыл бұрын
Engineering funda
@programmer1111x
@programmer1111x 6 ай бұрын
But if i=4. We need 5 in the 2nd wait. But (4+1) % 5 =0.... So isn't this a problem?
@subrattripathy9247
@subrattripathy9247 4 ай бұрын
Learn array indexing
@AliMurtaza-ew3lh
@AliMurtaza-ew3lh 2 ай бұрын
for those of you looking for the code that's deadlock free look up the Tannenbaum's solution.
@wasalawyer.1179
@wasalawyer.1179 Ай бұрын
Can this be Solved using Graph theory and Hamiltonian Graph Conceot?
@VishalBhagat1
@VishalBhagat1 Ай бұрын
Best ❤
@rohannaidubadarla280
@rohannaidubadarla280 7 ай бұрын
If I am there in place of philosopher, I would have eaten without even thinking about deadlock 🤣
@shawazonfire
@shawazonfire Жыл бұрын
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?
@m4ack4n
@m4ack4n Жыл бұрын
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.
@user-wm6qf3ek1n
@user-wm6qf3ek1n 5 ай бұрын
if chopstick[i] is the left chopstick then how chopstick[i+1] is the right chopstick....in @13:18
@soccerforu9530
@soccerforu9530 Жыл бұрын
💪💪
@TT-xg7qd
@TT-xg7qd 7 ай бұрын
Second scenario is good I think, to allow philosopher to pick the chopsticks only if both chopsticks are free....
@ayahamad5931
@ayahamad5931 7 ай бұрын
But I think the third scenario is better
@Ayush37262
@Ayush37262 Жыл бұрын
11:10 when i = 4 then [(i+1)%5] will give 0 How to solve this???
@SuyashGaurav
@SuyashGaurav 4 ай бұрын
Why don't they eat with just one fork? Do they think forks have separation anxiety?
@pranzz30
@pranzz30 9 ай бұрын
🙏🏻🙏🏻🙏🏻💯
@alenko2682
@alenko2682 3 ай бұрын
You only need one fork for spaghetti! :)
@mr.game_over1170
@mr.game_over1170 Жыл бұрын
so, when i=4 , 4+1=5 then 5 mod 5 will be 0 right ? is there a 0 copstick?
@tushman278
@tushman278 Жыл бұрын
the first chopstick corresponds to chopstick[0]. Array indexing starts with 0.
@himahelmy6206
@himahelmy6206 Жыл бұрын
@@tushman278 he initialized it as semaphore chopstick [5], so in that case the array has 6 elements tho
@aryanbasu8686
@aryanbasu8686 7 ай бұрын
​@@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]
@pavanfernandes9329
@pavanfernandes9329 Жыл бұрын
Noodles should have been yellow colored 🤣🤣
@helenmachelen4200
@helenmachelen4200 Ай бұрын
So is it rice or noodles? Forks or chopsticks?
@abhilashk4607
@abhilashk4607 2 ай бұрын
Naattil evida sire veed
@rushikeshsable3437
@rushikeshsable3437 7 ай бұрын
I think every body must have hand practice eating
@serhii-ratz
@serhii-ratz 2 жыл бұрын
And what about chopstick[0]?
@nooreldali7432
@nooreldali7432 2 жыл бұрын
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.
@loydvincentbutron4345
@loydvincentbutron4345 Жыл бұрын
Magkinamot nalang tag kaun uy HAHAHAHA
@vishuagarwal2820
@vishuagarwal2820 2 жыл бұрын
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.
@usaball9193
@usaball9193 2 жыл бұрын
That's what the second remedy is saying
@CHETHANgaming16
@CHETHANgaming16 Жыл бұрын
But one fork is enough know😂
@tonystark1552
@tonystark1552 7 ай бұрын
I'm still confused what are the philosophers eating.. 😂
@pranavmuthige427
@pranavmuthige427 Жыл бұрын
Isiliye ham Hindustani haath se khate hain
@animeshmaru16
@animeshmaru16 2 жыл бұрын
chopstick[4] will call chopstick[(4+1)%5] ie. chopstick[0] that is not correct..😥
@sandeept7114
@sandeept7114 Жыл бұрын
its an array -indexing starts at zero. so its correct, first chopstick is labeled chopstick[0].
@studystuff51
@studystuff51 Жыл бұрын
haha, I'm better than these philosophers, I need just one fork to eat!
@therobinx20
@therobinx20 6 ай бұрын
it actually is chopsticks instead of folks. 2 folks won't make much sense.
@edanuryardm8252
@edanuryardm8252 7 ай бұрын
adamsin
@ruzreuben9755
@ruzreuben9755 6 ай бұрын
lol it makes more sense with chopsticks, why would a philosipher need 2 forks
@sidarkilinc1291
@sidarkilinc1291 2 жыл бұрын
computer science degree check
@wildweroam2581
@wildweroam2581 2 жыл бұрын
Lovelelyyyyy
@hitblank2320
@hitblank2320 Жыл бұрын
they shouldn't share the fork its unhealthy lol
@ARFLASHYT
@ARFLASHYT 5 ай бұрын
just so let u know u can also eat noodles with one fork thank me later xd
@ashwin5562
@ashwin5562 Ай бұрын
Are hath se khalo yaar 😑
@hueydo3522
@hueydo3522 2 жыл бұрын
This is a naive solution. This is not the right solution for dining philosopher
@Ananasbleu
@Ananasbleu 2 жыл бұрын
what do you mean by "this" ? he goes through many different subtopics (avoid deadlock, using semaphores...) which one are you talking about?
@kozavr
@kozavr Жыл бұрын
O my god, it's not "tinking" it's "thinking" :)))
@co2_os
@co2_os 9 ай бұрын
very unhygienic imho
@ARFLASHYT
@ARFLASHYT 5 ай бұрын
and also noodles with out soup is really unhealthy to eat take care of your health thank me later :)
@bionic20
@bionic20 2 жыл бұрын
You talk silly too much....same thing repeats
@ramyap9110
@ramyap9110 3 ай бұрын
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 😂
Monitors
13:46
Neso Academy
Рет қаралды 184 М.
Semaphores
22:51
Neso Academy
Рет қаралды 447 М.
Best father #shorts by Secret Vlog
00:18
Secret Vlog
Рет қаралды 21 МЛН
LOVE LETTER - POPPY PLAYTIME CHAPTER 3 | GH'S ANIMATION
00:15
Жайдарман | Туған күн 2024 | Алматы
2:22:55
Jaidarman OFFICIAL / JCI
Рет қаралды 1,8 МЛН
Dining Philosophers Problem with Solution
8:10
Gary Explains
Рет қаралды 78 М.
4.15 Dining Philosophers Problem | Semaphores | Process Synchronization in Operating System
10:51
The Readers Writers Problem
15:32
Neso Academy
Рет қаралды 239 М.
L31: Dining philosophers Problem and Solution using Semaphore in Operating System
7:25
Dining Philosophers Solution using Monitors
15:04
Neso Academy
Рет қаралды 106 М.
The Bounded Buffer Problem
15:48
Neso Academy
Рет қаралды 268 М.
Disadvantages of Semaphores
11:05
Neso Academy
Рет қаралды 136 М.
CIA Triad
16:08
Neso Academy
Рет қаралды 287 М.
Best father #shorts by Secret Vlog
00:18
Secret Vlog
Рет қаралды 21 МЛН