Peterson's Solution for critical section problem

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ต.ค. 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

  • @Rishikarangoli
    @Rishikarangoli 8 หลายเดือนก่อน +11

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

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

      Keep it up 👍. 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..

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Really very helpful sir! Thank you

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

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

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

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

    very helpful sir
    thanks a lot

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

    best explanation! sharing this to all my friends

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

      many many Thanks for sharing revanth.

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

    Really superb explanation sir

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

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

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

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

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

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

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

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