add semaphore initialization code