Two processes X and Y need to access a critical section. Consider the following synchronization construct used by both the processes Process ? /* other code for process ? */ while(true) { varP = true; while(varQ == true) { /* Critical Section */ varP = false; } } /* other code for process ?? */ Process ? /* other code for process ? */ while(true) { varQ = true; while(varP == true) { /* Critical Section */ varQ = false; } } /* other code for process ? */ Here, varP and varQ are shared variables and both are initialized to false. Which one of the following statements is true?
Two processes X and Y need to access a critical section. Consider the following synchronization construct used by both the processes Process ? /* other code for process ? */ while(true) { varP = true; while(varQ == true) { /* Critical Section */ varP = false; } } /* other code for process ?? */ Process ? /* other code for process ? */ while(true) { varQ = true; while(varP == true) { /* Critical Section */ varQ = false; } } /* other code for process ? */ Here, varP and varQ are shared variables and both are initialized to false. Which one of the following statements is true? Correct Answer The proposed solution prevents deadlock but fails to guarantee mutual exclusion
[ alt="z,0401" src="//storage.googleapis.com/tb-img/production/17/05/z%2C0401.JPG" style="height:250px; width:279px">
As both processes can enter in critical section at the same time, mutual exclusion is not satisfied.