Peterson's Solution for critical section problem

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024
  • #Peterson’sSolution #criticalsection #oslectures
    Peterson’s Solution is a classical software based solution to the critical section problem.
    In Peterson’s solution, we have two shared variables:
    boolean flag[i] :Initialized to FALSE, initially no one is interested in entering the critical section
    int turn : The process whose turn is to enter the critical section.
    Peterson’s Solution preserves all three conditions :
    Mutual Exclusion is assured as only one process can access the critical section at any time.
    Progress is also assured, as a process outside the critical section does not block other processes from entering the critical section.
    Bounded Waiting is preserved as every process gets a fair chance.
    Disadvantages of Peterson’s Solution
    It involves Busy waiting
    It is limited to 2 processes.
    The algorithm uses two variables, flag and turn. A flag[n] value of true indicates that the process n wants to enter the critical section. Entrance to the critical section is granted for process P0 if P1 does not want to enter its critical section or if P1 has given priority to P0 by setting turn to 0.
    P0: flag[0] = true;
    P0_gate: turn = 1;
    while (flag[1] == true && turn == 1)
    {
    // busy wait
    }
    // critical section
    ...
    // end of critical section
    flag[0] = false;
    P1: flag[1] = true;
    P1_gate: turn = 0;
    while (flag[0] == true && turn == 0)
    {
    // busy wait
    }
    // critical section
    ...
    // end of critical section
    flag[1] = false;

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

  • @helloworld12444
    @helloworld12444 3 года назад +58

    I'm watching your lectures for 2 hours and tomorrow is my final exam of OS. Thank you Sir

    • @SudhakarAtchala
      @SudhakarAtchala  3 года назад +8

      Good luck! Plz subscribe to the channel and if possible share with your friends. Thanks

  • @jaganc5159
    @jaganc5159 2 года назад +3

    Thank you sir for explaining in a simple way sir

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

      Welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.

  • @raziyasameera5868
    @raziyasameera5868 2 года назад +1

    Ur teaching is 👌iam studying two days before my exams

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

      All the best for your exam. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.

  • @jaswanthm9775
    @jaswanthm9775 4 года назад +1

    Good explanation sir,thank you sir...

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

      Hai Jaswanth, plz go through my videos once. Definitely you will like more videos. Thanks
      for your encouragement and support towards our channel. Share my sessions with your friends and subscribe to our channel.Keep on following my sessions. Thank you so much.

  • @Rishikarangoli
    @Rishikarangoli 7 месяцев назад +10

    I have got cgpa of 9.40 just because of your vidoes sir

    • @SudhakarAtchala
      @SudhakarAtchala  7 месяцев назад +1

      Keep it up 👍. Plz subscribe to the channel and if possible share with your friends. Thanks in advance..

  • @swethaakepogu8634
    @swethaakepogu8634 2 года назад +11

    Finally I understood very well. Thank you sir thanks a lot🙏

  • @jsagarbabu9128
    @jsagarbabu9128 4 года назад +7

    goog explanation sir,zero knowledge person also can understand your teaching,awesome

    • @SudhakarAtchala
      @SudhakarAtchala  4 года назад +3

      Hai Sagar, plz go through my videos once. Definitely you will like more videos. Thanks
      for your encouragement and support towards our channel. Share my sessions with your friends and subscribe to our channel.Keep on following my sessions. Thank you so much.

  • @sovahermanita44
    @sovahermanita44 3 года назад +3

    sir, what will happen if we only put while(flag[ j ]==true); as the condition ?

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

      process i have to give chance for other process also that's why we have to use 2nd condition also. Hope ur doubt clarified shrey sharma. Plz subscribe to the channel and if possible share with your friends. Thanks

  • @yogeesh_kulal02
    @yogeesh_kulal02 6 месяцев назад +2

    You saved my day.. Thank you sir❤

    • @SudhakarAtchala
      @SudhakarAtchala  6 месяцев назад +1

      Most welcome 😊. Plz subscribe to the channel and if possible share with your friends. Thanks in advance..

  • @stviewsshorts
    @stviewsshorts 4 года назад +5

    Is Peterson’s Algorithm a good solution for Critical Section problem? If yes, then why? If no, then why?

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

      Because it satisfies me,bw,progress

    • @SudhakarAtchala
      @SudhakarAtchala  4 года назад +1

      Hai Sidra , plz go through my videos once. Definitely you will like more videos. Thanks
      for your encouragement and support towards our channel. Share my sessions with your friends and subscribe to our channel.Keep on following my sessions. Thank you so much.

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

      @@SudhakarAtchala can you explain more

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

      @@stviewsshorts petersons will satisfy only when there are 2 processes ... so it definetly wont be a "good" solution when your pc is loaded with processes

  • @rathanvpoojary4885
    @rathanvpoojary4885 Год назад +2

    Thank you sir❤️🙏

    • @SudhakarAtchala
      @SudhakarAtchala  Год назад

      Most welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance..

  • @abinayamani3805
    @abinayamani3805 4 года назад +3

    Really very helpful sir! Thank you

  • @shivarajubg9626
    @shivarajubg9626 Год назад +1

    Good explaining concepts sir I
    Like you

    • @SudhakarAtchala
      @SudhakarAtchala  Год назад

      Thanks for liking. Plz subscribe to the channel and if possible share with your friends. Thanks in advance..

  • @soumyadipbanerjee5726
    @soumyadipbanerjee5726 4 года назад +3

    Thank you so much sir❤

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

      Hai Soumyadip, plz go through my videos once. Definitely you will like more videos. Thanks
      for your encouragement and support towards our channel. Share my sessions with your friends and subscribe to our channel.Keep on following my sessions. Thank you so much.

  • @shriyajukanti6857
    @shriyajukanti6857 4 года назад +2

    Thank you sir... Very helpful explanation

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

      Plz subscribe to our channel and if possible share with your friends. Keep on following channel. Thanks

  • @user-dk3oq6jr6d
    @user-dk3oq6jr6d 2 года назад +2

    Thank you for this beautiful explanation sir

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

      You are most welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.

  • @binamonisaidulu54
    @binamonisaidulu54 Год назад +1

    Thank u very much sir for your clear explanation

    • @SudhakarAtchala
      @SudhakarAtchala  Год назад

      You are most welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance..

  • @pvlakshmipriya5382
    @pvlakshmipriya5382 3 года назад +2

    Clear explanation sir thank you

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

      So nice of you Lakshmi Priya. Plz subscribe to the channel and if possible share with your friends. Thank you so much

  • @rahulvarma7257
    @rahulvarma7257 4 года назад +2

    wonderful explanation sir 👏👏👏. you made it very simple

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

      Hai Rahul, plz go through my videos once. Definitely you will like more videos. Thanks
      for your encouragement and support towards our channel. Share my sessions with your friends and subscribe to our channel.Keep on following my sessions. Thank you so much.

  • @mastiiseries8120
    @mastiiseries8120 2 года назад +2

    Very well explained sir Thanks

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

      Welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.

  • @aravinderramreddy6716
    @aravinderramreddy6716 3 года назад +2

    thank you sir for your clear explanation

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

      You are most welcome aravind. Plz subscribe to the channel and if possible share with your friends. Thanks

  • @leelamanikrishnapeta6211
    @leelamanikrishnapeta6211 Год назад +1

    Great explanation sir👏👏.Thank you

    • @SudhakarAtchala
      @SudhakarAtchala  Год назад

      You're most welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance..

  • @whateverittakes7929
    @whateverittakes7929 Год назад +1

    Never understood process syn better tqsm 💖

    • @SudhakarAtchala
      @SudhakarAtchala  Год назад

      Most welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance..

  • @chaitanyag999
    @chaitanyag999 3 года назад +1

    best explanation! sharing this to all my friends

  • @SiddheshShankarBtech
    @SiddheshShankarBtech 3 года назад +1

    very helpful sir
    thanks a lot

  • @manasatadigadapa4952
    @manasatadigadapa4952 3 года назад +1

    Really superb explanation sir

  • @ramramkrishna8082
    @ramramkrishna8082 3 года назад +1

    Well explained sir

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

      Thanks and welcome Ram Krishna. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.

  • @sugatasaha4423
    @sugatasaha4423 3 года назад +1

    Great Explanation Sir.

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

      Thanks and welcome Sugata Saha. Plz subscribe to the channel and if possible share with your friends. Thank you so much.

  • @nisha.k
    @nisha.k 6 месяцев назад

    really you teach so gud line by line nd finally understood very well thank you so much sir

    • @SudhakarAtchala
      @SudhakarAtchala  6 месяцев назад

      Glad to hear that. Plz subscribe to the channel and if possible share with your friends. Thanks in advance..

  • @lalithav3079
    @lalithav3079 7 месяцев назад

    So many channels failed to explain the concept which you were able to do well sir. Thank you a lot! May God bless you!

    • @SudhakarAtchala
      @SudhakarAtchala  7 месяцев назад

      You are most welcome. Plz subscribe to the channel and if possible share with your friends. Thanks in advance..

  • @gopavaramsaimadhuree520
    @gopavaramsaimadhuree520 3 года назад +2

    Amazing lecture.
    I understood very clearly
    Thank u sir

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

      You are most welcome Sai Madhuree. Plz subscribe to the channel and if possible share with your friends. Thanks in advance.