Added barrier and semaphore