Implement events using semaphores.