sample code for semaphore