3 3 votes What is Lock Variable solution to critical section problem? Does it satisfy all the conditions like Mutual exclusion, Bounded waiting and Progress? Theory of Computation operating-system critical-section + – Warlock lord 5.3k views answer comment Share Follow Print See all 12 Comments 12 12 Comments reply Bikram commented Aug 21, 2017 reply Follow flag Yes, Lock Variable solution to critical section problem is use to solve all these 3 ME, progress and BW . 0 0 replyShare Pinaki Dash commented Aug 21, 2017 reply Follow flag Sir, I think ME is not guaranteed in Lock variable solution to CS problem. 0 0 replyShare Warlock lord commented Aug 21, 2017 reply Follow flag @Dinkar Can you please lead me to a reference to support this? :) 0 0 replyShare G.K.T commented Aug 21, 2017 reply Follow flag Sir how mutual exclusion is satisfied ? are you considering any modified version of lock variable solution ? 0 0 replyShare Warlock lord commented Aug 21, 2017 reply Follow flag Can you tell me which lock variable does not support? I know semaphore supports all. Peterson's supports all except may be bounded waiting. (Am I right?) Can you tell me what lock variable does not support mutual exclusion? Because I think the the whole purpose of lock was to achieve mutual exclusion. 1 1 replyShare Bikram commented Aug 21, 2017 reply Follow flag Yes, The whole purpose of use Lock is to to achieve Mutual Exclusion . If there is no lock, there is No order means more than one process can enter into CS at a same time ..so ME does not satisfy .. And peterson's algo supports all 3 --> ME, BW and progress ( as there is no deadlock ) . From wiki The algorithm satisfies the three essential criteria to solve the critical section problem, The three criteria are mutual exclusion, progress, and bounded waiting https://en.wikipedia.org/wiki/Peterson%27s_algorithm#The_algorithm 0 0 replyShare Pinaki Dash commented Aug 21, 2017 reply Follow flag I was talking about the simplest implementation using Lock variable. It is like: Initially Lock=0(indicating CS is free) Entry section: while(lock!=0); set Lock=1; CS Exit section: set Lock=0; Here as you can see ME is not guaranteed. Peterson's solution, however, satisfies ME, there is no doubt. 0 0 replyShare G.K.T commented Aug 21, 2017 reply Follow flag In addition to locking a variable peterson is also using the array like interested[2] or something which helps to ensure progress . if simply we use locking variable like using a flag variable if flag is set to 0 CS if free you may enter flag is 1 indicates CS is busy but with some combination of preemption multiple processes may enter in cs here we are neither checking for strict alteration(Decker's) or if a process want to go or not into the CS (like in peterson's). 0 0 replyShare Bikram commented Aug 21, 2017 reply Follow flag @ G.K.T and @Pinaki Dash Read this thread : https://gateoverflow.in/72010/difference-between-dekkers-peterson-solutions-critical-section https://cs.stackexchange.com/questions/12621/contrasting-peterson-s-and-dekker-s-algorithms ( see 2nd answer ) https://cs.stackexchange.com/questions/60235/is-bounded-waiting-ensured-in-given-version-of-dekkers-solution-for-critical-se ( see BW is satisfied in Dekker's algo too ) so it all means the use of Lock is to guarantee that it satisfies all three conditions : ME Progress Bounded waiting and both Peterson and Dekker's algo satisfy all 3 conditions. 0 0 replyShare Pinaki Dash commented Aug 21, 2017 reply Follow flag @Bikram Sir, I was not talking about Peterson's or Dekker's. I was referring to the simplest algo using Lock variable only and nothing else, for which I have written the pseudocode above. Thanks for all the references. 0 0 replyShare Bikram commented Aug 21, 2017 reply Follow flag @pinaki yes, i have seen it.. but the thing is we use lock to ensure Mutual exclusion property. see the definition of lock , it is an object that can only be owned by a single thread at any given time . so that means no two threads can acquire a same lock at same time , which leads to Mutual exclusion, is not it ? And there are 2 operations we can perform on a lock: acquire: mark the lock as owned by the current thread; if some other thread already owns the lock then first wait until the lock is free. Lock typically includes a queue to keep track of multiple waiting threads. release: mark the lock as free (it must currently be owned by the calling thread). So all it means ME is satisfied using Lock .. infact the purpose of lock is this . And a good CS problem satisfy all 3 conditions like ME, BW and progress. 0 0 replyShare Arpon commented Nov 19, 2021 reply Follow flag lock variable does NOT guarantee MUTUAL EXCLUSION BOSS. those who are watching, don’t go by this. i think bikram you are making a mistake. 0 0 replyShare Please log in or register to add a comment.
0 0 votes Refer to this PDF: https://cseweb.ucsd.edu/classes/fa05/cse120/lectures/120-l5.pdf smsubham answered Aug 21, 2017 smsubham comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes Peterson and Dekker's algo, both solves : ME, BW and progress these three conditions. Also progress is satisfied so deadlock is not possible ( bcoz progress done in finite time where as deadlock is infinite waiting). Reference : https://cs.stackexchange.com/questions/12621/contrasting-peterson-s-and-dekker-s-algorithms ( see 2nd answer , the table) https://cs.stackexchange.com/questions/60235/is-bounded-waiting-ensured-in-given-version-of-dekkers-solution-for-critical-se Bikram answered Aug 21, 2017 • edited Aug 21, 2017 by Bikram Bikram comment Share Follow See all 6 Comments 6 6 Comments reply Show 3 previous comments Shivansh Gupta commented Aug 21, 2017 reply Follow flag I mistook Dekker's as strict alternation.. 0 0 replyShare Shivansh Gupta commented Aug 21, 2017 reply Follow flag yes Dekker's satisfies all the three properties. 0 0 replyShare Karan Dodwani 1 commented Aug 23, 2018 reply Follow flag @Bikram Sir, In my understanding Lock Variable does not hold Mutual Exclusion and Bounded Waiting it can only hold Progress. (If_i_am_Wrong) Please give an example on Lock Variable . 0 0 replyShare Please log in or register to add a comment.
0 0 votes lock variable solution does not satisfy Mutual exclusion. sh2mohit111 answered Oct 12, 2017 sh2mohit111 comment Share Follow 0 reply Please log in or register to add a comment.