Question: what is the difference between semaphore and condition variable?
Answer: In most systems, boolean semaphores are just a special case of counting semaphores, also known as general semaphores. The condition variable is a synchronization primative that provides a queue for threads waiting for a resource.