# difference among Critical Section ,Mutual Exclusion and Semaphore

1.3k views

difference in following: [i] mutual exclusion [ii] critical section [iii] semaphore

retagged

critical section anything...file,code,memory,register,colddrink,food which is "shared" by two processes..

mutual exclusion...if a process is inside the critical section.....other process shouldnt enter inside...like u r in a washroom..till that time no one should enter..

semaphore...a "variable"...a protected variable on which read modify etc happens automatically in kernal mode....like before entering washroom u have kept a bodygaurd ouside who will prevent others from entering..and when u comes out...it is removed...P and V are the operations to do so...

selected
0
When examples bare taken from our daily life and become a model or prototype in complex topic , that topic become easy to understand and no one can forget.

## Related questions

1
416 views
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 ... 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?
1 vote
Can Mutual exclusion can be enforced with a general semaphore initial value is greater than 1 ? I think yes. Consider a semaphore $S = 2$, and following code segment for both processes. P(S); P(S); <Critical Section> V(S); V(S);