Add memory barrier to synchronization primitives