semaphore is a variable providing mutual exclusion in following manner- -It consist of two function called wait and signal, wait() { while(semav==0); semav--; } signal() { semav++; } where semav is semaphore. we apply wait() and signal() in following manner- while(true) { ; wait() signal() } note that wait() always comes before signal(), a process is not allowed to execute critical section if the semaphore has a value 0 i.e. at most one process can execute critical section at a time.