The Dining Philosophers Problem

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ม.ค. 2025

ความคิดเห็น • 157

  • @devbhuva9798
    @devbhuva9798 ปีที่แล้ว +52

    Its really very tough to explain such complicated problems so clearly and also the explanation is so perfect and point to point. Hats offf!!!!!

  • @PythonisLove
    @PythonisLove 3 ปีที่แล้ว +604

    everyone should have their own fork. Using other's fork is not good practice

    • @01.abhishekkumar33
      @01.abhishekkumar33 3 ปีที่แล้ว +10

      😄😄😄😄

    • @siddharth2954
      @siddharth2954 3 ปีที่แล้ว +28

      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 ปีที่แล้ว +2

      , 😂😂

    • @areezmuhammed
      @areezmuhammed 2 ปีที่แล้ว +30

      By that logic you could also tell that one of the philosopher could eat directly from thier hand, why the fork

    • @ounissaslimi8412
      @ounissaslimi8412 2 ปีที่แล้ว +8

      The first thing i thought about what covid 19

  • @mdnghbrs1283
    @mdnghbrs1283 2 ปีที่แล้ว +53

    Three minutes into this video and already like your explanation. Thanks a lot for the content

    • @bowserjrsoutsidestory7125
      @bowserjrsoutsidestory7125 ปีที่แล้ว

      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 10 หลายเดือนก่อน

      ​@@bowserjrsoutsidestory7125that's the way how clearly explained pin to pin again and again reached to our brain what he is saying right

  • @aakashbiju.v8548
    @aakashbiju.v8548 2 ปีที่แล้ว +92

    I wanna be a philosopher, just spend my whole life thinking or eating.

  • @shivamgupta3293
    @shivamgupta3293 28 วันที่ผ่านมา

    greatly explained,
    No unnecessary code, good theoretical explanation

  • @xigong3009
    @xigong3009 2 ปีที่แล้ว +14

    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

  • @caamedyyyy
    @caamedyyyy 10 หลายเดือนก่อน +5

    At first entered into ur vedio i just switched to another channel but continuously wateching 3minutes i automatically liked ur way of explanation

  • @dhaneshjandhyala5685
    @dhaneshjandhyala5685 3 ปีที่แล้ว +23

    Wonderful explanation ❤️

  • @lalithav3079
    @lalithav3079 11 หลายเดือนก่อน +1

    Very Beautifully explained! Thanks, Neso Academy

  • @xsilverx1198
    @xsilverx1198 ปีที่แล้ว +8

    I owe my CE degree to this channel. THANK YOU!

  • @astrovishalthakur
    @astrovishalthakur 3 ปีที่แล้ว +29

    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 2 ปีที่แล้ว

      The pick up action is mutual exclusive, so only one philosopher can pick up the chopstick

    • @Ayush37262
      @Ayush37262 ปีที่แล้ว +1

      11:10 when i = 4 then [(i+1)%5] will give 0
      How to solve this???

    • @anonymous1306
      @anonymous1306 ปีที่แล้ว +1

      @@Ayush37262 Why would you mod by 5 when the no. of philosophers are 4 ?

    • @ruzreuben9755
      @ruzreuben9755 ปีที่แล้ว +1

      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 9 หลายเดือนก่อน

      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

  • @ROSHAN-bf5bj
    @ROSHAN-bf5bj 3 ปีที่แล้ว +6

    Great explanation sir. Thank you🙂🙂

  • @aliyanbalouch8603
    @aliyanbalouch8603 5 หลายเดือนก่อน

    your teaching method is amazing

  • @nutislucky4904
    @nutislucky4904 10 หลายเดือนก่อน +12

    why philosopher? why it isn't dining family or friends?

  • @pranavbakare8922
    @pranavbakare8922 3 ปีที่แล้ว +1

    One of the most Important and famous problem with easiest solution

  • @funwithsaman8560
    @funwithsaman8560 2 หลายเดือนก่อน

    Excellent explanation 🎉🎉

  • @song_shorts_12
    @song_shorts_12 หลายเดือนก่อน

    Very nice explanation 👌

  • @darshil-oh2le
    @darshil-oh2le ปีที่แล้ว +1

    Nicely explained problem

  • @helenmachelen4200
    @helenmachelen4200 7 หลายเดือนก่อน +4

    So is it rice or noodles? Forks or chopsticks?

  • @niteeshtechminister126
    @niteeshtechminister126 3 ปีที่แล้ว +38

    What a life
    Eating🍴&
    Thinking 🤔

  • @rex123z
    @rex123z 6 หลายเดือนก่อน

    thank you for the great explanation

  • @رند-س5ح
    @رند-س5ح 3 หลายเดือนก่อน

    Thank you so much

  • @maya_11_12
    @maya_11_12 3 ปีที่แล้ว +2

    Thank u so much for this topic❤❤❤

  • @cindaellas
    @cindaellas 5 หลายเดือนก่อน

    very well explained!

  • @simaobonvalot9141
    @simaobonvalot9141 ปีที่แล้ว +2

    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???

  • @balashivuduu2101
    @balashivuduu2101 ปีที่แล้ว

    Great lecture sir...

  • @feritcan5992
    @feritcan5992 2 ปีที่แล้ว +4

    i like the way Indians talking in English. And, thanks for the explanation.

  • @barisballi70
    @barisballi70 2 ปีที่แล้ว

    A really clean explanation, thx

  • @priyadharzhini4181
    @priyadharzhini4181 2 ปีที่แล้ว +8

    is one fork not enough to eat noodles??

    • @Harish_00007
      @Harish_00007 2 ปีที่แล้ว +2

      😂😂

    • @tiktokstrend481
      @tiktokstrend481 3 หลายเดือนก่อน +1

      That's just to explain it easily. Actually chopsticks are used to explain this 🤓🏃

  • @susmitamaity8576
    @susmitamaity8576 2 ปีที่แล้ว

    Really helpful...thanks

  • @mohsinkalander3986
    @mohsinkalander3986 2 ปีที่แล้ว

    Thank You

  • @shawazonfire
    @shawazonfire 2 ปีที่แล้ว +4

    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 2 ปีที่แล้ว

      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.

    • @abhirupdas7962
      @abhirupdas7962 3 หลายเดือนก่อน

      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

  • @BLcomicsShorts
    @BLcomicsShorts ปีที่แล้ว +2

    please give me the c program code of this dining philosopher problem

  • @ABHINDHU
    @ABHINDHU 3 ปีที่แล้ว +7

    Sir please make videos on software engineering subject sir please 🥺🥺

  • @rohannaidubadarla280
    @rohannaidubadarla280 ปีที่แล้ว +1

    If I am there in place of philosopher, I would have eaten without even thinking about deadlock 🤣

  • @bakirmarouf6683
    @bakirmarouf6683 2 วันที่ผ่านมา +1

    one of them must stop thinking for a lil and go to kitchen to bring 5 more forks (:

  • @shikarikumar
    @shikarikumar 2 ปีที่แล้ว

    Thanks sir

  • @brucelamb6060
    @brucelamb6060 3 ปีที่แล้ว +2

    Thank you. Very well done!

  • @ujefmalek77
    @ujefmalek77 3 ปีที่แล้ว

    Thanks ❤️

  • @jjrpoektl1925
    @jjrpoektl1925 5 หลายเดือนก่อน

    I think the image should show alternating knife and fork or fork and spoon

  • @kavyabanka4482
    @kavyabanka4482 3 ปีที่แล้ว +3

    When will u complete DBMS lectures in neso fuel

  • @hayethamez2671
    @hayethamez2671 8 หลายเดือนก่อน

    thnk you

  • @thecodeshala
    @thecodeshala 8 หลายเดือนก่อน +2

    That's why a famous quote is famous in India "अपना हाथ जगन्नाथ" 😂

  • @SuyashGaurav
    @SuyashGaurav 11 หลายเดือนก่อน

    Why don't they eat with just one fork? Do they think forks have separation anxiety?

  • @deepa6332
    @deepa6332 ปีที่แล้ว

    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.

  • @navaneethdesai
    @navaneethdesai 5 หลายเดือนก่อน

    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??

  • @TheExhilaratedMan
    @TheExhilaratedMan 2 ปีที่แล้ว

    Amazing explanation!!!

  • @tadm123
    @tadm123 9 หลายเดือนก่อน

    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

  • @RohitSamanta-x8q
    @RohitSamanta-x8q 11 หลายเดือนก่อน

    if chopstick[i] is the left chopstick then how chopstick[i+1] is the right chopstick....in @13:18

  • @wasalawyer.1179
    @wasalawyer.1179 7 หลายเดือนก่อน

    Can this be Solved using Graph theory and Hamiltonian Graph Conceot?

  • @Rahulreddy45264
    @Rahulreddy45264 หลายเดือนก่อน

    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

  • @orgho2044
    @orgho2044 6 หลายเดือนก่อน

    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

  • @Bunny_Shark
    @Bunny_Shark 6 หลายเดือนก่อน

    what about philosopher 4 , which fork will he use , as per the formula 4 and 0 ? but he should use 4 and 5 ?

  • @archer8629
    @archer8629 ปีที่แล้ว +1

    great video! I hope the philosophers washed their hands before sitting down to eat.

  • @mr.game_over1170
    @mr.game_over1170 ปีที่แล้ว +1

    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 ปีที่แล้ว

      ​@@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]

  • @Ayush37262
    @Ayush37262 ปีที่แล้ว

    11:10 when i = 4 then [(i+1)%5] will give 0
    How to solve this???

  • @psayush2844
    @psayush2844 6 หลายเดือนก่อน

    Legends say that they are still eating and thinking

  • @mohammedirfan8651
    @mohammedirfan8651 ปีที่แล้ว +2

    Guys better eat with ur hands problem solve 💯

  • @boltez6507
    @boltez6507 หลายเดือนก่อน +1

    Numbering should have started from 0 rest is correct

  • @AliMurtaza-ew3lh
    @AliMurtaza-ew3lh 9 หลายเดือนก่อน

    for those of you looking for the code that's deadlock free look up the Tannenbaum's solution.

  • @DSA_Coding
    @DSA_Coding 11 หลายเดือนก่อน

    perfect

  • @Worldwithvishal
    @Worldwithvishal 7 หลายเดือนก่อน

    Best ❤

  • @serhii-ratz
    @serhii-ratz 3 ปีที่แล้ว +1

    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.

  • @abhilashk4607
    @abhilashk4607 8 หลายเดือนก่อน

    Naattil evida sire veed

  • @rushikeshsable3437
    @rushikeshsable3437 ปีที่แล้ว +1

    I think every body must have hand practice eating

  • @TT-xg7qd
    @TT-xg7qd ปีที่แล้ว +1

    Second scenario is good I think, to allow philosopher to pick the chopsticks only if both chopsticks are free....

    • @ayahamad5931
      @ayahamad5931 ปีที่แล้ว

      But I think the third scenario is better

  • @miracle3825
    @miracle3825 3 ปีที่แล้ว +1

    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.

  • @vishuagarwal2820
    @vishuagarwal2820 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      That's what the second remedy is saying

  • @young_youth
    @young_youth หลายเดือนก่อน

    What if they just started eating or consuming with hand 👌🏻

  • @pavanfernandes9329
    @pavanfernandes9329 2 ปีที่แล้ว

    Noodles should have been yellow colored 🤣🤣

  • @programmer1111x
    @programmer1111x ปีที่แล้ว +2

    But if i=4. We need 5 in the 2nd wait.
    But
    (4+1) % 5 =0....
    So isn't this a problem?

  • @theuglycat16
    @theuglycat16 ปีที่แล้ว

    thanks a lot for your videos. i just watch for one straight and already know with the problem

  • @loydvincentbutron4345
    @loydvincentbutron4345 2 ปีที่แล้ว

    Magkinamot nalang tag kaun uy HAHAHAHA

  • @pranzz30
    @pranzz30 ปีที่แล้ว

    🙏🏻🙏🏻🙏🏻💯

  • @animeshmaru16
    @animeshmaru16 2 ปีที่แล้ว +3

    chopstick[4] will call chopstick[(4+1)%5] ie. chopstick[0] that is not correct..😥

    • @sandeept7114
      @sandeept7114 ปีที่แล้ว +1

      its an array -indexing starts at zero. so its correct, first chopstick is labeled chopstick[0].

  • @tonystark1552
    @tonystark1552 ปีที่แล้ว

    I'm still confused what are the philosophers eating.. 😂

  • @lewismor3206
    @lewismor3206 21 วันที่ผ่านมา

    Dontt alllow them to sit on same table

  • @studystuff51
    @studystuff51 ปีที่แล้ว +4

    haha, I'm better than these philosophers, I need just one fork to eat!

  • @soccerforu9530
    @soccerforu9530 2 ปีที่แล้ว

    💪💪

  • @therobinx20
    @therobinx20 ปีที่แล้ว

    it actually is chopsticks instead of folks. 2 folks won't make much sense.

  • @CHETHANgaming16
    @CHETHANgaming16 ปีที่แล้ว

    But one fork is enough know😂

  • @ruzreuben9755
    @ruzreuben9755 ปีที่แล้ว

    lol it makes more sense with chopsticks, why would a philosipher need 2 forks

  • @pranavmuthige427
    @pranavmuthige427 2 ปีที่แล้ว +1

    Isiliye ham Hindustani haath se khate hain

  • @ARFLASHYT
    @ARFLASHYT 11 หลายเดือนก่อน

    just so let u know u can also eat noodles with one fork thank me later xd

  • @edanuryardm8252
    @edanuryardm8252 ปีที่แล้ว

    adamsin

  • @ashwin5562
    @ashwin5562 7 หลายเดือนก่อน

    Are hath se khalo yaar 😑

  • @hitblank2320
    @hitblank2320 ปีที่แล้ว

    they shouldn't share the fork its unhealthy lol

  • @sidarkilinc1291
    @sidarkilinc1291 3 ปีที่แล้ว +1

    computer science degree check

  • @hueydo3522
    @hueydo3522 3 ปีที่แล้ว +1

    This is a naive solution. This is not the right solution for dining philosopher

    • @Ananasbleu
      @Ananasbleu 3 ปีที่แล้ว +2

      what do you mean by "this" ? he goes through many different subtopics (avoid deadlock, using semaphores...) which one are you talking about?

  • @co2_os
    @co2_os ปีที่แล้ว

    very unhygienic imho

  • @wildweroam2581
    @wildweroam2581 3 ปีที่แล้ว

    Lovelelyyyyy

  • @kozavr
    @kozavr ปีที่แล้ว

    O my god, it's not "tinking" it's "thinking" :)))

  • @ARFLASHYT
    @ARFLASHYT 11 หลายเดือนก่อน

    and also noodles with out soup is really unhealthy to eat take care of your health thank me later :)

  • @bionic20
    @bionic20 2 ปีที่แล้ว +1

    You talk silly too much....same thing repeats

  • @ramyap9110
    @ramyap9110 9 หลายเดือนก่อน

    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 😂