Semaphore S
Achieve mutual exclusion between processes.
Semaphore E
Define the empty space in the buffer.
Semaphore F
Define the space that is filled by the producer.
wait()
Decrease the semaphore variable by 1.
signal()
Increase the semaphore variable by 1.
void producer() {
while(T) {
produce()
wait(E)
wait(S)
append()
signal(S)
signal(F)
}
}
If the buffer is full i.e. āEā is ā0ā, the program will stop and no production will be done.
void consumer() {
while(T) {
wait(F)
wait(S)
take()
signal(S)
signal(E)
use()
}
}
If the buffer is empty i.e. āFā is ā0ā, no consumption will be made.