Process P1 |
Process P2 |
P(S1) |
P(S1) |
P(S2) |
P(S2) |
Critical Section |
Critical Section |
V(S2) |
V(S1) |
V(S1) |
V(S2) |
In one of the Gateoverflow tests, this question was given and it was told that in the above case mutual exclusion is not guaranteed. But I can't understand why. As far as I see it, when any process accesses the Critical Section, both Semaphore S1 and S2 must be locked. When even one lock could suffice, here both are locked before accessing the critical section. As far as the order of unlocking, I dont see a problem there. Can someone please explain why mutual exclusion is not guaranteed?