CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

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.

Method used by P1 Method used by P2
while (S1 == S2); Critica1 Section S1 = S2; while (S1 != S2); Critica1 Section S2 = not (S1);
Which one of the following statements describes the properties achieved?

A
Neither mutual exclusion nor progress
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
Mutual exclusion but not progress
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
C
Both mutual exclusion and progress
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
Progress but not mutual exclusion
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is B Mutual exclusion but not progress
P1 P2
while (S1 == S2); Critica1 Section S1 = S2; while (S1 != S2); Critica1 Section S2 = Not (S1);

We initially take S1=1, and S2=1
When P1 execute S1 = S2 then it do nothing and process P1 go into critical section after executing it make the value of S1 = S2 and when P1 execute then P2 not execute because that checks different conditon in while so both show mutual exclusion. But progress is not shown by these two because in this one process can be delayed infinitely.

Because again both P1 make its own condition true(S1 = S2 and S2 = not (S1);).

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Critical Section Problem and Conditions
OTHER
Watch in App
Join BYJU'S Learning Program
CrossIcon