Peterson's Solution for critical section problem

Sdílet
Vložit
  • čas přidán 8. 09. 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;

Komentáře • 63

  • @helloworld12444
    @helloworld12444 Před 3 lety +57

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

    • @SudhakarAtchala
      @SudhakarAtchala  Před 3 lety +8

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

  • @Rishikarangoli
    @Rishikarangoli Před 7 měsíci +8

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

    • @SudhakarAtchala
      @SudhakarAtchala  Před 7 měsíci +1

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

  • @swethaakepogu8634
    @swethaakepogu8634 Před 2 lety +11

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

  • @lalithav3079
    @lalithav3079 Před 6 měsíci

    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  Před 6 měsíci

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

  • @yogeesh_kulal02
    @yogeesh_kulal02 Před 5 měsíci +2

    You saved my day.. Thank you sir❤

    • @SudhakarAtchala
      @SudhakarAtchala  Před 5 měsíci +1

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

  • @jsagarbabu9128
    @jsagarbabu9128 Před 4 lety +7

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

    • @SudhakarAtchala
      @SudhakarAtchala  Před 4 lety +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.

  • @jaganc5159
    @jaganc5159 Před 2 lety +3

    Thank you sir for explaining in a simple way sir

    • @SudhakarAtchala
      @SudhakarAtchala  Před 2 lety

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

  • @raziyasameera5868
    @raziyasameera5868 Před rokem +1

    Ur teaching is 👌iam studying two days before my exams

    • @SudhakarAtchala
      @SudhakarAtchala  Před rokem

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

  • @binamonisaidulu54
    @binamonisaidulu54 Před 11 měsíci +1

    Thank u very much sir for your clear explanation

    • @SudhakarAtchala
      @SudhakarAtchala  Před 11 měsíci

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

  • @user-dk3oq6jr6d
    @user-dk3oq6jr6d Před 2 lety +2

    Thank you for this beautiful explanation sir

    • @SudhakarAtchala
      @SudhakarAtchala  Před 2 lety

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

  • @shivarajubg9626
    @shivarajubg9626 Před rokem +1

    Good explaining concepts sir I
    Like you

    • @SudhakarAtchala
      @SudhakarAtchala  Před rokem

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

  • @rathanvpoojary4885
    @rathanvpoojary4885 Před rokem +2

    Thank you sir❤️🙏

    • @SudhakarAtchala
      @SudhakarAtchala  Před rokem

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

  • @whateverittakes7929
    @whateverittakes7929 Před rokem +1

    Never understood process syn better tqsm 💖

    • @SudhakarAtchala
      @SudhakarAtchala  Před rokem

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

  • @mastiiseries8120
    @mastiiseries8120 Před 2 lety +2

    Very well explained sir Thanks

    • @SudhakarAtchala
      @SudhakarAtchala  Před 2 lety

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

  • @nisha.k
    @nisha.k Před 5 měsíci

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

    • @SudhakarAtchala
      @SudhakarAtchala  Před 5 měsíci

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

  • @pvlakshmipriya5382
    @pvlakshmipriya5382 Před 3 lety +2

    Clear explanation sir thank you

    • @SudhakarAtchala
      @SudhakarAtchala  Před 3 lety

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

  • @shriyajukanti6857
    @shriyajukanti6857 Před 4 lety +2

    Thank you sir... Very helpful explanation

    • @SudhakarAtchala
      @SudhakarAtchala  Před 4 lety

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

  • @leelamanikrishnapeta6211

    Great explanation sir👏👏.Thank you

    • @SudhakarAtchala
      @SudhakarAtchala  Před rokem

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

  • @abinayamani3805
    @abinayamani3805 Před 4 lety +3

    Really very helpful sir! Thank you

  • @aravinderramreddy6716
    @aravinderramreddy6716 Před 3 lety +2

    thank you sir for your clear explanation

    • @SudhakarAtchala
      @SudhakarAtchala  Před 3 lety

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

  • @soumyadipbanerjee5726
    @soumyadipbanerjee5726 Před 4 lety +3

    Thank you so much sir❤

    • @SudhakarAtchala
      @SudhakarAtchala  Před 4 lety

      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.

  • @rahulvarma7257
    @rahulvarma7257 Před 4 lety +2

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

    • @SudhakarAtchala
      @SudhakarAtchala  Před 4 lety

      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.

  • @SiddheshShankarBtech
    @SiddheshShankarBtech Před 3 lety +1

    very helpful sir
    thanks a lot

  • @manasatadigadapa4952
    @manasatadigadapa4952 Před 3 lety +1

    Really superb explanation sir

  • @chaitanyag999
    @chaitanyag999 Před 3 lety +1

    best explanation! sharing this to all my friends

  • @sugatasaha4423
    @sugatasaha4423 Před 3 lety +1

    Great Explanation Sir.

    • @SudhakarAtchala
      @SudhakarAtchala  Před 3 lety

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

  • @ramramkrishna8082
    @ramramkrishna8082 Před 3 lety +1

    Well explained sir

    • @SudhakarAtchala
      @SudhakarAtchala  Před 3 lety

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

  • @gopavaramsaimadhuree520
    @gopavaramsaimadhuree520 Před 3 lety +2

    Amazing lecture.
    I understood very clearly
    Thank u sir

    • @SudhakarAtchala
      @SudhakarAtchala  Před 3 lety

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

  • @jaswanthm9775
    @jaswanthm9775 Před 4 lety +1

    Good explanation sir,thank you sir...

    • @SudhakarAtchala
      @SudhakarAtchala  Před 4 lety

      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.

  • @sovahermanita44
    @sovahermanita44 Před 3 lety +3

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

    • @SudhakarAtchala
      @SudhakarAtchala  Před 3 lety

      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

  • @stviewsshorts
    @stviewsshorts Před 4 lety +5

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

    • @SudhakarAtchala
      @SudhakarAtchala  Před 4 lety

      Because it satisfies me,bw,progress

    • @SudhakarAtchala
      @SudhakarAtchala  Před 4 lety +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 Před 4 lety

      @@SudhakarAtchala can you explain more

    • @gautamshenoy6170
      @gautamshenoy6170 Před 3 lety

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