MCQs City stays free thanks to ads. Please turn off your ad blocker for this site so content and features keep working.
Operating System
Classic Sync Problems
Q
Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned. (GATE 2010) Method used by P1 : while(S1==S2); Critical section S1 = S2; Method used by P2 : while(S1!=S2); Critical section S2 = not(S1); Which of the following statements describes properties achieved?
AA. Mutual exclusion but not progress
BB. Progress but not mutual exclusion
CC. Neither mutual exclusion nor progress
DD. Both mutual exclusion and progress
Correct Answer:
D. D. Both mutual exclusion and progress
Explanation:
The while(S1==S2) or while(S1!=S2) loops will work as a mutex. When either P1 or P2 enters the Critical section (CS), they will make sure to change the values of S1 or S2 upon exit from the CS such that the other process enters the CS while that process waits on the mutex.