Let Binary semaphore s initialized to 1 is shared among n processes .
Below is the code snippet to illustrate Mutual Exclusion
Let Suppose Pi process wants to enter the critical section so it will execute below code and later on if any other process wish to enter critical section it can't do so as wait(s) is 0 now .Once the Pi process signals s only then other process will be able to enter critical section thereby achieving Mutual exclusion.
do(
wait(s);
//Critical Section
signal(s);
}while(true);
Hope if this clarifies.