UNIX, using semaphores for buffer synchronization, implement producer and consumer