use semaphore instead of mutex and condition variable