use gcc atomic sync function