Q1. What are the uses of Semaphore?
Ans. The other than avoiding race condition semaphores are used for synchronization. The full and empty semaphores are needed to guarantee that certain event sequences do or so not occur. In this case, they ensure that the producer stops running when the buffer is full, and that the consumer stops running when it is empty.