the usage of mutex and semaphore