Use semaphores instead of locks