0 votes 0 votes I) CODE 1 guarantees Mutual Exclusion II) CODE 2 guarantees Mutual Exclusion III) CODE 2 leads to Deadlock Which of the above statements are TRUE???? 1. I and II only 2. II and III only 3. I and III only 4. All I,II and II Deepanshu asked Sep 21, 2018 Deepanshu 619 views answer comment Share Follow See all 15 Comments See all 15 15 Comments reply himgta commented Sep 21, 2018 reply Follow Share is th answer 4?? 0 votes 0 votes Shaik Masthan commented Sep 21, 2018 reply Follow Share @himgta How code1 guarantees Mutual exclusion? 0 votes 0 votes himgta commented Sep 21, 2018 reply Follow Share @Shaik Masthan while flag of other process is true thn it will block in the while loop...isn't it?? 0 votes 0 votes Shaik Masthan commented Sep 21, 2018 reply Follow Share given that flag of other process is false initially. Hint:- preempt the process after checking 2nd while loop. 0 votes 0 votes Deepanshu commented Sep 21, 2018 reply Follow Share CORRECT OPTION 2ND 0 votes 0 votes Shaik Masthan commented Sep 21, 2018 reply Follow Share @Deepanshu i am also trying to say, only 1st statement is wrong. 0 votes 0 votes Magma commented Sep 21, 2018 reply Follow Share P1 is symmetric means ?? 0 votes 0 votes Shaik Masthan commented Sep 21, 2018 reply Follow Share actually in the code they have used flag[0], it should be replaced by flag[i] What is symmetric means? in place of i, you have to place 0 if you are P0 in place of i, you have to place 1 if you are P1 0 votes 0 votes Deepanshu commented Sep 21, 2018 reply Follow Share @Shaik Masthan I AM JUST TELLING THE ANSWER FROM TEST SERIES :) I AM STILL CONFUSED ABOUT THIS MUTUAL EXCLUSION POINT TELL ME WHERE AM I WRONG SO CODE 1 1ST STATEMENT------ flag[i] is false means means both processes p0 and p1 flag is false no one wants to enter critical section right now 2ND STATEMENT---------- While (true) means while condition is satisfied or true 3RD STATEMENT -------------------- While (flag[1]) is true means flag of 1st process is true . Up to then we are in while loop . when this condition false we go to next statement so this means flag[1] is false and flag[0] can enter . SO IT IS MUTUAL EXCLUSION MEANS PROCESS 0 ENTERS OONLY WHEN 1 IS FALSE PLEASE HELP HOW 1 IS NOT MUTUALLY EXCLUSIVE EDIT THIS COMMENT WHERE ANYTHING IS WRONG .THEN YOU WILL NOT HAVE TO WRITE WHOLE EXPLANATION AGAIN :) 0 votes 0 votes Shaik Masthan commented Sep 21, 2018 reply Follow Share SO CODE 1, starts with P0 1ST STATEMENT------ flag[i] is false means means both processes p0 and p1 flag is false no one wants to enter critical section right now 2ND STATEMENT---------- While (true) means while condition is satisfied or true 3RD STATEMENT -------------------- While (flag[1]) is true means flag of 1st process is true . Up to then we are in while loop . when this condition false we go to next statement. Preempt the process.===> P0 is preempted ( but remember that flag[0]=false only) starts with P1 1ST STATEMENT------ flag[i] is false means means both processes p0 and p1 flag is false no one wants to enter critical section right now 2ND STATEMENT---------- While (true) means while condition is satisfied or true 3RD STATEMENT -------------------- While (flag[0]) is true means flag of P0 process is true . Up to then we are in while loop . when this condition false we go to next statement. so this means flag[1] is true and entered in CS ∴ Now in Critical section P1 is present., Now Preempt the process.===> P0 it will also can enter into CS SO IT IS NOT SATISFIES the MUTUAL EXCLUSION 2 votes 2 votes himgta commented Sep 21, 2018 reply Follow Share @Shaik Masthan Thanks for correcting me! 0 votes 0 votes Prince Sindhiya commented Sep 28, 2018 reply Follow Share I think no one is correct 1 and 2 both doesn't satisfy ME and 2 will not go in deadlock 0 votes 0 votes Shaik Masthan commented Sep 28, 2018 reply Follow Share @prince Can you justify your statement s on code2 ? 0 votes 0 votes Prince Sindhiya commented Sep 28, 2018 i edited by Shaik Masthan Jan 2, 2019 reply Follow Share @shaikh bro In second code flag[1] is always false no one is going to make it true ,so both p0 and P1 can enter into cs 0 votes 0 votes Shaik Masthan commented Jan 2, 2019 reply Follow Share it is not, flag[0], it should be flag[i] in the both codes... it is a typing mistake only 0 votes 0 votes Please log in or register to add a comment.