Working mutual exclusion using semaphores

This is the code that is working.