Implement producer/consumer with semaphores