CMPXCHG
} while ((nflags = CMPXCHG(&shared[ref].flags, flags, 0)) != flags);
if (CMPXCHG(&shared[ref].flags, flags, 0) == flags)