semaphore.cpp example