establish the semaphore
fix a bug of Msemaphore