another c code example to understand semaphore