Peterson's Solution for critical section problem

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
now let's see about Pedersen solution in order to solve the critical section problem there are two solutions the fastest solution is software solution and the second solution is hardware solution here the Peterson solution is nothing but the software solution so Peterson solution is mainly useful in order to solve critical section problem Peterson solution is nothing but a software solution we know what is a software software means a program programming's a collection of instructions so we can say that Peterson solution is a program which is useful in order to solve the critical section problem here we can use the Peterson solution only where there are two processes which involves critical section that means when two processes shades the common good then only we use a period sub solution suppose the system contains more than two processes then periods and solution is not possible so that is the first point here we can uses the bijection solution to solve a critical section problem only when the system contains would eat two processes if the system contains more than two processes then the third sub solution is not sufficient we have to use a support algorithm let us assume that here we have two processors P naught and beaver next here we are using two data structures the first one is in term so Tammy's an additional variable term indicates whose turn it is - yet then into the critical section here the value of the terms may be either zero or one suppose if the value is 0 then it specifies that P not yet that's into the critical section suppose you have value is fun that it specifies that there is a possibility that p1 may enters into the critical section so here the value of 10 maybe is at 0 or 1 now Alexis the next two data structure boolean flat off to boolean means it may hold yeah that true or false we have Flag is in a way the size of the flag is two so that means it holds the flag of zero value our flag of one so the value of flag of zero and flag of one may be either true or false suppose the flag of zero is true then it specifies that the process P naught is interested to enter into the critical section suppose if flag of zero is false that it specifies that P naught is not interested to enter into the critical section here the initial values of flag of zero and flag of 1 are false so he divorced that initially both the processes such as P naught and B 1 are not interested to enter into the critical section so this is about the data structures which we can use us in the Peterson solution now let's see the so you shall get structural process P Adams why not true so it specifies that the condition is always true so this block is nothing but entry section this is nothing but critical section very has the state is nothing but paint resection exist section so fast the intersection will be executed so in the intersection the first statement is flaca is equal to 2 so it specifies that the process P I is interested to enter into the critical section the next statement Tammy is equal to J so it specifies that P is giving the chance for J to enter into the critical section so term so what is the use of time it indicates whose turn it is to enter into the critical section so that means the process P is giving a chance for the J to attend into the critical section next while flag of J is equal to 2 and this is nothing but loss he can add operator and tantowel is equal to J next at the end of this we use a semicolon so that means if the we know what is classically and if both the conditions are true then the result is true so if both the conditions are true then it specifies that the process P say is in the critical section so P AE has to wait suppose if one of these two condition is false or both the conditions are false that bi enters into the critical section so if these two conditions are true then PA reminds in the critical section P a remains in the vine you so let's shake about the conditions so what is the first condition flag off Jason Seifer do two so it specifies that the process P say is also interested to enter into the critical section as well as if k is equal to j then that means if both the conditions are true it specifies that PA is interested to return to the critical section or Pisa is already in the technical section so PA process has to face in this condition it is findable so that's why we you just this semicolon let us assume that the process PC is not interested to enters into the critical section so this condition becomes false here my process PA is not interested to index into the critical section so false to logical it means false so when one of the condition is false that the entire result is false so whenever the condition is false and the control comes into the critical section the next the corresponding process PA execute the critical section and if it is completed its operations then PA comes up from the critical section so whenever process PA comes out from the critical section then it executes if Z section in the exit section it executes a statement as flaca Phi is equal to false so it specifies that PA comes out from the critical section so now P say can get heads into the critical section so this is about the structure of process P and so let us take the code for PC and Bhima let us consider about PC so what is the past event flag of 0 is equal to 2 so it specifies that PJ is interested to enter into the critical section next tag is equal to 1 so that means it is giving a chance for the other process that is people to enter into the critical section next P naught is shaking whether P 1 is interested to attend to the critical section or whether P 1 is already in the critical section or not so white flag up for double is equal to 2 and that number is equal to 1 if if these flow conditions are true that it specifies that P 1 may be in the critical section or Bremen is interested to get seneschal so the peanut process has to wait until pu and closest comes out from the medical section suppose e4 of the condition is false that means suppose if this condition is false flag operation suppose if this condition is false that means suppose if b1 is not interested to reenter into the critical section so first Lu means false so the antenna expression is false so the control enters into the critical section next closest three not completed all its operations in the critical section so while spirit completed or its operations then he comes out from the middle section and in the existing shape it executes an operation called flag of 0 is equal to false so it specifies that be rowdy is no longer belongs to the critical section so now the process p1 may enter into the critical section so like this we have written the code for p1 also fast if p1 wants to enter into the critical section then it executes say statement like flag of 1 is equal to true it specifies that p1 he is interested to be ended into the critical section next tag is equal to 0 that means the process p1 is giving a chance for P not to enter into the critical section next p1 v checks whether p not already the wife already entered into the critical section or whether P note is interested to enter into the critical section or not so that's why it is checking whether flag of conc first you are not suppose if flag of Geo is equal to true then it specifies that P naught may be in the critical section or P naught may be interested to enter into the critical section already it is it's Danny has zero so that p1 process revenge anti-iran process comes out from the critical section suppose if P naught is not interested to enter into the critical section then it's flag value is false so this condition he becomes false numb so if for of the condition is false then the controller comes from the by noon that's the video section will be executed so that means p1 execute sits shared code after completing its operations then p1 comes out from its PD dissection and it executes a statement called flag of what is equal to false it specifies that paper rolled out there belongs to the critical section now P not can attach it to the critical section we know that any solution to the critical section problem must satisfy three requirements the first experiment is mutual exclusion the second requirement is progress the third requirement is Bob get ready so now we have to check whether Peterson solution is satisfying these three requirements or not so what is the first requirement mutual exclusion so what is mutual exclusion the critical section through cuttings only one process edited the other process should be allowed into the vertical section only when the critical section is free so that means if the critical section contains a process then no process should be allowed to enter into the critical section so editor critical section should contain only one process so let's check whether it is possible or not so let us assume that we know D is interested to enter into the critical section so execute this statement flag of zero is equal to two next it executes a statement that is equal to 1 next it executes the statement black of body is equal to true and tan double is equal to one initially p1 is not interested to attend to the critical section so this is false various that is equal to but this is true so false blue means false so the control comes from the by loop and P not enters into the critical section now P naught is your wild level in the critical section now shake with the pre-work enters into the critical section or not now let us assume that now p1 is trying to attack reception so fast it executes the statement flag off what is equal to true next in execute the statement that is equal to zero next statement flag of zero is equal to true but what is flag up to you what is flag of zero already not execute its flag value flag of zero is true so the value of the flag of zero is two through double is equal to two condition is true so that means critical section already contains P not process as well as what is that value zero so both the conditions are true so that means the process p1 has to vent and in the process P dog comes up from the rear section now let us assume that P not completed all its operations in the critical section and P not caps off from the critical section so whenever P naught comes up from the reading section then it executes a statement called flag of 0 is equal to false so now what is flag of 0 now now P naught is not in the critical section and he executes the statement called lack of 0 is equal to false not allowed so nowadays I assume that P the process P but wants to enter into the critical section so P 1 executes this condition so flag of 4 is equal to 2 next ad is equal to 0 next why flag of 0 double is equal to true but what is flag of zero flag of 0 is false the false number is equal to 2 so this condition is false next this condition is true so fast-moving is false so the entire expression is false so the control comes over from the bag loop and p1 process enters into the critical section now P 1 is in the critical section now people completed all its operations and after that it executes the statement count flag of 1 is equal to zero flag of 1 is equal to false so with this we can conclude that editing is that P naught or P 1 can index into the critical section so we can say that the first condition that is the first requirement that is mutual exclusion be satisfied negative is that P dot or p1 can enters into the video section now let's in the second requirement progress so what is the progress so progress means so no net is issued that the critical section is free and several processes such as P naught P 1 P 2 are interested to intercept to the critical section then the decision about which process should get there simply the critical section should be taken in a finite amount of time it should not be postponed for a longer period of time and we have to consider only the interested processes which are comes to the critical section so not interested processes should not be considered here so that is nothing but progress so progress means out of all the available processes we have to consider only the interested processes which should index into the critical section as well as the corresponding decision should be taken in a finite amount of time whereas a should that we are executing P naught and here we are executing the statement by a cop 1 is equal to 2 let us assume that he now P 1 is not interested to be attending to the critical section so what is the initial value of flag of 0 and flag of 1 the initial value of flag of 0 and flag out for his false it specifies that initially P naught is not interested to edit it in the critical section as well as P 1 is not interested to enter into the critical section so initially if we do not executed a statement called backup 0 is equal to true so you specify is that P Nadi's interest set to enter into the critical section next time is equal to 1 so that means P dot is giving a chance for p1 to enter into the critical section next Y flag of 1 is equal to true but what is flag of fun my addition baño flag offer is false that means P body is not interested to yet a particular section so that means here the processes which are not interested to enter into the critical section so those processes are not considered here and here the decision is taking in you find the amount of time so that means here the P money is not interested to enter into the critical section so obviously that conditions will become false so P naught comes into the critical section so if you take this one that is if you that this blog is executed fast so flag Hockman is equal to true it specifies that P one is interested to be added into that media section 10 is equal to zero that means the process P 1 is giving a chance for P dot to enter into the critical section next edie taking me the flag of zero is true or false but the initial value flag of zero is false it specifies that the process P dot is not interested to get into the intersection so P naught should be covered peanut should be not considered now so we can say that the progress is also satisfied why because here we are considered in Goudy the interest rate processes and the decision is taking in a finite amount of time by taking go in one condition that is this condition and already the next one bounded ready so what is found admitting the decision about which process will enters into the airborne means there should be a bound bound means there should be a limit on number of times a process can be entered into the critical section with other process request to enter into the critical section let us assume that this is nothing but a critical section P 1 is in the critical section and P 2 sends a request to enter into the critical section but video section contains Pima let us assume that P 1 completed or its operations so P 1 comes out from the critical section after that assumes that p1 also put a request to enter into the critical section so now there is a commutation between P 1 and P 2 so which process needs to be entered into the critical section let us assume that the operating system giving a chance for P 1 so issues that people completed all its operations and p1 comes out from the critical section one more type even puts a request to be added into the critical section one more time operating system giving a chance for p1 so he had power rating means they should be about there should be a limit on temper of times a process can enter into the critical section if further process is waiting to enter into the critical section so only a limited number of times we have to you know p1 to enter into the critical section otherwise be to starvation rather for P 2 and P due process will die ok let us say when that bounded reading is satisfied or not here ok so what is for it is ready here we have to give a limited number of chances for a corresponding process if you considered P not some whenever V naught comes out from the critical section then it says it's flat Valley as false so that specifies that P naught is not interested to enter into the critical section so during that time people can execute his code so what is flag of 0 here P 1 plan of 0 what is P naught back of the response so false double is equal to true so this condition is false so that people can intercept is a critical section so like face so 41 also very much even comes up from the intersection it executes its flag of one man so flag up what is equal to false it specifies that T buddy is not interested to get into the critical section so the process P naught will be given charge snow so that the chances will be given for each process to enter into the critical section so that there is no starvation will have done here so we can say that Peters and so region is the best solution in order to solve the critical section problem with the help of a program so this is about the Peterson
Info
Channel: Sudhakar Atchala
Views: 18,515
Rating: 4.8454547 out of 5
Keywords: process Synchronization, The Critical-Section Problem, Peterson‘s Solution, Synchronization Hardware, Semaphores, Classical Problems of Synchronization, Monitors, Synchronization Examples, sudhakar, atchala, operating system, os, lectures, Producer Consumer Problem, Classical Problems Of Synchronization, Bounded Buffer Problem, producer consumer problem using semaphore, critical section problem in operating system, mutual exclusion, progress, Bounded Waiting, requirements
Id: uj-zhs7cUSI
Channel Id: undefined
Length: 21min 41sec (1301 seconds)
Published: Thu Oct 17 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.