synchronization with semaphore