Every Modern OS provides today some atomic operations:
Interlocked*
Recent standards (from 2011) of C & C++ now specify atomic operations:
Regardless, your platform or compiler may not support these newer headers & features.