Pergunta de entrevista da empresa AMD

c++ threads usage, semaphore, how to write thread safe code