RW lock functions using atomic builtins