Deadlock 3: Dining Philosophers

Поделиться
HTML-код
  • Опубликовано: 7 авг 2016
  • The Dining Philosophers problem is discussed, in which 5 philosopher processes compete for 5 fork resources in order to eat. An incorrect solution leading to deadlock is discussed, and then a simple fix based on a global ordering of resources is presented.

Комментарии • 33

  • @ukaszsmigielski8648
    @ukaszsmigielski8648 6 лет назад +37

    More english videos on youtube about OSs and I would be happy

  • @shinreyzhang
    @shinreyzhang 6 лет назад +10

    Thank you so much, you have explained this problem very thoroughly

  • @disorder1111
    @disorder1111 6 лет назад +3

    Thanks for these videos. I have been studying by reading a chapter in the Stallings book first and then watching the corresponding video(s) on your channel. I wish you had a video for every subject!

  • @onaecO
    @onaecO 11 месяцев назад +1

    beautiful !

  • @ValentinBaca
    @ValentinBaca 7 лет назад +1

    Thanks for the clear explanation!

  • @DaveJLin
    @DaveJLin 3 года назад

    Excellent explanation, thanks!

  • @ahcenebelhadi955
    @ahcenebelhadi955 2 года назад

    Thanks for this simple solution!

  • @pabliospark
    @pabliospark 7 лет назад

    well explained, thank you!

  • @chandrashakerreddy3915
    @chandrashakerreddy3915 6 лет назад +1

    Thank you 🙏

  • @furb39692
    @furb39692 5 лет назад +2

    If you make fork = 5 and change code to have just one wait and signal where the wait decrements by two and the signal increments by 2 that would fix it as well.

  • @rajkunal7628
    @rajkunal7628 6 лет назад +1

    Best explaination

  • @DarkLambfromthesun
    @DarkLambfromthesun 6 лет назад

    Great video!

  • @chrise202
    @chrise202 6 лет назад

    Elegant solution!

  • @paurushgargtube
    @paurushgargtube 2 года назад

    Thanks.

  • @ViniciuxMariano
    @ViniciuxMariano 5 лет назад

    awesome explanation

  • @grantwilson6577
    @grantwilson6577 7 лет назад +5

    this leads to P4 leading to starvation as he eats less often. Thanks you for the video.

    • @MintFiend
      @MintFiend 7 лет назад +1

      Grant Wilson Could you explain why please?

    • @grantwilson6577
      @grantwilson6577 7 лет назад +1

      this is because P0 will always have priority over F0, therefore it it's not first come first serve. so P4 will eat less often then the rest leading to the thread being "starved". starved in the concurrent definition, not literally starved.

    • @MintFiend
      @MintFiend 7 лет назад

      But no philosopher has "priority", they just have a fork that they will go for first. In the same way that P0 will go for F0 first, P4 will also go for F0 first. It's true that in this way F0 is unique as it has two philosophers that will go for it first, whereas F1, 2, and 3 only each have one philosopher that will go for them first. No philosopher will go for F4 first. I can't figure out if all that means some philosophers may be starved vs others, or whether it all evens out in the end as all philosophers always need to acquire two forks to eat anyway. I'd appreciate it if someone could provide a definitive answer.

    • @JacobSchrum
      @JacobSchrum  7 лет назад +7

      If p4 is waiting to take f0 because p0 claimed it (or vice-versa), then it will be able to immediately take f0 as soon as the other philosopher is done because the semSignal command is an explicit invitation to take the newly released resource. There may be some small bias in who gets f0 first, but from that point onward, if demand for f0 is high, then the two philosophers will simply be taking turns, which is as fair as you can expect.

    • @GalacticEmpression
      @GalacticEmpression 7 лет назад

      You are correct- Thank you

  • @tarungupta5827
    @tarungupta5827 6 лет назад

    Nice!

  • @shireeniqbal7399
    @shireeniqbal7399 7 лет назад

    perfect

  • @learnwithdounia6946
    @learnwithdounia6946 4 года назад

    thanks for explanation ,have you a code in java or c of dining philosophers ?

  • @ethanphan6136
    @ethanphan6136 6 лет назад

    What if P3 eats so fast and also fast in grabbing the fork, will it also create deadlock? I'm just trying to consider all the edge cases.

    • @paolo2605
      @paolo2605 6 лет назад +2

      That is starvation not deadlock. But you are right, it is possible.

  • @celsiusfahrenheit1176
    @celsiusfahrenheit1176 4 года назад

    Infinite supply of spaghetti, I'm hungry now lol

  • @celsiusfahrenheit1176
    @celsiusfahrenheit1176 4 года назад

    Probably being philosopher they figure that two forks would allow them to shove more spaghetti down their pie holes, increasing concurrency.

  • @dungleouet
    @dungleouet 4 года назад

    OMG

  • @shaydennaidoo4036
    @shaydennaidoo4036 8 месяцев назад

    prof g brought me here

  • @dougg1976
    @dougg1976 6 лет назад +4

    Philosophers need 2 forks to eat how inefficient! Get more forks

  • @poleomentaa
    @poleomentaa 4 года назад

    while ( true ) { fork(); }