implement the semaphore using mutex && cond-var