use semaphore to solve the producer and consumer problem